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

Making sure generated performance counter names are correct #2906

Merged
merged 1 commit into from
Sep 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/performance_counters/counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,20 +1098,17 @@ namespace hpx { namespace performance_counters
// now expand "pool#*"
if (detail::is_pool_kind(p.instancename_))
{
bool expand_threads = detail::is_thread_kind(p.subinstancename_);

counter_info i = info;
p.instancename_ = detail::get_pool_kind(p.instancename_);
if (!detail::expand_counter_info_threads(i, p, f, ec))
return false;

if (detail::is_thread_kind(p.subinstancename_))
if (expand_threads)
{
counter_info i = info;
p.subinstancename_ =
detail::get_thread_kind(p.subinstancename_) + "-thread";
return detail::expand_counter_info_threads(i, p, f, ec);
p.subinstancename_ = detail::get_thread_kind(
p.subinstancename_) + "-thread";
}

return true;
return detail::expand_counter_info_pools(
expand_threads, i, p, f, ec);
}

if (detail::is_thread_kind(p.instancename_))
Expand Down
36 changes: 23 additions & 13 deletions src/runtime/resource/detail/detail_partitioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,12 @@ namespace hpx { namespace resource { namespace detail
}
}

std::lock_guard<mutex_type> l(mtx_);
std::unique_lock<mutex_type> l(mtx_);

// @TODO allow empty pools
if (get_pool_data("default").num_threads_ == 0)
{
l.unlock();
throw_runtime_error("partitioner::setup_pools",
"Default pool has no threads assigned. Please rerun with "
"--hpx:threads=X and check the pool thread assignment");
Expand All @@ -381,6 +382,7 @@ namespace hpx { namespace resource { namespace detail
// Check whether any of the pools defined up to now are empty
if (check_empty_pools())
{
l.unlock();
throw_runtime_error("partitioner::setup_pools",
"Pools empty of resources are not allowed. Please re-run this "
"application with allow-empty-pool-policy (not implemented "
Expand Down Expand Up @@ -542,7 +544,7 @@ namespace hpx { namespace resource { namespace detail
"as a name.");
}

std::lock_guard<mutex_type> l(mtx_);
std::unique_lock<mutex_type> l(mtx_);

if (pool_name == "default")
{
Expand All @@ -556,6 +558,7 @@ namespace hpx { namespace resource { namespace detail
{
if (pool_name == initial_thread_pools_[i].pool_name_)
{
l.unlock();
throw std::invalid_argument(
"partitioner::create_thread_pool: "
"there already exists a pool named '" + pool_name + "'.\n");
Expand Down Expand Up @@ -585,7 +588,7 @@ namespace hpx { namespace resource { namespace detail
"as a name.");
}

std::lock_guard<mutex_type> l(mtx_);
std::unique_lock<mutex_type> l(mtx_);

if (pool_name == "default")
{
Expand All @@ -600,6 +603,7 @@ namespace hpx { namespace resource { namespace detail
{
if (pool_name == initial_thread_pools_[i].pool_name_)
{
l.unlock();
throw std::invalid_argument(
"partitioner::create_thread_pool: "
"there already exists a pool named '" + pool_name + "'.\n");
Expand All @@ -625,10 +629,11 @@ namespace hpx { namespace resource { namespace detail
"been started");
}

std::lock_guard<mutex_type> l(mtx_);
std::unique_lock<mutex_type> l(mtx_);

if (!exclusive && !(mode_ & mode_allow_dynamic_pools))
{
l.unlock();
throw std::invalid_argument(
"partitioner::add_resource: dynamic pools have not been "
"enabled for this partitioner");
Expand Down Expand Up @@ -659,6 +664,7 @@ namespace hpx { namespace resource { namespace detail
&& detail::init_pool_data::num_threads_overall == cfg_.num_threads_) {
// then it's all fine
} else {*/
l.unlock();
throw std::runtime_error(
"partitioner::add_resource: " "Creation of " +
std::to_string(detail::init_pool_data::num_threads_overall) +
Expand All @@ -671,6 +677,7 @@ namespace hpx { namespace resource { namespace detail
}
else
{
l.unlock();
throw std::runtime_error(
"partitioner::add_resource: " "PU #" + std::to_string(p.id_) +
" can be assigned only " + std::to_string(p.thread_occupancy_) +
Expand Down Expand Up @@ -738,13 +745,14 @@ namespace hpx { namespace resource { namespace detail
scheduling_policy partitioner::which_scheduler(
std::string const& pool_name)
{
std::lock_guard<mutex_type> l(mtx_);
std::unique_lock<mutex_type> l(mtx_);

// look up which scheduler is needed
scheduling_policy sched_type =
get_pool_data(pool_name).scheduling_policy_;
if (sched_type == unspecified)
{
l.unlock();
throw std::invalid_argument(
"partitioner::which_scheduler: " "Thread pool " + pool_name +
" cannot be instantiated with unspecified scheduler type.");
Expand Down Expand Up @@ -827,7 +835,6 @@ namespace hpx { namespace resource { namespace detail
std::string const& partitioner::get_pool_name(
std::size_t index) const
{
std::lock_guard<mutex_type> l(mtx_);
if (index >= initial_thread_pools_.size())
{
throw_invalid_argument(
Expand Down Expand Up @@ -891,9 +898,10 @@ namespace hpx { namespace resource { namespace detail
scheduler_function partitioner::get_pool_creator(
std::size_t index) const
{
std::lock_guard<mutex_type> l(mtx_);
std::unique_lock<mutex_type> l(mtx_);
if (index >= initial_thread_pools_.size())
{
l.unlock();
throw std::invalid_argument(
"partitioner::get_pool_creator: pool requested out of bounds.");
}
Expand Down Expand Up @@ -1033,14 +1041,16 @@ namespace hpx { namespace resource { namespace detail
std::size_t partitioner::get_pool_index(
std::string const& pool_name) const
{
std::lock_guard<mutex_type> l(mtx_);

std::size_t num_pools = initial_thread_pools_.size();
for (std::size_t i = 0; i < num_pools; i++)
{
if (initial_thread_pools_[i].pool_name_ == pool_name)
std::lock_guard<mutex_type> l(mtx_);

std::size_t num_pools = initial_thread_pools_.size();
for (std::size_t i = 0; i < num_pools; i++)
{
return i;
if (initial_thread_pools_[i].pool_name_ == pool_name)
{
return i;
}
}
}

Expand Down