Hello,
I think I found a bug in the nvc++ compiler. To give you some context, I’m trying to use the stl parallel algorithms with a std::function. It generates an internal error in the compiler. I tried to create a simple example that generates this issue.
Here is the error I get :
nvc++ -std=c++20 -stdpar=gpu -gpu=cuda12.0 -O4 test2.cpp -o test2
NVC++-F-0000-Internal compiler error. cf_data_init: unknown datatype -54 (test2.cpp)
NVC++/x86-64 Linux 23.1-0: compilation aborted
Here’s the code that produces this error :
/*
Issue small example
*/
#include <algorithm>
#include <execution>
#include <functional>
#include <vector>
constexpr size_t kSize = static_cast<size_t>(1.5e6);
int main() {
std::vector<float> in_vect(kSize);
std::vector<float> out_vect(kSize);
for (int i = 0; i < kSize; i++) {
in_vect[i] = static_cast<float>(std::rand() - RAND_MAX / 2);
}
std::function<float(float)> multiply_by_two = [](float f) { return 2.0F * f; };
std::transform(std::execution::par, in_vect.begin(), in_vect.end(), out_vect.begin(), multiply_by_two);
return 0;
}
Configuration :
- HPC SDK 23.1
- CUDA 12.0
- Linux x86_64
edit: This piece of code compiles and works with gcc 12.1.0 and 11.3.0
g++ -std=c++20 test2.cpp -ltbb -O3 -o test2 && ./test2