Hello. I am implementing some spline algorithms using Cuda, and have run into a rather annoying problem. The offending function is appended at the bottom. The symptom is the dreaded “unspecified launch failure”, even with block sizes as small as 1x1. Also, this application is running at 60FPS, so it is not the 5 second timeout :-)

Now on to discussion of the problem. As can be seen from the function signature. I am passing an int k by reference. However, I am resetting k for every loop iteration as I am only interested in its final value outside of this function. In outer words, is the equivalent of a GLSL ‘out’ variable. The offending line by the way is the x = t[k+1] statement inside an if-test.

If I however stop passing k by reference (by removing the ‘&’), the function happily runs along and produce the correct x-value. Of course I do not get the ‘k’ value.

Anyone who can shed some light on what is going on here?

```
//-----------------------------------------------------------------------------
__device__
float findMinAbsVal( float* t, float* c, int& n,
const float eps, const int maxn, float cutoff, const unsigned int d, int& k)
//-----------------------------------------------------------------------------
{
float x = NO_ROOT;
for (; n<maxn; ++n ) {
k = 0;
float minval = fabs(c[0]);
for ( int i=0; i<n; ++i) {
if (fabs(c[i])<minval){
minval = fabs(c[i]);
k=i;
}
}
if (minval>cutoff) {
x = NO_ROOT;
break;
}
float diff = t[k+d]-t[k+1];
if (diff<eps) {
x = t[k+1];
break;
}
float dck = delta(t,c,k,d);
float dckp = delta(t,c,k+1,d);
float beta = dckp/(dckp-dck);
x = (knotSum(d-1,t,k+1) - beta*diff)/(d-1.0);
float e = max(x,t[k+d-1])-min(x,t[k+2]);
if (e<eps) {
break;
}
// otherwise, insert x
insertKnot(x,k,t,c,n,d);
}
return x;
}
```