I’m not going to claim to be the best programmer (by a long shot), but I can not figure out what I am doing wrong in my code. I am trying to initialize a variable that is of a struct type, and then initialize the pointers I have inside that struct. I whipped up a test code so I could isolate the effect, and I will post it below:
using namespace std;
int a; int *b;
test* x; x=(test*)malloc(sizeof(test)); x->a=2; x->b=(int*)malloc(10*sizeof(int)); for (int l=0; l<10; l++) x->b[l]=l; cout <<"\nx->a= "<<x->a; for (int l=0; l<10; l++) cout <<"\nx->b["<<l<<"]= "<<x->b[l]; cout<<endl; test* x_d; cudaMalloc((void**)&x_d,sizeof(test)); cudaMemcpy(&(x_d->a),&(x->a),sizeof(test),cudaMemcpyHostToDevice); cudaMalloc((void**)&(x_d->b),10*sizeof(int*)); //Would add more once I get past this point!
The terminal output is as follows:
[codebox]nvcc test.cu -run
Thanks for any help you can give, I have been stumped by this for a bit too long now.
p.s. I forgot to mention: I have had no problems running any of the SDK samples, and so I believe the driver/toolkit/sdk are all installed just fine on my PC.
My setup is a core2duo e6600, Ubuntu 9.04, 2gb ram, 8800gts 312mb.