Hello,
I have a problem using OpenMP atomic with PGI compiler versions 19 and 20.
Here is a simple reproducer:
#include <iostream>
#include <vector>
#include <random>
#include <omp.h>
int main()
{
const int SIZE = 10;
std::vector<double> vect(SIZE);
#pragma omp parallel
{
auto rank = omp_get_thread_num();
std::mt19937 rand;
rand.seed(rank);
std::uniform_real_distribution<double> double_dist;
std::uniform_int_distribution<int> int_dist(0,SIZE-1);
auto index = int_dist(rand);
auto val = double_dist(rand);
#pragma omp atomic
vect[index] += val;
}
for (const auto& v : vect)
std::cout << v << " ";
std::cout << std::endl;
return 0;
}
This compiles with PGI 18.7 but not with PGI 19.10 nor PGI 20.10 with -O0 or -O1 optimization levels:
$ pgc++ --version
pgc++ 20.1-0 LLVM 64-bit target on x86-64 Linux -tp skylake
PGI Compilers and Tools
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
$ pgc++ -O1 -std=c++11 -mp test2.cpp
PGC++-S-0000-Internal compiler error. get_dtype_from_ilm: unexpected ILM opc 2 (test2.cpp: 21)
PGC++-S-0155-Invalid atomic update statement. (test2.cpp: 21)
PGC++/x86-64 Linux 20.1-0: compilation completed with severe errors
$ pgc++ -O2 -std=c++11 -mp test2.cpp
$ ./a.out
6.37603 3.54772 5.52872 4.60111 2.51587 6.62821 1.46953 2.05598 3.59274 4.26629
Thanks in advance.