diff --git a/opencl-aot/CMakeLists.txt b/opencl-aot/CMakeLists.txt index da9dd662c0499..d5cdac0ebb9ef 100644 --- a/opencl-aot/CMakeLists.txt +++ b/opencl-aot/CMakeLists.txt @@ -25,6 +25,7 @@ if (NOT OpenCL_INCLUDE_DIRS) STEP_TARGETS build COMMENT "Downloading OpenCL headers." ) + add_definitions(-DCL_TARGET_OPENCL_VERSION=220) else () add_custom_target(opencl-headers ALL DEPENDS ${OpenCL_INCLUDE_DIRS} diff --git a/opencl-aot/source/utils.cpp b/opencl-aot/source/utils.cpp index fb1fdd2bde70c..1a0a732e319cc 100644 --- a/opencl-aot/source/utils.cpp +++ b/opencl-aot/source/utils.cpp @@ -140,14 +140,18 @@ std::string getOpenCLErrorNameByErrorCode(cl_int CLErr) { return "CL_INVALID_LINKER_OPTIONS"; case CL_INVALID_DEVICE_PARTITION_COUNT: return "CL_INVALID_DEVICE_PARTITION_COUNT"; +#ifdef CL_VERSION_2_0 case CL_INVALID_PIPE_SIZE: return "CL_INVALID_PIPE_SIZE"; case CL_INVALID_DEVICE_QUEUE: return "CL_INVALID_DEVICE_QUEUE"; +#endif +#ifdef CL_VERSION_2_2 case CL_INVALID_SPEC_ID: return "CL_INVALID_SPEC_ID"; case CL_MAX_SIZE_RESTRICTION_EXCEEDED: return "CL_MAX_SIZE_RESTRICTION_EXCEEDED"; +#endif default: return "Unknown error code"; } diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index f729374168d5e..d073c5a70cc94 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -82,6 +82,7 @@ if( NOT OpenCL_INCLUDE_DIRS ) STEP_TARGETS build COMMENT "Downloading OpenCL headers." ) + add_definitions(-DCL_TARGET_OPENCL_VERSION=220) else() add_custom_target( ocl-headers ALL DEPENDS ${OpenCL_INCLUDE_DIRS} diff --git a/sycl/include/CL/sycl/backend/opencl.hpp b/sycl/include/CL/sycl/backend/opencl.hpp index efd0f7df8a365..881ef69fbb1dd 100644 --- a/sycl/include/CL/sycl/backend/opencl.hpp +++ b/sycl/include/CL/sycl/backend/opencl.hpp @@ -9,9 +9,9 @@ #pragma once -#include #include #include +#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { diff --git a/sycl/include/CL/sycl/detail/aligned_allocator.hpp b/sycl/include/CL/sycl/detail/aligned_allocator.hpp index 1563d829d2753..e4fe03328d6e8 100644 --- a/sycl/include/CL/sycl/detail/aligned_allocator.hpp +++ b/sycl/include/CL/sycl/detail/aligned_allocator.hpp @@ -8,7 +8,6 @@ #pragma once -#include #include #include #include diff --git a/sycl/include/CL/sycl/detail/buffer_impl.hpp b/sycl/include/CL/sycl/detail/buffer_impl.hpp index b1561928218e5..a39fcdb7ed65a 100644 --- a/sycl/include/CL/sycl/detail/buffer_impl.hpp +++ b/sycl/include/CL/sycl/detail/buffer_impl.hpp @@ -8,7 +8,6 @@ #pragma once -#include #include #include #include diff --git a/sycl/include/CL/sycl/detail/cl.h b/sycl/include/CL/sycl/detail/cl.h new file mode 100644 index 0000000000000..7e90fe126e40d --- /dev/null +++ b/sycl/include/CL/sycl/detail/cl.h @@ -0,0 +1,18 @@ +//==---------------- cl.h - Include OpenCL headers -------------------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#pragma once + +// Suppress a compiler message about undefined CL_TARGET_OPENCL_VERSION +// and define all symbols up to OpenCL 2.2 +#ifndef CL_TARGET_OPENCL_VERSION +#define CL_TARGET_OPENCL_VERSION 220 +#endif + +#include +#include diff --git a/sycl/include/CL/sycl/detail/common.hpp b/sycl/include/CL/sycl/detail/common.hpp index b1310a103c0c9..fb15403d30208 100644 --- a/sycl/include/CL/sycl/detail/common.hpp +++ b/sycl/include/CL/sycl/detail/common.hpp @@ -8,16 +8,11 @@ #pragma once +#include +#include #include #include -// Suppress a compiler warning about undefined CL_TARGET_OPENCL_VERSION -// Khronos ICD supports only latest OpenCL version -#define CL_TARGET_OPENCL_VERSION 220 -#include -#include -#include - #include #include #include diff --git a/sycl/include/CL/sycl/detail/memory_manager.hpp b/sycl/include/CL/sycl/detail/memory_manager.hpp index d07010d9ed8c2..366edf4093e8c 100644 --- a/sycl/include/CL/sycl/detail/memory_manager.hpp +++ b/sycl/include/CL/sycl/detail/memory_manager.hpp @@ -8,8 +8,8 @@ #pragma once -#include #include +#include #include #include #include diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 49e569077f9fd..f44b74292b664 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -45,9 +45,9 @@ // TODO: we need a mapping of PI to OpenCL somewhere, and this can be done // elsewhere, e.g. in the pi_opencl, but constants/enums mapping is now // done here, for efficiency and simplicity. -// + #include -#include +#include #include #ifdef __cplusplus diff --git a/sycl/include/CL/sycl/detail/usm_impl.hpp b/sycl/include/CL/sycl/detail/usm_impl.hpp index 47ae9447bb4ec..1276d5ced8be4 100644 --- a/sycl/include/CL/sycl/detail/usm_impl.hpp +++ b/sycl/include/CL/sycl/detail/usm_impl.hpp @@ -7,8 +7,8 @@ // ===--------------------------------------------------------------------=== // #pragma once -#include #include +#include #include #include diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 733322fe0f577..67e0e98935543 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -14,7 +14,7 @@ /// /// \ingroup sycl_pi_ocl -#include "CL/opencl.h" +#include #include #include diff --git a/sycl/source/detail/common.cpp b/sycl/source/detail/common.cpp index c1a9be853d8cc..fb4ed5b5c1846 100644 --- a/sycl/source/detail/common.cpp +++ b/sycl/source/detail/common.cpp @@ -160,14 +160,18 @@ const char *stringifyErrorCode(cl_int error) { return "CL_INVALID_LINKER_OPTIONS"; case CL_INVALID_DEVICE_PARTITION_COUNT: return "CL_INVALID_DEVICE_PARTITION_COUNT"; +#ifdef CL_VERSION_2_0 case CL_INVALID_PIPE_SIZE: return "CL_INVALID_PIPE_SIZE"; case CL_INVALID_DEVICE_QUEUE: return "CL_INVALID_DEVICE_QUEUE"; +#endif +#ifdef CL_VERSION_2_2 case CL_INVALID_SPEC_ID: return "CL_INVALID_SPEC_ID"; case CL_MAX_SIZE_RESTRICTION_EXCEEDED: return "CL_MAX_SIZE_RESTRICTION_EXCEEDED"; +#endif /* case CL_BUILD_NONE: return "CL_BUILD_NONE"; diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 0f4534cdc6813..538d5e1549eb5 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -9,8 +9,8 @@ #include #include "CL/sycl/access/access.hpp" -#include #include +#include #include #include #include diff --git a/sycl/tools/get_device_count_by_type.cpp b/sycl/tools/get_device_count_by_type.cpp index 31d741950730b..1cfec312e8883 100644 --- a/sycl/tools/get_device_count_by_type.cpp +++ b/sycl/tools/get_device_count_by_type.cpp @@ -6,6 +6,12 @@ // //===----------------------------------------------------------------------===// +// Suppress a compiler warning about undefined CL_TARGET_OPENCL_VERSION +// and define all symbols up to OpenCL 2.2 +#ifndef CL_TARGET_OPENCL_VERSION +#define CL_TARGET_OPENCL_VERSION 220 +#endif + #include #include diff --git a/sycl/unittests/scheduler/SchedulerTestUtils.hpp b/sycl/unittests/scheduler/SchedulerTestUtils.hpp index 7952edcc4155f..7cfbd995bb7c8 100644 --- a/sycl/unittests/scheduler/SchedulerTestUtils.hpp +++ b/sycl/unittests/scheduler/SchedulerTestUtils.hpp @@ -7,8 +7,8 @@ //===----------------------------------------------------------------------===// #pragma once -#include #include +#include #include #include