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 test.cl -o test_amd.bc

test.cl:3:11: 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?

Frank

Hi Frank,

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

https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#work-item-functions

Cheers,
Anastasia