Here is an example that demonstrates the issue:

--
test.ispc
--
struct Vec3f {
    float x;
    float y;
    float z;
};

typedef unsigned int8 uint8_t;

export void
run(varying intptr_t * uniform ptrs, uniform int * uniform offsets)
{
    varying intptr_t vptr = *ptrs;
    uniform uint8_t * varying ptr = (uniform uint8_t * varying) vptr;

    varying int iterations = programIndex * 16; // max of 256
    for (varying int i1 = 0; i1 < iterations; ++i1) {
        // note that lane 0 should be inactive since !(0 < 0)
        varying int i0 = (i1 == 0)? iterations - 1 : i1 - 1;

        print("i0 = %\n", i0);
        print("i1 = %\n", i1);
        const varying Vec3f v0 = *((uniform Vec3f * varying)(ptr + 
offsets[i0]));
        const varying Vec3f v1 = *((uniform Vec3f * varying)(ptr + 
offsets[i1]));

        print("v0.x = %\n", v0.x);
        print("v1.x = %\n", v1.x);
    }
}
// ispc -O3 --target=avx1-i32x8 test.ispc  -o test_ispc.o -h test_ispc.h

--
test.cc
--
#include "test_ispc.h"

#include <iostream>

struct Vec3f {
    float x;
    float y;
    float z;
};

int
main(int argc, char *argv[])
{
    const int NUM_VEC3F  = 256;
    const int NUM_LANES  = 8;

    // setup 8 lanes of Vec3f[256]
    intptr_t ptrs[NUM_LANES] = { 0, 0, 0, 0, 0, 0, 0, 0 };
    char *data = new char[NUM_VEC3F * sizeof(Vec3f)];
    Vec3f *vdata = (Vec3f *) data;
    for (int i = 0; i < 256; ++i) {
        vdata[i].x = vdata[i].y = vdata[i].z = float(i);
    }
    ptrs[1] = ptrs[3] = ptrs[5] = ptrs[7] = (intptr_t) data;
    ptrs[0] = ptrs[2] = ptrs[4] = ptrs[6] = (intptr_t) data;

    // offset into each array for item i
    int offsets[NUM_VEC3F];
    for (int i = 0; i < 256; ++i) {
        offsets[i] = i * sizeof(Vec3f);
    }

    ispc::run(&ptrs, offsets);

    delete [] data;
}
// c++ -std=c++11 test.cc test_ispc.0


When compiled with -00 or any prior version of ispc, the program completes 
without error.  With 1.9.2 -O3 I get:

i0 = [((-1)),15,31,47,63,79,95,111]
i1 = [((0)),0,0,0,0,0,0,0]
Segmentation fault (core dumped)

In the debugger, the crash points to the assignment line for v1.

Has anyone seen something similar with 1.9.2?

-Brian

On Thursday, February 8, 2018 at 3:50:16 PM UTC-8, Brian Green wrote:
>
>
> The above code will not demonstrate the problem, so don't spend any cycles 
> staring at it.  Sorry.
>
> I'll need to produce a new example...
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Intel SPMD Program Compiler Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ispc-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to