compiler crash

Discussion created by twiig on Nov 7, 2009
Latest reply on Nov 7, 2009 by twiig

After calling clBuildProgram, my program crashes.  I have traced it down to trying to index a write-only global portion of memory with an index that has been involved in a division.  That make sense?

For example, in the attached code, the program will compile successfully if I remove the normalize call.  Furthermore, if I write my own normal function it will still fail.  I have tracked it down to the index variable(s) being involved in any way with a divide.  This only happens when it is compiled for the GPU by the way.

First, I think this must be a compiler bug.  Second, does anyone know how to normalize a vector without using a division?  I tried multiplying the vector by the length calculated using rsqrt to no avail.

__kernel void planar_hough(const int n, __global const float *points, const int NRANGE, __global int *out) { size_t gid = get_global_id(0); float4 v0 = (float4)(points[gid*3+0], points[gid*3+1], points[gid*3+2], 1.0); const int k = 3; int a[3]; for(int i = 0; i < k; i++) a[i] = gid+i; while(true) { float4 v1 = (float4)(points[a[1]*3+0], points[a[1]*3+1], points[a[1]*3+2], 1.0); float4 v2 = (float4)(points[a[2]*3+0], points[a[2]*3+1], points[a[2]*3+2], 1.0); float4 v1_v0 = v1 - v0; float4 v2_v0 = v2 - v0; //distance constraint? float3 norm = normalize(cross(v1_v0, v2_v0)).xyz; out[(int)(norm.x*NRANGE*NRANGE) + (int)(norm.y*NRANGE)]++; ... ...