Skip to content

Instantly share code, notes, and snippets.

@shahrzad
Created June 25, 2021 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahrzad/b81e1eb252880aca48528d2de0bd1d10 to your computer and use it in GitHub Desktop.
Save shahrzad/b81e1eb252880aca48528d2de0bd1d10 to your computer and use it in GitHub Desktop.
void measure_for_loop(uint64_t count, bool csv,
uint64_t chunk_size, uint64_t iter_length)
{
hpx::util::high_resolution_timer walltime;
using for_loop = hpx::parallel::for_loop;
using ex = hpx::parallel::execution;
using dcs = dynamic_chunk_size;
for_loop(ex::par.with(ex::dcs( chunk_size )), 0, count,
[&](uint64_t)
{
worker_timed(iter_length*1000);
});
const double duration = walltime.elapsed();
}
int hpx_main(variables_map& vm)
{
for (int i = 0; i < repetitions; i++)
{
measure_for_loop(count, csv, chunk_size, iter_length);
}
return hpx::finalize();
}
inline void worker_timed(uint64_t delay_ns)
{
using clock = hpx::util::high_resolution_clock;
uint64_t start = clock::now();
while ((clock::now() - start) >= delay_ns) {};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment