Hi, I’m running the code below on a tesla node in our cluster, and I’m finding that every time I run it, the variables C and D persist after the run. running it multiple times causes the variables to just keep incrementing. This happens even if I compile the code into two different binaries, say ‘test1’ and ‘test2’. Running test2 will still increment the same variables that test1 used. This seems very odd to me. Anyone have a good guess at what’s going on here?
Thanks,
Paul
[codebox]/*
-
functor.cu
-
functor
*/
#include <stdio.h>
device struct myFex {
__device__ void operator()(int *bob, float *joe, int art, float big) {
*bob += art;
*joe += big;
}
};
global void Bill(int* A, float* B, int C, float D){
myFex bogoFex;
bogoFex(A,B,C,D);
}
int main (int argc, char * const argv) {
// insert code here...
printf("Hello World\n");
int *A, C;
float *B, D;
cudaMalloc((void**)&A,sizeof(int));
cudaMalloc((void**)&B,sizeof(float));
int* Ah;
float* Bh;
cudaMallocHost((void**)&Ah,sizeof(int));
cudaMallocHost((void**)&Bh,sizeof(float));
C = 5;
D= 7.2;
for(int itr = 0; itr <20; itr++){
Bill<<<1,1>>>(A,B,C,D);
cudaMemcpy(Ah,A,sizeof(int),cudaMemcpyDeviceToHost);
cudaMemcpy(Bh,B,sizeof(float),cudaMemcpyDeviceToHost);
printf("%i\t%f\n",*Ah,*Bh);
}
cudaFree(A);
cudaFree(B);
cudaFreeHost(Ah);
cudaFreeHost(Bh);
return 0;
}
[/codebox]