Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Optional per-thread startup procedure #163

Closed
awr1 opened this issue Aug 1, 2020 · 1 comment · Fixed by #164
Closed

[Request] Optional per-thread startup procedure #163

awr1 opened this issue Aug 1, 2020 · 1 comment · Fixed by #164
Labels

Comments

@awr1
Copy link
Contributor

awr1 commented Aug 1, 2020

Could init(Weave) take in an optional procedure that gets executed on every thread (i.e. no stealing, inside of worker_entry_fn) on startup before their respective event loops start?

Sometimes there is a need for preconfigured thread-local initial state that we have to have applied to all threads - spawning a proc after init is potentially error-prone due to the work-stealing mechanism. The specific use case I am thinking of involves the FPU state. In games and other realtime applications, handling denormal IEEE 754 values can cause increased arithmetic latency so we setup the FPU on program initialization to compress denormal values to zero (DTZ) wherever possible. Because each thread has its own FPU state, DTZ needs be activated on all threads we're handling arithmetic on. There may be other use cases for a user-specifiable per-thread startup procedure but this is the most significant one I can think of.

@mratsim
Copy link
Owner

mratsim commented Aug 20, 2020

I'm all for it.

And exit should allow for a cleanup procedure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants