Skip to content

Commit 21f7af2

Browse files
kpetmemfrob
authored andcommitted
[OpenCL] Fix parsing of opencl-c.h in CL 3.0
Ensure that the cl_khr_3d_image_writes pragma is enabled by making cl_khr_3d_image_writes an optional core feature in CL 3.0 in addition to being an available extension in 1.0 onwards and a core feature in CL 2.0. https://reviews.llvm.org/D99425 Signed-off-by: Kevin Petit <[email protected]>
1 parent a4e0062 commit 21f7af2

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

clang/include/clang/Basic/OpenCLExtensions.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ OPENCL_OPTIONALCOREFEATURE(cl_khr_fp64, true, 100, OCL_C_12P)
6868
OPENCL_EXTENSION(cl_khr_fp16, true, 100)
6969
OPENCL_EXTENSION(cl_khr_int64_base_atomics, true, 100)
7070
OPENCL_EXTENSION(cl_khr_int64_extended_atomics, true, 100)
71-
OPENCL_COREFEATURE(cl_khr_3d_image_writes, true, 100, OCL_C_20)
71+
OPENCL_GENERIC_EXTENSION(cl_khr_3d_image_writes, true, 100, OCL_C_20, OCL_C_30)
7272

7373
// EMBEDDED_PROFILE
7474
OPENCL_EXTENSION(cles_khr_int64, true, 110)

clang/test/Headers/opencl-c-header.cl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 | FileCheck %s
33
// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 | FileCheck %s
44
// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=clc++ | FileCheck %s --check-prefix=CHECK20
5+
// RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL3.0 | FileCheck %s
56

67
// Test including the default header as a module.
78
// The module should be compiled only once and loaded from cache afterwards.
@@ -81,7 +82,7 @@ void test_atomics(__generic volatile unsigned int* a) {
8182
#endif
8283

8384
// Verify that ATOMIC_VAR_INIT is defined.
84-
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
85+
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0)
8586
global atomic_int z = ATOMIC_VAR_INIT(99);
8687
#endif //__OPENCL_C_VERSION__
8788
// CHECK-MOD: Reading modules

clang/test/SemaOpenCL/extension-version.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@
9393
// expected-warning@-2{{OpenCL extension 'cl_khr_fp64' is core feature or supported optional core feature - ignoring}}
9494
#endif
9595

96-
//Core feature in CL 2.0
96+
//Core feature in CL 2.0, optional core feature in CL 3.0
9797
#ifndef cl_khr_3d_image_writes
9898
#error "Missing cl_khr_3d_image_writes define"
9999
#endif
100100
#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
101-
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) && defined TEST_CORE_FEATURES
101+
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200 || __OPENCL_C_VERSION__ == 300) && defined TEST_CORE_FEATURES
102102
// expected-warning@-2{{OpenCL extension 'cl_khr_3d_image_writes' is core feature or supported optional core feature - ignoring}}
103103
#endif
104104

0 commit comments

Comments
 (0)