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

Modify task counting in thread_queue.hpp #3242

Merged
merged 2 commits into from Mar 19, 2018
Merged

Modify task counting in thread_queue.hpp #3242

merged 2 commits into from Mar 19, 2018

Conversation

msimberg
Copy link
Contributor

@msimberg msimberg commented Mar 16, 2018

Proposed Changes

  • Make sure that new_tasks_count_ is decremented only after a corresponding count has been incremented (when moving tasks from one queue to another)
  • This is to make sure new_tasks_count_ + thread_map_count_ never goes to 0 while there are tasks available (see below for example)

Any background context you want to provide?

This is relevant for suspending the runtime after launching a task

// in main thread

// no tasks in queues at this point
hpx::async(...); // task added to new_tasks
// scheduler on worker thread removes task from new_tasks (decrements count)
hpx::suspend(); // get_thread_count returns 0, runtime suspends even though
                // it should wait for the async task to run
// scheduler on worker thread adds task to thread_map (increments count)

I find this a bit ugly, but I expect it to be temporary. Once #3146 and a follow up PR to remove the new_tasks_ queue are merged, this will not be needed anymore.

A bit last minute, but this I would still like to have in the release assuming tests pass.

This is done to ensure that the sum of thread_map_count_ and new_tasks_count_ is never lower than the real number of tasks.
Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

Excellent catch!

@msimberg msimberg merged commit f1a3454 into master Mar 19, 2018
@msimberg msimberg deleted the msimberg-patch-1 branch March 19, 2018 12:29
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

2 participants