Skip to content

Commit

Permalink
Mapping default priority to normal priority at the last possible moment
Browse files Browse the repository at this point in the history
- also make sure high_recursive priority gets inherited only if no non-default priority is given
- flyby: fix get_thread_priority_name()
  • Loading branch information
hkaiser committed Jul 12, 2017
1 parent 178575b commit a5a7c6f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
6 changes: 4 additions & 2 deletions hpx/runtime/actions/action_priority.hpp
Expand Up @@ -21,8 +21,10 @@ namespace hpx { namespace actions
threads::thread_priority priority =
static_cast<threads::thread_priority>(
traits::action_priority<action_type_>::value);
if (priority == threads::thread_priority_default)
priority = threads::thread_priority_normal;
// The mapping to 'normal' is now done at the last possible moment in
// the scheduler.
// if (priority == threads::thread_priority_default)
// priority = threads::thread_priority_normal;
return priority;
}
}}
Expand Down
6 changes: 4 additions & 2 deletions hpx/runtime/actions/action_support.hpp
Expand Up @@ -195,8 +195,10 @@ namespace hpx { namespace actions
static threads::thread_priority
call(threads::thread_priority priority)
{
if (priority == threads::thread_priority_default)
return threads::thread_priority_normal;
// The mapping to 'normal' is now done at the last possible moment
// in the scheduler.
// if (priority == threads::thread_priority_default)
// return threads::thread_priority_normal;
return priority;
}
};
Expand Down
11 changes: 8 additions & 3 deletions hpx/runtime/threads/detail/create_thread.hpp
Expand Up @@ -70,16 +70,21 @@ namespace hpx { namespace threads { namespace detail
if (nullptr == data.scheduler_base)
data.scheduler_base = scheduler;

// Pass critical priority from parent to child.
// Pass critical priority from parent to child (but only if there is
// none is explicitly specified).
if (self)
{
if (thread_priority_high_recursive ==
threads::get_self_id()->get_priority())
if (data.priority == thread_priority_default &&
thread_priority_high_recursive ==
threads::get_self_id()->get_priority())
{
data.priority = thread_priority_high_recursive;
}
}

if (data.priority == thread_priority_default)
data.priority == thread_priority_normal;

// create the new thread
std::size_t num_thread = data.num_os_thread;
scheduler->create_thread(data, &id, initial_state, run_now, ec, num_thread);
Expand Down
8 changes: 6 additions & 2 deletions hpx/runtime/threads/detail/create_work.hpp
Expand Up @@ -81,13 +81,17 @@ namespace hpx { namespace threads { namespace detail
// Pass critical priority from parent to child.
if (self)
{
if (thread_priority_high_recursive ==
threads::get_self_id()->get_priority())
if (data.priority == thread_priority_default &&
thread_priority_high_recursive ==
threads::get_self_id()->get_priority())
{
data.priority = thread_priority_high_recursive;
}
}

if (data.priority == thread_priority_default)
data.priority == thread_priority_normal;

// create the new thread
if (thread_priority_high == data.priority ||
thread_priority_high_recursive == data.priority ||
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/threads/threadmanager.cpp
Expand Up @@ -117,7 +117,7 @@ namespace hpx { namespace threads

char const* get_thread_priority_name(thread_priority priority)
{
if (priority < thread_priority_default || priority > thread_priority_boost)
if (priority < thread_priority_default || priority > thread_priority_high)
return "unknown";
return strings::thread_priority_names[priority];
}
Expand Down

0 comments on commit a5a7c6f

Please sign in to comment.