Hi there, i’m trying to run a simple NVC++ parallel program but it fails to compile.
Here’s the code:
#include <iostream>
#include <execution>
#include <vector>
#include <algorithm>
int main() {
std::vector<float> input((int)1e8, 2.0);
std::vector<float> output(input.size());
// std::transform(std::execution::par_unseq,input.begin(), input.end(), output.begin(), [](float f){return f*f;});
float result = std::transform_reduce(std::execution::par_unseq, output.begin(), output.end(), 0.0f,
[](float a, float b){return a+b;}, [](float f){return f*f;});
std::cout << "Hello, World! Result is: " << result << " and it should be: " << 4.0*input.size() << std::endl;
return 0;
}
I’m compiling with:
$ nvc++ -stdpar main.cpp -o main
On Ubuntu 20.04 LTS, with driver version 470.82.00 and Cuda Version 11.4
I’ve tried this but it doesn’t help. Thank you all for your help!