svenvh created this revision. svenvh added reviewers: Anastasia, azabaznov. svenvh added a project: clang. Herald added subscribers: ldrumm, jfb, yaxunl. svenvh requested review of this revision. Herald added a subscriber: cfe-commits.
Add the `memory_scope_all_devices` enum value, which is restricted to OpenCL 3.0 or newer and the `__opencl_c_atomic_scope_all_devices` feature. Also guard `memory_scope_all_svm_devices` accordingly, which is already available in OpenCL 2.0. This patch only adds a negative test for now. Ideally adding a CL3.0 run line to `atomic-ops.cl` should suffice as a positive test, but we cannot do that yet until (at least) generic address spaces and program scope variables are supported in OpenCL 3.0 mode. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D103241 Files: clang/include/clang/Basic/OpenCLExtensions.def clang/lib/Headers/opencl-c-base.h clang/test/SemaOpenCL/atomic-ops.cl Index: clang/test/SemaOpenCL/atomic-ops.cl =================================================================== --- clang/test/SemaOpenCL/atomic-ops.cl +++ clang/test/SemaOpenCL/atomic-ops.cl @@ -2,6 +2,7 @@ // RUN: -fsyntax-only -triple=spir64 -fdeclare-opencl-builtins -finclude-default-header // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \ // RUN: -triple=amdgcn-amd-amdhsa -fdeclare-opencl-builtins -finclude-default-header +// TODO: add -cl-std=CL3.0 line when generic and psv are supported. // Basic parsing/Sema tests for __opencl_atomic_* @@ -161,6 +162,11 @@ (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_work_group); (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_device); (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_all_svm_devices); + (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_all_devices); +#if __OPENCL_C_VERSION__ < CL_VERSION_3_0 + // expected-error@-2{{use of undeclared identifier 'memory_scope_all_devices'}} + // expected-note@* {{'memory_scope_all_svm_devices' declared here}} +#endif (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_sub_group); (void)__opencl_atomic_load(Ap, memory_order_relaxed, scope); (void)__opencl_atomic_load(Ap, memory_order_relaxed, 10); //expected-error{{synchronization scope argument to atomic operation is invalid}} Index: clang/lib/Headers/opencl-c-base.h =================================================================== --- clang/lib/Headers/opencl-c-base.h +++ clang/lib/Headers/opencl-c-base.h @@ -312,7 +312,12 @@ memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM, memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP, memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE, +#if defined(__opencl_c_atomic_scope_all_devices) memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES, +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0) + memory_scope_all_devices = memory_scope_all_svm_devices, +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0 +#endif // defined(__opencl_c_atomic_scope_all_devices) #if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP #endif Index: clang/include/clang/Basic/OpenCLExtensions.def =================================================================== --- clang/include/clang/Basic/OpenCLExtensions.def +++ clang/include/clang/Basic/OpenCLExtensions.def @@ -110,6 +110,7 @@ OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_all_devices, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_3d_image_writes, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 300, OCL_C_30)
Index: clang/test/SemaOpenCL/atomic-ops.cl =================================================================== --- clang/test/SemaOpenCL/atomic-ops.cl +++ clang/test/SemaOpenCL/atomic-ops.cl @@ -2,6 +2,7 @@ // RUN: -fsyntax-only -triple=spir64 -fdeclare-opencl-builtins -finclude-default-header // RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \ // RUN: -triple=amdgcn-amd-amdhsa -fdeclare-opencl-builtins -finclude-default-header +// TODO: add -cl-std=CL3.0 line when generic and psv are supported. // Basic parsing/Sema tests for __opencl_atomic_* @@ -161,6 +162,11 @@ (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_work_group); (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_device); (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_all_svm_devices); + (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_all_devices); +#if __OPENCL_C_VERSION__ < CL_VERSION_3_0 + // expected-error@-2{{use of undeclared identifier 'memory_scope_all_devices'}} + // expected-note@* {{'memory_scope_all_svm_devices' declared here}} +#endif (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_sub_group); (void)__opencl_atomic_load(Ap, memory_order_relaxed, scope); (void)__opencl_atomic_load(Ap, memory_order_relaxed, 10); //expected-error{{synchronization scope argument to atomic operation is invalid}} Index: clang/lib/Headers/opencl-c-base.h =================================================================== --- clang/lib/Headers/opencl-c-base.h +++ clang/lib/Headers/opencl-c-base.h @@ -312,7 +312,12 @@ memory_scope_work_item = __OPENCL_MEMORY_SCOPE_WORK_ITEM, memory_scope_work_group = __OPENCL_MEMORY_SCOPE_WORK_GROUP, memory_scope_device = __OPENCL_MEMORY_SCOPE_DEVICE, +#if defined(__opencl_c_atomic_scope_all_devices) memory_scope_all_svm_devices = __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES, +#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0) + memory_scope_all_devices = memory_scope_all_svm_devices, +#endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0 +#endif // defined(__opencl_c_atomic_scope_all_devices) #if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP #endif Index: clang/include/clang/Basic/OpenCLExtensions.def =================================================================== --- clang/include/clang/Basic/OpenCLExtensions.def +++ clang/include/clang/Basic/OpenCLExtensions.def @@ -110,6 +110,7 @@ OPENCL_OPTIONALCOREFEATURE(__opencl_c_generic_address_space, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_acq_rel, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_order_seq_cst, false, 300, OCL_C_30) +OPENCL_OPTIONALCOREFEATURE(__opencl_c_atomic_scope_all_devices, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_subgroups, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_3d_image_writes, false, 300, OCL_C_30) OPENCL_OPTIONALCOREFEATURE(__opencl_c_device_enqueue, false, 300, OCL_C_30)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits