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

Add OS thread suspension #3046

Merged
merged 74 commits into from Dec 8, 2017
Merged

Conversation

msimberg
Copy link
Contributor

@msimberg msimberg commented Dec 4, 2017

This adds functionality to suspend and resume threads (and fixes throttling, thus replaces #2994).

Notes:

  • in order to support suspending the pu on which the suspending thread is running the scheduling loop exit criteria have been relaxed a bit
  • cleanup_terminated only cleans up terminated threads and returns true if there are none left (the checks for remaining work have been moved out to the scheduling loop)
  • this adds a background thread count, the count is used to wait for the runtime/thread_pool_executor/this_thread_executor to finish their work (instead of relying on each pu to wait for other pus in the pool)
  • {remove,add,suspend,resume}_processing_unit and create_thread (in schedulers) are locked with thread specific mutexes to avoid scheduling work when a pu is being suspended/removed (but the lock in create_thread is only taken if elasticity is enabled)
  • create_thread checks the state of the scheduler to decide if it's running or not instead of checking used_processing_units (but again only if elasticity is enabled)
  • the used_processing_units mask is only used for setting the affinity of service threads
  • the used_processing_units mask is recomputed when requested to account for removed/suspended pus and different affinity masks per pu

Some schedulers are not tested:

  • the static schedulers are not tested because they do not steal work
  • the periodic scheduler is not tested because it doesn't check the state of the pus and might schedule work on suspended pus (candidate for removal, so I have not fixed this)

msimberg and others added 30 commits November 2, 2017 14:02
One version takes the thread number and the other cleans up in all worker
threads.
Add HPX_EXPORT to hopefully fix msvc build errors.
Preparation for adding suspension which can be more relaxed.
Testing the wrong thing, the correct functions are not yet implemented.
@msimberg msimberg mentioned this pull request Dec 4, 2017
2 tasks
@msimberg msimberg changed the title Add suspension of threads Add OS thread suspension Dec 4, 2017
@msimberg msimberg mentioned this pull request Dec 4, 2017
4 tasks
@hkaiser hkaiser added this to the 1.1.0 milestone Dec 4, 2017
@msimberg
Copy link
Contributor Author

msimberg commented Dec 4, 2017

This breaks some tests again with the latest commit, but I think I know the cause. Will try to fix it tomorrow.

@msimberg msimberg removed this from the 1.1.0 milestone Dec 5, 2017
Copy link
Member

@sithhell sithhell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as advertised!

@sithhell sithhell merged commit 82f7b28 into STEllAR-GROUP:master Dec 8, 2017
@msimberg msimberg added this to the 1.1.0 milestone Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants