Is it legal to pass a struct containing a global pointer into a kernel?

The following code uses a struct, passed into the kernel, containing a global pointer. The pointer however is not used inside the kernel until initialized to point to the floats0 global float * array. Is there anything in the OpenCL 1.2 spec that says this is/isnt legal?


struct Eigen__TensorEvaluator {
    global float* f0;
    float f1;
};

kernel void foo(global struct Eigen__TensorEvaluator* pstruct, global float* floats0) {
    pstruct[0].f0 = floats0;
    pstruct[0].f0[0] = pstruct[0].f1;
}

Pretty sure it is illegal. If you can’t use SVM from 2.0, simply store your element’s position as an int.

Seems legal to me as long as you’re not trying to pass a host pointer in there. If you initialize the value and use the value only on the device side, seems completely legit.

The thing is, pointers are not guaranteed to remain consistent on a GPU between kernel runs. It can be valid for some particular architecture, but using an undefined behavior is always iffy.