Majed Badawi
Majed Badawi

Reputation: 28424

OpenACC unresolved extern function

I am trying to optimize a problem using OpenACC, however, there are some basic functions that are set as routines. The main problem I am facing is with the calloc function where it shows the following error at the end:

ptxas fatal : Unresolved extern function 'calloc'

The command for compiling used is:

pgcc acc.c -acc -Minfo=accel -ta=nvidia:cc60,nordc -o acc

I previously tried without the nordc flag, however, there was this error:

nvlink error : Undefined reference to 'calloc' in '/tmp/pgccqWXdW9NTZXUL.o'

nvlink error : Undefined reference to 'rand' in '/tmp/pgccqWXdW9NTZXUL.o

Upvotes: 0

Views: 172

Answers (1)

Mat Colgrove
Mat Colgrove

Reputation: 5646

Many system calls are not available on the device. While you could replace 'calloc' with 'malloc' which is available, I would highly advise not allocating within device code. Besides being very slow, the device heap is quite small (~32MB). You'll be better off if you can refactor your algorithm to not dynamically allocate data on the device.

For "rand", you'll want to call 'cuRand'. If you are using PGI, we ship examples on how to call cuRand under the "$PGI/2018/examples/CUDA-Libraries/curand" directory. Note that 'rand' is not thread safe so should not be used in a parallel context, host or device.

Upvotes: 2

Related Questions