I ran into a weird problem. In my little cuda code, I have several kernels. It can be completely compiled. When I run the program, I found out that one of the kernel either not run or does not run correctly ( I can see that from the return values). Even more weird is that it runs correctly without changing anything. In this kernel I passed a structure pointer in the kernel argument. This structure has both integer and float members. I was wondering that that may be the reason of the problem. Any body has experienced the same problem. I mean you realize some kernel do not run while others may run correctly. Any suggestion is appreciated.
Did you try calling CUT_CHECK_ERROR to see what it says?
Syntax:
cuCreateParticles<<<dimGrid, dimBlock>>>(positions);
CUT_CHECK_ERROR("Kernel execution failed");
I did not use that. I did not use toolkit in my ubuntu laptop. But thanks for your suggestion. I can try that.
BTW, the weird thing is it runs correct some time and sometime not.
My structure is like
typedef struct {
float ro[3];
float d[3];
float t;
int index;
} ray;
And I pass the ray* pointer in the kernel argument.
Which memory (host or device) space is your struct pointer allocated? Please paste the code how you declare/define/init/use the struct. Otherwise it’s difficult to help.
(I suspect that you forgot to cudaMemcpy your struct to device.)
One issue with structures that one can easily run into is different padding on the host side and the device side.
The best way of avoiding this (in my experience) is to always lay out the structures so that elements are naturally aligned and don’t need any padding.