I have been working on porting a code that uses the Eigen library to use OpenMP target offload with NVC++ 22.1.
Trying to use Eigen in offloaded regions sometimes produces the following error:
NVC++-S-0000-Internal compiler error. accel.c::acc_remove_atomics: ILI_ALT is missing for atomicrmw opcode 402 (stripped_tmp.cpp: 402)
NVC++/x86-64 Linux 22.1-0: compilation completed with severe errors
which I have managed to reproduce with the small example:
#include <atomic>
int main() {
#pragma omp target
{
std::atomic<int> x{};
x -= 1;
}
}
or with no #includes
void sub() {
int i{}, j{};
__atomic_sub_fetch(&i, j, int());
}
int main() {
#pragma omp target
{
sub();
}
}
compiled with nvc++ -mp=gpu test.cpp.
On our system nvc++ is configured to use headers from GCC 11.2.0. Please let me know if any other information would be helpful.
In the meantime, we have a workaround where we compile the relevant Eigen functions as CUDA code and then call those CUDA-defined functions from OpenMP offload regions, but this is a bit of a frustrating kludge.
Using std::atomic in OpenMP offload regions is expected to work, hence I’ve filed a problem report, TPR #31305, and sent it to engineering for investigation.