Sending parameters to extern "C"

Hi

I’m trying to run a simple CUDA program from visual studio 2008:

File “CUDAFFT.h”:

global void zwap(double u_mat,int x_s, int y_s)
{
const int y = blockDim.y * blockIdx.y + threadIdx.y;
const int x = blockDim.x * blockIdx.x + threadIdx.x;
u_mat[(x
y_s+y)2]=u_mat[(xy_s+y)*2]+10;
}

extern “C” void runZwap(double *u_mat, int x_s, int y_s)
{
dim3 numBlocks=(32,32);
dim3 threadsPerBlock=(32,32);
zwap<<<numBlocks,threadsPerBlock>>>(u_mat,x_s,y_s);
}

When I’m calling “runZwap” and sending parameters from “CUDAFFT.cpp” I’m getting junk in the function.

Please help

Moti

There are no parameter values in your post. Check the array length, probably you are out of boundary even if the code doesn’t fail.

Thanks but I cant even send the int parameters,
I am calling it like this:

double *pdblArrayInGPU = (double *)u_gpu;
runZwap(pdblArrayInGPU,1024,1024);

So, I’m sending 1024 for int x_s and 1024 for int y_s but in the function I’m getting:

x_s=176570528
y_s=16777216

Which of the functions you mean - runZwap or zwap?

runZwap is getting junk parameters for some reason, I do not know why

What does give sizeof(x_s) in runZwap and sizeof() ?

both cases 4

Sorry, don’t have a running VS right now to check. The only thing: how do you read the values - in a tracer or print out with some format?

I read it with a tracer.

I will try with print.

I took the function and put it in CUDA example: convolutionFFT2D
and it works fine there so I think that it might be some issue with linking maybe project setting or something?

Thank You

It is o.k. in printf(), and so it is getting the correct values

Thanks

You may try to compare the calling convention setting (_cdecl, _stdcal,…l)