Skip to content

Commit

Permalink
Even more work on #1281: reset idle rate counter
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Oct 3, 2014
1 parent 2c7939f commit 70ded8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions hpx/runtime/threads/detail/scheduling_loop.hpp
Expand Up @@ -188,6 +188,7 @@ namespace hpx { namespace threads { namespace detail
{
start_timestamp_ = util::hardware::timestamp();
tfunc_time_ = 0;
exec_time_ = 0;
}
else
{
Expand Down
16 changes: 10 additions & 6 deletions src/runtime/threads/threadmanager.cpp
Expand Up @@ -1673,14 +1673,15 @@ namespace hpx { namespace threads
std::accumulate(tfunc_times.begin(), tfunc_times.end(), 0.);

if (reset) {
std::fill(exec_times.begin(), exec_times.end(), 0);
std::fill(tfunc_times.begin(), tfunc_times.end(),
boost::uint64_t(-1));
}

if (std::abs(tfunc_total) < 1e-16) // avoid division by zero
return 10000LL;

HPX_ASSERT(tfunc_total > exec_total);

double const percent = 1. - (exec_total / tfunc_total);
return boost::int64_t(10000. * percent); // 0.01 percent
}
Expand All @@ -1693,13 +1694,14 @@ namespace hpx { namespace threads
double const tfunc_time = static_cast<double>(tfunc_times[num_thread]);

if (reset) {
exec_times[num_thread] = 0;
tfunc_times[num_thread] = boost::uint64_t(-1);
}

if (std::abs(tfunc_time) < 1e-16) // avoid division by zero
return 10000LL;

HPX_ASSERT(tfunc_total > exec_total);

double const percent = 1. - (exec_time / tfunc_time);
return boost::int64_t(10000. * percent); // 0.01 percent
}
Expand All @@ -1718,15 +1720,16 @@ namespace hpx { namespace threads
std::accumulate(tfunc_times.begin(), tfunc_times.end(), 0.);

if (reset) {
std::fill(exec_times.begin(), exec_times.end(), 0);
std::fill(tfunc_times.begin(), tfunc_times.end(),
boost::uint64_t(-1));
}

// avoid division by zero
if (std::abs(tfunc_total - exec_total) == 0.0)
if (std::abs(tfunc_total - exec_total) < 1e-16)
return 10000LL;

HPX_ASSERT(tfunc_total > exec_total);

double const percent = (creation_total / (tfunc_total - exec_total));
return boost::int64_t(10000. * percent); // 0.01 percent
}
Expand All @@ -1743,15 +1746,16 @@ namespace hpx { namespace threads
std::accumulate(tfunc_times.begin(), tfunc_times.end(), 0.);

if (reset) {
std::fill(exec_times.begin(), exec_times.end(), 0);
std::fill(tfunc_times.begin(), tfunc_times.end(),
boost::uint64_t(-1));
}

// avoid division by zero
if (std::abs(tfunc_total - exec_total) == 0.0)
if (std::abs(tfunc_total - exec_total) < 1e-16)
return 10000LL;

HPX_ASSERT(tfunc_total > exec_total);

double const percent = (cleanup_total / (tfunc_total - exec_total));
return boost::int64_t(10000. * percent); // 0.01 percent
}
Expand Down

0 comments on commit 70ded8e

Please sign in to comment.