OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1663 Discussions

Compiler incorrectly accepts initialized local variables

Philippe
Beginner
206 Views
When compiling the following snippet the offline compiler does not complain:
[cpp]__kernel void T6_f_15_355 () {
    __local   int x   = 5 ;
  x = 0;
  return;
}[/cpp]
According to the OpenCL 1.1 spec (6.5.2), a local variable cannot be initialized.

The AMD compiler emits an error:
[plain]Line 2: error: variable "x"
          may not be initialized
      __local   int x =1  ;
                    ^

1 error detected.
[/plain]
Moreover, local variables should only be defined at kernel function scope. The following code should thus also be rejected:
[cpp]__kernel void T6_f_15_355 (int x) {
   if(x < 3) {
      __local int y  ;
      y = 0;
   }
}[/cpp]
But all OpenCL compilers seem to accept it without complaining.
0 Kudos
1 Reply
Guy_B_Intel
Employee
206 Views
Hello Phillippe,
Thanks for your post, I'll open a bug report on this issue, and we'll add these restrictions to one of our future versions.

Thanks
Guy Benyei
Reply