[ADMB Users] Does CUDA suck? answer NO!
dave fournier
davef at otter-rsch.com
Sat Sep 3 16:05:40 PDT 2011
First there is an error in the code. It should read
return z;
and not
return x+y;
However I thought that maybe the problem is that addition is too
trivial compared to the
overhead of moving things to the GPU and back. I changed the function to
pow(x,y)
and lo! the el cheapo GPU is faster (about 6 times faster).
So how hard is a vector pow. All that was necessary was to take the
included VecAdd
function and modify it to
__global__ void VecPow(const double* A, const double* B, double* C, int N)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
double x=0.0;
if (i < N)
{
C[i] = pow(A[i],B[i]);
}
}
Code is attached. Note I use mypow just to avoid clash with existing
admb libs.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myvecpow.zip
Type: application/zip
Size: 7605 bytes
Desc: not available
URL: <http://lists.admb-project.org/pipermail/users/attachments/20110903/04fbb1be/attachment.zip>
More information about the Users
mailing list