K
K
Kirill Batalin2016-02-27 14:41:40
C++ / C#
Kirill Batalin, 2016-02-27 14:41:40

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

That is, is it possible to somehow set in reduction several operations / functions that need to be performed on the variable at the end?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question