loop carried scalar dependence and acc routine seq


I have a function containing a simple reduction loop. Since the loop count varies, but is typically too small to be worth run in parallel, I have declared it as “acc routine seq” to express my intention. However, the compiler reports the following:

  1415, Generating acc routine seq
  1427, Loop carried scalar dependence for JJ at line 1430
         Scalar last value needed after loop for JJ at line 1440

Does the compiler just proactively warn me not to declare the routine as gang or vector because of the loop carried dependence and I can simply ignore it in my case? I think it would be better if the message were only generated in case I had specified gang or vector leading to undefined behavior.


Hi LS,

Yes, the compiler feedback message do tend to error on the side of giving too much information which can sometimes be extraneous. The counter might be that if the loop at line 1427 was parallelizable, you might use this information to change the routine to be “vector”.

There’s also a phasing issue in that the dependency analysis step occurs before scheduling so that the messages are produced before the compiler knows the context.

One thing you might try is adding “#pragma acc loop seq” before the loop at line 1427. The compiler may then skip the dependency analysis for this loop and hence not produce any messages.

  • Mat

Hi Mat,

Specifying “#pragma acc loop seq” before the loop in the routine that I want to be sequential is a good way to make my intention clear and it works, i.e. the compiler no longer complains about all the issues it detects regarding parallelization of the loop.