Answer the question
In order to leave comments, you need to log in
How to define multiple operations in OpenMP reduction?
Is there any way to shorten this code?
double tmp = 0;
#pragma omp parallel
{
#pragma omp for reduction(+:tmp)
for (int i = 0; i < N; ++i) {
tmp += i * i;
}
#pragma omp single
{
tmp = sqrt(tmp);
}
} //end #pragma omp parallel
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question