Skip to content

Instantly share code, notes, and snippets.

@mcopik
Created August 5, 2016 17:56
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 mcopik/d34318766bb8dc8404255026c47a28c1 to your computer and use it in GitHub Desktop.
Save mcopik/d34318766bb8dc8404255026c47a28c1 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <iterator>
#include <cassert>
#include <cmath>
#include <chrono>
#include <hpx/hpx_init.hpp>
#include <hpx/hpx.hpp>
#include <hpx/version.hpp>
#include <hpx/include/parallel_algorithm.hpp>
#include <hpx/include/parallel_executors.hpp>
int main()
{
const int size = 1000000;
float * a = new float[size], * b = new float[size], *c = new float[size];
hpx::parallel::fill(hpx::parallel::par, a, a + size, 1.0f);
//hpx::parallel::fill(hpx::parallel::par, b, b + size, 2.0f);
auto start = std::chrono::high_resolution_clock::now();
// hpx::parallel::for_loop(hpx::parallel::par, 0, size,
// [a, b, c] (int i) {
// c[i] = a[i] + b[i];
// }
// );
auto end = std::chrono::high_resolution_clock::now();
std::cout << "Time: " << std::chrono::duration<double>(end-start).count() << std::endl;
for(int i = 0; i < size; ++i)
assert( fabs(c[i] - 3.0f) < 1e-6);
delete[] a;
delete[] b;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment