[cfe-dev] Compile OpenCL2.x kernel which declares “Other Data Types” with global address space in program scope

Anastasia Stulova via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 8 04:08:26 PST 2021


Hi CY,

that's right, there is a patch for this in review:
https://reviews.llvm.org/D112110

You can also file a bugzilla bug if you like, but it might be quicker to just finalize the review.

Cheers,
Anastasia


________________________________
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> on behalf of Chuang-Yu Cheng via cfe-dev <cfe-dev at lists.llvm.org>
Sent: 13 October 2021 08:44
To: cfe-dev at lists.llvm.org <cfe-dev at lists.llvm.org>
Subject: [cfe-dev] Compile OpenCL2.x kernel which declares “Other Data Types” with global address space in program scope

Hi,

In OpenCL2.x, I think it is not legal to declare/define “Other Data
Types” (The OpenCL™ C 2.0 Specification) ndrange_t / queue_t / … etc,
with global address space in program scope, for example:

test.cl
```c
global ndrange_t nrt;
global queue_t qt;

kernel void test(global int *a) { a[0] = 0; }
```

Given the OpenCL2.x spec states:
https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_C.html

In 6.5.1. __global (or global):
“Variables defined at program scope and static variables inside a
function can also be declared in the global address space. They can be
defined with any valid OpenCL C data type except for those in Other
Built-in Data Types. In particular, such program scope variables may
be of any user-defined type, or a pointer to a user-defined type.”

But I use clang-13 to compile the test case, it passes without any
warning or error:

clang-13 --target=amdgcn -cl-std=CL2.0 -S -O3 test.cl

Should we add more checks in:
https://clang.llvm.org/doxygen/SemaDecl_8cpp_source.html#l06825

/// Returns true if there hasn't been any invalid type diagnosed.
static bool diagnoseOpenCLTypes(Sema &Se, VarDecl *NewVD)

Thanks,
CY
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20211108/6b064bd7/attachment.html>


More information about the cfe-dev mailing list