5

I am trying to make this for-loop parallelized by using Openmp, i recognized that there reduction in this loop so i added "#pragma omp parallel for reduction(+,ftab)",but it did not work and it gave me this error : error: user defined reduction not found for ‘ftab’.

   #pragma omp parallel for reduction(+:ftab)
    for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1];

1 Answer 1

3

The operation you want to do is prefix sum. It can be done in parallel. A simple way is to use thrust::inclusive_scan with OpenMP or TBB backend.

thrust::inclusive_scan(thrust::omp::par, ftab, ftab + 65536, fab);

or

thrust::inclusive_scan(thrust::tbb::par, ftab, ftab + 65536, fab);

You could also implement it by yourself as referenced in the Wikipedia page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.