Undefined reference to __pgicudalib_curandUniformXORWOW


when I compile an OpenACC code that uses curand functions with “-g -O0” the resulting “out.o” contains the function __pgicudalib_curandUniformXORWOW. When I compile with “-O2/-O3” the object file does not contain said function. Now I could not find in which library this function may be present, thus I guessed that it is a built-in function that is taken care of by the compiler/linker. However the resulting library is part of a larger project which is linked with GCC. And finally I get an error that the symbol __pgicudalib_curandUniformXORWOW could not be found.
Now I have tried several compile flags “-Mcuda=nollvm”, “-Minline”, etc. however only using “-O2” seems to inline the function and solve my problem.
So my questions are, is there a library that contains this symbol?
And how can I inline it (get rid of it) in my object file while keeping “-O0”?

Kind regards,

Hi Rob,

So my questions are, is there a library that contains this symbol?

The answer depends on which compiler version you’re using, but assuming you’re using a more recent version, you should be able to either add the “openacc_curand” module or “openacc_curand.h” header file to your code, and then add “-cudalib=curand” at link.

For examples, please see the examples under the “<install_dir>/Linux_x86_64/22.5/examples/CUDA-Libraries/cuRAND” directory. In particular “test_rand_oacc_c/trand8.c” for C and “test_rand_oacc_ftn/trand5.f90” for Fortran.

Several years ago, you would have needed the “nollvm” option since the curand device header file needed to be included in the device code. This required needing the fall back CUDA device code generator (i.e. nollvm). But since we no longer support the CUDA device code generator, our engineers needed to find another solution.

Hope this helps,