diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def --- a/clang/include/clang/Basic/OpenCLExtensions.def +++ b/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) diff --git a/clang/lib/Headers/opencl-c-base.h b/clang/lib/Headers/opencl-c-base.h --- a/clang/lib/Headers/opencl-c-base.h +++ b/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 diff --git a/clang/test/SemaOpenCL/atomic-ops.cl b/clang/test/SemaOpenCL/atomic-ops.cl --- a/clang/test/SemaOpenCL/atomic-ops.cl +++ b/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}}