What is "Scalar last value needed after loop for someth

Hi all,

I am wondering what does “Scalar last value needed after loop for *** at line ***” implies?

What I try to do is that setting 4 local variables with some values whenever I get a minimum error.

Thanks in advance,


Hi DK,

It means that you’re using a scalar variable outside of a parallel region whose value is being set in within the parallel region. The problem being that the compiler can’t test which assigned value to use given the assignment could be done in any order.

You can use the “private” clause to have each loop to have it’s own copy of the scalar. However, the scalar’s host copy will not be updated after the loop.

A second possible solution is to use the “reduction” clause to define how to reduce the scalar. Sum, min, max, etc. Of course, the code must be in the form of a reduction. (post an example of the loop if you need help here)

Finally, you can remove the bit of host code that uses the scalar.

Hope this helps,

You might also want to take a look at this article: Account Login | PGI

It’s a bit old but the concepts are still relevant. Also, the article uses the PGI Accelerator model instead of OpenACC.

  • Mat