So my problem is, I am passing a variable by value (it is a float) from one function in my C code to another function. For some reason the variable is 0 after the pass. I have multiple other floats being passed by value, that are not 0 (all in the same function call), so I can't understand why this one is. It might be as simple as some typo that I am just not seeing:
int cuda_call(float *h_DataA, float *h_Kernel, int numSmooths, float kernelSum, int KERNEL_R, int KERNEL_W, int DATA_W){
printf("\n What am I here?: %f \n", kernelSum);
convolutionProgram(h_DataA, h_Kernel, numSmooths, kernelSum, KERNEL_R, KERNEL_W, DATA_W);
return 1;
}
extern "C" void convolutionProgram(float *h_DataA, float *h_Kernel, int numSmooths, float kernelSum, int KERNEL_R, int KERNEL_W, int DATA_W);
void convolutionProgram(float *h_DataA, float *h_Kernel, int numSmooths, float kernelSum, int KERNEL_R, int KERNEL_W, int DATA_W){
printf("\n what am I now? %f \n", kernelSum);
float
*d_DataA,
*d_DataB,
*d_Temp,
*d_Kernel;
.......
}
By the time I get to that second print in the called function, it is 0.
Maybe you have somehow ended up mixing calling conventions (ABIs). For instance, the first compilation unit may be performing a cdecl
call, while the second one is compiled with fastcall
.
Is it possible that you have not rebuilt the object file for one of the c files? This looks like a signature mismatch which can arrise from a function signature change without rebuilding both object files.