Sending parameters to extern "C"


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;

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

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

Please help


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;

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


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


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