I’ve been having some issues using the division operator “/” within my CUDA kernel, and I couldn’t find another post discussing the issue. Basically, the problem is that using the operator within any line of code within my kernel will cause the kernel to be terminated at that line when run. This behavior only popped up after switching from CUDA runtime 3.2 with VS 2008 to CUDA runtime 4.0 with VS 2010.
Am I doing something wrong? Here are a couple examples of lines that will cause the kernel to terminate.
int variable = (double) array[number] / number;
or
cos(number * number / number)
I actually have yet to try using the division operator within strictly integer operations, as these two are within double operations. So ill try that and see if that works, but if it does, then what operator do I use for division for double operations.
Thanks for the quick reply. No, its not a divide by zero issue. The first line uses a constant 32767, and the second line never has a zero in the denominator either. As for the valid index, that’s also not the issue as I’ve tried both lines separately and they both fail by themselves.
Also, I’ve tried what I was talking about at the end of my first post. And it looks like that it blows up when I try to use the division operator in the middle of some double operations.
For example,
This works:
double fun = fun1 / fun2; (where both fun1 and fun2 are integers, fun1 and fun2 are 1 and 2 respectively, result of this is 0)
while this doesnt:
double fun = (double) fun1 / fun2; (result of this should be .5)
Also within the cos operation there is no explicit double cast, so it just looks like it blows up when I try to use the division operator in the midst of double operations.
double fun = (double) (fun1/fun2) would result in zero in that case, which is not what I want. I will try double casting both of them, but again, this problem occurs within the cosine operation as well where there is no double cast.
As for my CC, its 2.0, I have a gtx580, and I’ve also set compute_20 and sm_20. I had this code working perfectly in 3.2, well not perfectly, it was blowing up this mod operation within the double operations, so I had to separate the mod operation and save it to a variable, but other than that, I had no issues in 3.2.