[cfe-dev] OpenCL: get_global_linear_id() not supported?

Anastasia Stulova via cfe-dev cfe-dev at lists.llvm.org
Wed May 26 04:40:23 PDT 2021


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

________________________________
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> on behalf of Frank Winter via cfe-dev <cfe-dev at lists.llvm.org>
Sent: 09 May 2021 19:11
To: cfe-dev at lists.llvm.org <cfe-dev at lists.llvm.org>
Subject: [cfe-dev] 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20210526/48b2a28a/attachment-0001.html>


More information about the cfe-dev mailing list