In a couple of places, I’ve found that an exception:
exception: cudaError_enum at memory location 0x03a4ebdc…
is thrown when I divide by an int cast to a float:
float fh = 5.0 / (float) nimg_height; // throws the above exception in a kernel, nimg_height = 1000
but
float fh = 5.0 / 1000.0; // does not throw exception
I’ve seen this in two different places so far.
The function in one case is declared:
global void
cuDisplayHiddenOut3D(float4 *pos,
int nimg_width,
int nimg_height,
int ndisplay)
Am I doing something wrong?
ETA: the following also throws the same exception
float fheight = (float) nimg_height;
float fh = 5.0 / fheight;
ETA2: also
float fheight = 1000.0;
float fh = 5.0 / fheight;
throws the exception, but
float fh = 5.0 / (float) 1000;
does not.
ETA3: In case it’s important, I’m using CUDA 5.0 on a Dell XPS 15z 525M with Optimus and writing to a VBO with CUDA/OpenGL interoperability.
In another kernel function called by the above function, declared as:
host device void
floatTo3DVector(DATA_FLOAT dfval,
float4 *puc4out,
int pos_offs,
int nbuff_offs,
int nimg_width,
int nimg_height)
I get:
First-chance exception at 0x769eb9bc in AppName.exe: Microsoft C++
exception: cudaError_enum at memory location 0x0439eb14…
when I substitute:
float fheight = 1.0 / (float) nimg_height; // nimg_height = 1000
for
float fheight = .001;
Doesn’t anyone at Nvidia have any idea why dividing causes an exception?
Divide by int seems to work fine.
Since no one else has replied…
- Can you reproduce this behavior on a very simple standalone kernel?
1a) If not, trying to isolate the specific conditions it’s happening – helpful to report a reproducible bug.
If you can get to reproduce a simple case:
- Does it happen under CUDA 4.2?
- File bug with gathered information.
If it’s actually not a bug, chances are by the time you’re done with this procedure that you’ve figured out what the issue is :)
Thanks for responding vacaloca.
Apparently the exception is thrown cause I was passing an unsigned int to the function where an int was specifiied. :facepalm:
The compiler did not complain, but casting to float and dividing throws an exception.
It would be nice if the compiler checks for things which are important.