Created
August 5, 2016 17:56
-
-
Save mcopik/d34318766bb8dc8404255026c47a28c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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