ispc/ispc — Issue #149: assertion failed in opt.cpp:791
Author: palacaze
Created: 2012-01-06 10:52:35+00:00
State: open

I am trying ISPC out for a data filtering application. Very nice so far.

The following kernel triggers a failed assertion on version 1.1.1 of ISPC for Windows:

export uniform int collectNeighbours(uniform int r, uniform int si, uniform float area,
const uniform float<4> din[],
uniform float<4> dout[])
{
uniform float area2 = area * area;
uniform float<4> pr = din[r];
uniform float xrmin = pr.x - area;
uniform float xrmax = pr.x + area;

uniform int32 imin = r - 1;
uniform int32 imax = r + 1;
while (imin >= 0 && din[imin].x > xrmin) imin--;
while (imax < si && din[imax].x < xrmax) imax++;

uniform int32 num = 0;
int32 one = 1;

foreach (i = imin + 1 ... imax)
{
float<4> pi = din[i];
float dx = pr.x - pi.x;
float dy = pr.y - pi.y;
pi.w = dx * dx + dy * dy;

if (pi.w < area2)
{
int32 pos = atomic_add_global(&num, one);
dout[pos] = pi;
}
}

return num;
}

I get the following:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

opt.cpp:791: Assertion failed: "llvm::isa(insertBase)"
***
*** Please file a bug report at https://github.com/ispc/ispc/issues
*** (Including as much information as you can about how to reproduce this error).
*** You have apparently encountered a bug in the compiler that we'd like to fix!
***

The blame seems to lie on 'atomic_add_global', since replacing 'one' with '1' makes it compile just fine.

I should also warn that I compiled it myself with the mingw compiler. I might supply a patch in a few days if it is of interest to you.

Thank you for your work.