How do I get the device to do logarithms?

Hey all,

I am trying to execute a logarithm operation on the device. I know the “log” function I am using is a host function, which is only executable in device emulation mode. Anyone know what the name of the real device function is? And where do I find a list of them?

Thank you muchly

[codebox]device void drawExp(double* draw,int size, double beta){

int i;

for(i=0;i<size;i++){

	draw[i] =  -log(rand())/beta;

}

}[/codebox]

wait, wait… I found the log function. Its the rand() that’s causing the problem. How do I draw a random number in cuda?

Appendix B of the programming guide has what you want.

The natural logarithm in single precision is logf() and the double is log(). I think you will find that rand() is the problem…

External Media Have a look at the CUDA Programming Guide

Regards

Navier

Oooops… to slow