1
votes

Hi I was using CAPS OpenACC compilers, but it seems the compiler can not link the functions to the standard math.h.

Actually, in my case, sqrt function is used in my code within the acceleration loop. When I compile the code, below error is thrown out:

/tmp/cc8L0aKZ.o:compute_fluxes_XrxAnW.translated.i:function _flux_function_central: error: undefined reference to 'sqrt'

Anyone get some solutions?

Thanks!

2
what is the command you are using to link the code? Which language and host compiler are you using? - talonmies
$ caps capsmc --openacc-target CUDA --io-report -Xnvcc -arch=sm_13 -c --force gcc -std=c99 -L/usr/include/math.h compute_fluxes.c -o cf.13 - YuanZheCSYZ
The code is implemented in C, gcc - YuanZheCSYZ

2 Answers

1
votes

All accelerator code must be marked as such using the routine directive. Otherwise the compiler won't generate device code for it. PGI has an article explaining how to deal with this.

You can read the article, or just try adding the following with the other top-level declarations in your code:

#pragma acc routine(sqrt) seq
0
votes

Please retry with

caps capsmc --openacc-target CUDA --io-report -Xnvcc -arch=sm_13 -c --force gcc -std=c99 -L/usr/include/math.h **-lm** compute_fluxes.c -o cf.13

(-lm actually links with the standard math library )