I have a problem setting up a pretty basic code, and I’ve never seen this particular problem before. The code I have looks like this:
[codebox]void doCudaStuff(InputStruct * in)
InputStruct* in_d; // device memory
cutilSafeCall(cudaMalloc((void**) &in_d, sizeof(InputStruct)));
// I have error checks and prints that show that in_d does contain an address (typically 0x01000600)
// sizeof(InputStruct) == 32
cutilSafeCall(cudaMemcpy(in_d, in, sizeof(InputStruct), cudaMemcpyHostToDevice)); // fails
The error occurs on the line with cudaMemcpy. ‘fatal error in “foo::doCudaStuff”: memory access violation at address: 0x01000600: non-existent physical address.’
I’m running OSX Snow Leopard with CUDA 2.3. The SDK examples and a number of homebrew codes run fine, so I’m pretty mystified that something this simple fails. What am I missing?
Note that this doesn’t happen with -deviceemu turned on. Actually, now that I think about it I should check and see what happens in emulation mode. I’ll do that and check back here later!