OpenCL: get_global_linear_id() not supported?

The follwing kernel doesn’t compile with Clang (current upstream):

__kernel void test()
int i = get_global_linear_id();

clang -emit-llvm -target amdgcn-amd-amdhsa -mcpu=gfx908 -Xclang -finclude-default-header -c -o test_amd.bc error: implicit declaration of function ‘get_global_linear_id’ is invalid in OpenCL
int i = get_global_linear_id();
1 error generated.

Per Khronos OpenCL 2.0 specification this function is part of the standard.

What am I missing here?


Hi Frank,

By default clang compiles using OpenCL version 1.0, so you would need to add ‘-cl-std=CL2.0’ flag ( as get_global_linear_id() is a function from OpenCL 2.0 onwards: