I want to use atomic functions with OpenACC directives. What are the compile options of pgc++ that can help? Should I use a particular header file?
Asked
Active
Viewed 1,462 times
2
-
1All atomic operations in OpenACC are provided by `#pragma acc atomic` directives. Your compiler needs to support V2.0 of the standard or later – talonmies Sep 01 '16 at 14:19
-
I tried these directives but I get compilation errors. For #pragma acc atomic {res[i][i]=res[i][i]+x}, i have no compilation error, but for #pragma acc atomic {res[i][i]=res[i][i]+x res[j][j]=res[j][j]+y}, I get PGCC-S-0155-Invalid atomic expression – Constantinus Spanakis Sep 01 '16 at 18:35
1 Answers
1
One thing to check: are you using the right data? Per this forum not all accelerators accept all data types and, possibly, not all data types can be accessed atomically. Table 13 at this link indicates that atomics on Nvidia seem to only be available for 32-bit integer and floating-point datatypes. 64-bit is available for compute capacities 6.x+.
You say your code looks like:
#pragma acc atomic
{
res[i][i]=res[i][i]+x;
res[j][j]=res[j][j]+y;
}
However, I don't think you can nest multiple atomics together like that. Try, instead:
#pragma acc atomic update
res[i][i]=res[i][i]+x;
#pragma acc atomic update
res[j][j]=res[j][j]+y;

Richard
- 56,349
- 34
- 180
- 251