Hey all,
I was running into a maddening issue where I was getting what looked like junk memory / stomps, but turned out to be a basic alignment mismatch between structures shared between C and ISPC. I finally tracked this down to multiple targets breaking the header generation:
So if I have a ISPC header that does a trivial short vector define:
// Types.ispc
typedef float<4> MyVector;
export PrintTypes()
{
print("MyVector Size %", sizeof(uniform MyVector));
}
////////////////////////////////
And compile that with multiple targets:
ispc Types.ispc -o "Types_ispc.obj" -h "Types_ispc.h" --target=sse4,avx2
You'll see the header that will use 16 byte alignment (corresponding to SSE4), yet when you call "PrintTypes" it'll print 32 as the compiler choose AVX2 under the hood (but seemingly after the header generation). Removing the SSE4 target (or moving AVX2 to the first target) fixes the issue.
Perhaps modifying the header file to support all the provided targets and just use common preprocessor defines? (__SSE4_1__, __AVX2___, etc) so that the final output matches?
Cheers,
- Matt