Does OpenMP natively support reduction of a variable that represents an array?
This would work something like the following...
float* a = (float*) c
OpenMP can perform this operation as of OpenMP 4.5 and GCC 6.3 (and possibly lower) supports it. An example program looks as follows:
#include
#include
int main(){
std::vector vec;
#pragma omp declare reduction (merge : std::vector : omp_out.insert(omp_out.end(), omp_in.begin(), omp_in.end()))
#pragma omp parallel for default(none) schedule(static) reduction(merge: vec)
for(int i=0;i<100;i++)
vec.push_back(i);
for(const auto x: vec)
std::cout<
Note that omp_out and omp_in are special variables and that the type of the declare reduction must match the vector you are planning to reduce on.