[OpenCL] Define OpenCL 3.0 optional core features in C++ for OpenCL 2021

Modifies OpenCL 3.0 optional core feature macro definitions so that
they are set analogously in C++ for OpenCL 2021.

This change aims to achieve compatibility between C++ for OpenCL
2021 and OpenCL 3.0.

Differential Revision: https://reviews.llvm.org/D108704
This commit is contained in:
Justas Janickas 2021-08-25 15:19:42 +01:00
parent c568985845
commit fb321c2ea2
3 changed files with 15 additions and 7 deletions

View file

@ -30,7 +30,7 @@
#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
// Define feature macros for OpenCL C 2.0
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
#define __opencl_c_pipes 1
#define __opencl_c_generic_address_space 1
#define __opencl_c_work_group_collective_functions 1
@ -45,12 +45,12 @@
#endif
// Define header-only feature macros for OpenCL C 3.0.
#if (__OPENCL_C_VERSION__ == 300)
#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
// For the SPIR target all features are supported.
#if defined(__SPIR__)
#define __opencl_c_atomic_scope_all_devices 1
#endif // defined(__SPIR__)
#endif // (__OPENCL_C_VERSION__ == 300)
#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
// built-in scalar data types:

View file

@ -175,13 +175,13 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
// OpenCL C features.
#if (__OPENCL_C_VERSION__ == 300)
#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
#if __opencl_c_atomic_scope_all_devices != 1
#error "Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices"
#endif
#elif (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
#elif (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
#ifndef __opencl_c_pipes
#error "Feature macro __opencl_c_pipes should be defined"
@ -262,6 +262,6 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
#error "Incorrect feature macro __opencl_c_subgroups define"
#endif
#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200)
#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
#endif // defined(__SPIR__)

View file

@ -6,6 +6,14 @@
// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \
// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=-all \
// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \
// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES
// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 \
// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \
// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES
// For OpenCL C 2.0 feature macros are defined only in header, so test that earlier OpenCL
// versions don't define feature macros accidentally and CL2.0 don't define them without header
@ -15,7 +23,7 @@
// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 \
// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CLC++ \
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \
// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
// Note that __opencl_c_int64 is always defined assuming