How to avoid implicit reduction in OpenACC?

When compiling my fortran code with openacc, it shows implicit reduction on several private variables which are not supposed to have such operation. How should I manually stop it from doing so?


Do you have a reproducing example?

If the compiler is detecting a reduction, then it may be needed. Though it’s hard to tell without seeing what the code is doing.

Hi MatCogrove,

I think I figured it out. I am using Fortran and the implicit reduction is for the dot_product of two vectors:

“dist = dsqrt(dot_product(r,r))”.

I guess it is treated as a loop, right?

DOT_PRODUCT is a function, but could be getting inlined, in which case it could turn into a loop.

Hi Mat,

It seems like using dot_product slows down the program a lot. Is there any alternative that is fast but does not need to write it as a do loop?


I’m hesitant to offer any specific advice here without a reproducing example. Before you go too far down the path of writing your own manually unrolled version of dot product, we should make sure the original reduction question does indeed come from the dot_product, is detrimental, and if so, are there any better options.