Internal OpenCL error (Compilation failure ! (code = -42))


While trying to build my OpenCL program I am getting what I think is an internal error in OpenCL.

The error is: Compilation failure ! (code = -42)

ptxas ptx input, line 50; error : State space mismatch between instruction and address in instruction ‘ld’

My example code is:


__global int * mReferences;

__kernel void entry(__global int * references){

int loop_control = 0;

int handle = references[loop_control];

references[loop_control] = mReferences[handle];



Is there something I am doing wrong with this?

P.S. I know mReferences is unassigned to and this will give me a runtime error, but I get this compiler

error for more complicated examples that (hopefully) won’t have runtime errors.

I’m not sure that you can declare a __global in the program scope (the mReferences variable). IIRC only __constant can be declared this way, and it has to be initialized.

pcchen is correct, page 150 of the specs says:

And on the next page:

This is actually a good thing IMO - analysing dependencies in code with mutable file-scope variables is a pain.

The error message could be better though.

Thanks, that helped a lot.