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.
1719 Discussions

Compiling OpenCL 2.0 atomics

Tyler_S_2
Beginner
1,310 Views

Hi,

I am trying to compile a simple kernel using OpenCL 2.0 atomics using exactly the device, driver, and kernel described in:

https://software.intel.com/en-us/forums/topic/556904

However, I cannot even get the kernel to compile, as it does not seem to recognize the atomic types and functions. My error log (along with some environment info) is:


  -- device info --
DEVICE_NAME:                Intel(R) HD Graphics 5500
DEVICE_VENDOR:              Intel(R) Corporation
DEVICE_VERSION:             OpenCL 2.0 
DRIVER_VERSION:             10.18.14.4029

:6:62: error: unknown type name 'atomic_int'
kernel void atomics_test(global int *output, volatile global atomic_int*  atomicBuffer, uint iterations, uint offset)
                                                             ^
:10:9: error: implicit declaration of function 'atomic_fetch_add_explicit' is invalid in OpenCL
        atomic_fetch_add_explicit(&atomicBuffer[0], MY_ADD_VALUE, memory_order_relaxed, memory_scope_device);
        ^

error: front end compiler failed build.

Am I missing an include or an extension to enable? I tried searching through the docs but couldn't find anything. For example, the Atomic Function page doesn't seem to describe any includes or extensions to use 'atomic_int':

https://www.khronos.org/registry/cl/sdk/2.0/docs/man/xhtml/atomicFunctions.html

Thanks a lot in advance!

0 Kudos
1 Solution
Robert_I_Intel
Employee
1,310 Views

Did you provide the Build flag   -cl-std=CL2.0  ?

View solution in original post

0 Kudos
2 Replies
Robert_I_Intel
Employee
1,311 Views

Did you provide the Build flag   -cl-std=CL2.0  ?

0 Kudos
Tyler_S_2
Beginner
1,310 Views

Thanks for the fast reply Robert! That did it.

I was looking at the clBuildProgram docs for OpenCL 1.x which doesn't include this option. Of course, when I look at clBuildProgram doc for 2.0, this option is documented.

Thanks again!

0 Kudos
Reply