#include #include #include #include #include #include #include #include #include "stopwatch.hpp" using namespace std; constexpr size_t dataSize = 10'000; constexpr size_t iterations = 1000; template void test(ExecutionPolicy&& exec, vector& v) { for (size_t iter = 0; iter < iterations; ++iter) { std::reverse(std::forward(exec), v.begin(), v.end()); } } template void test_hpx(ExecutionPolicy&& exec, vector& v) { for (size_t iter = 0; iter < iterations; ++iter) { hpx::parallel::reverse(std::forward(exec), v.begin(), v.end()); } } #pragma optimize("", off) int hpx_main(boost::program_options::variables_map& vm) { puts("reverse parallelism test"); printf("iterations: %zu elements: %zu size: %zu\n", iterations, dataSize, dataSize * sizeof(unsigned int)); random_device rd{}; vector data(dataSize); generate(data.begin(), data.end(), ref(rd)); stopwatch std_sequential; std_sequential.start(); test(execution::seq, data); std_sequential.stop(); std_sequential.print("std seq"); stopwatch std_parallel; std_parallel.start(); test(execution::par, data); std_parallel.stop(); std_parallel.print("std par"); printf("std par speedup: %f\n", std_parallel.compare(std_sequential)); stopwatch sequential; sequential.start(); test_hpx(hpx::parallel::execution::seq, data); sequential.stop(); sequential.print("HPX seq"); stopwatch parallel; parallel.start(); test_hpx(hpx::parallel::execution::par_unseq, data); parallel.stop(); parallel.print("HPX par_unseq"); printf("HPX par speedup: %f\n", parallel.compare(sequential)); return hpx::finalize(); } #pragma optimize("", on) int main(int argc, char* argv[]) { return hpx::init(argc, argv); }