Kernel doesn't return correct values but in emulation mode it does

Just use [font=“Courier New”]cudaMalloc((void **)&(structure.int), N*sizeof(int))[/font] as normal. cudaMalloc() does not dereference the pointer passed to it, and actually can only be called in host code.

Question for you : are you debugging in emulation mode using SKD 2.3?

Thanks to all for response. :)

I’ve debugging with SDK 3.0 on a Linux x64 machine.

Now the situation is the following:

[Before changing in code]:

  • Emulation Mode: Correct
  • Normal Mode: Incorrect

[After changing in code suggested by SPWorley]:

  • Emulation Mode: Incorrect
  • Normal Mode: Incorrect

In both emulation and normal mode results are the same and are more correct than before changing in code; in particular, I’ve an output of about 240000 numbers and only the first three are correct, the rest is wrong.

Since emulation is incorrect, this means your math logic may have accidentally changed, or more likely, your array indexing, perhaps from flattening your 2D arrays into 1D.

You can use valgrind on emulator runs, and Ocelot or cudaMemcheck on GPU code to help find memory access errors.

Finally, I did it!!! External Image

Thanks SPWorley, you was right. The indexing of E_b (the array flattened) was wrong. Now it works perfectly and gives me correct results.

Thanks to all. ;)