jrprice / Oclgrind

An OpenCL device simulator and debugger
Other
346 stars 63 forks source link

"Unsupported constant int size: 5 bytes" #204

Open athas opened 2 years ago

athas commented 2 years ago

I'm getting this error on Oclgrind 21.10 with rather simple kernels, e.g. this one:

__kernel void mainzisegred_nonseg_6074(int n_6034, int num_threads_6087, __global int *segred_tmp_mem_6085)
{
    int global_tid_6088 = get_global_id(0);
    int x_acc_6097 = 0;
    for (int i_6102 = 0; i_6102 < n_6034; i_6102++) {
      x_acc_6097 = x_acc_6097 + get_global_id(0) + num_threads_6087 * i_6102;
    }
    segred_tmp_mem_6085[0] = x_acc_6097;
}

This is a contrived kernel derived from a much larger example. Interestingly, the original kernel triggered a complaint about the constant being 9 bytes.

I'm not sure whether this is a compatibility problem with the wrong version of LLVM. It happens with the Oclgrind packaged in Ubuntu 21.04, but I am not sure which LLVM it is linked against.

athas commented 2 years ago

Through bisection I have confirmed that 16a4f20981a94ec6d65d2d5620d338d473947788 is the commit that introduces this bug.

athas commented 2 years ago

As a workaround, I can pass -O1 as an OpenCL build option. It seems to only be -Oz that produces these interesting constants.