pow function not compiling in CUDA kernel

hello, I use the pow() function twice throughout a global function, and the first causes a problem but it doesn’t complain about the second.

Just by taking a look, can anyone see what might be wrong?

works:
t2 = 24.0pow(10.0, 6.953-4.09*log10(envreal_.zwtemp[*iz][*iy][*ix]+26.0));

doesn’t work:
xweight[*i] = pow(xlength[*i]/kwt2lena, 1.0/kwt2lenb);

I get the message:
cuda.cu(166): error: calling a host function from a device/global function is only allowed in device emulation mode

thank you

are you compiling with support for double precision? if not, it’s probably picking up the host’s pow(double, double) instead of the device’s pow(float, float)

Hi,

I had a similar problem, and I do compile with “nvcc -arch=sm_13”.

It seems that CUDA simply doesn’t have declarations of pow(double,float) and pow(float,double), while it DOES HAVE pow(float,float) and pow(double, double). It can be easily seen here:

[codebox]

    double dA=2., dB=3.;

float	fA=2., fB=3.;

    double rdd,rff,rdf,rfd;

rdd=pow(dA,dB);

rff=pow(fA,fB);

rfd=pow(fA,dB);

rdf=pow(dA,fB);[/codebox]

Here the lines with rdd and rff compile ok, but the rfd and rdf give out the error " error: calling a host function from a device/global function is only allowed in device emulation mode".

A simple fix is to explicitly cast both arguments either to float or to double.

Cheers!