From 29c2132cb738ded9a8724e4de1f0acb4e0424b1b Mon Sep 17 00:00:00 2001 From: Denis Demidov Date: Tue, 9 Nov 2021 07:59:54 +0300 Subject: [PATCH] Include CL/opencl.hpp or CL/cl2.hpp, whatever available --- CMakeLists.txt | 12 ++++++++++++ vexcl/backend/opencl.hpp | 6 +++++- vexcl/backend/opencl/compiler.hpp | 6 +++++- vexcl/backend/opencl/context.hpp | 6 +++++- vexcl/backend/opencl/device_vector.hpp | 6 +++++- vexcl/backend/opencl/error.hpp | 6 +++++- vexcl/backend/opencl/event.hpp | 6 +++++- vexcl/backend/opencl/filter.hpp | 6 +++++- vexcl/backend/opencl/image.hpp | 6 +++++- vexcl/backend/opencl/kernel.hpp | 6 +++++- vexcl/backend/opencl/svm_vector.hpp | 6 +++++- 11 files changed, 62 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba3b911d..6d5c9866 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,11 +129,23 @@ find_package(OpenCL) include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/VexCLOpenCLTarget.cmake") if(OpenCL_FOUND) + set(CL_HPP_TARGET_OPENCL_VERSION 120 CACHE STRING "Target OpenCL version") + set(CL_HPP_MINIMUM_OPENCL_VERSION 120 CACHE STRING "Minimum OpenCL version") + add_library(OpenCL INTERFACE) add_library(VexCL::OpenCL ALIAS OpenCL) target_link_libraries(OpenCL INTERFACE Common OpenCL::OpenCL) target_compile_definitions(OpenCL INTERFACE VEXCL_BACKEND_OPENCL) + target_compile_definitions(OpenCL INTERFACE CL_TARGET_OPENCL_VERSION=${CL_HPP_TARGET_OPENCL_VERSION}) + target_compile_definitions(OpenCL INTERFACE CL_HPP_TARGET_OPENCL_VERSION=${CL_HPP_TARGET_OPENCL_VERSION}) + target_compile_definitions(OpenCL INTERFACE CL_HPP_MINIMUM_OPENCL_VERSION=${CL_HPP_MINIMUM_OPENCL_VERSION}) + + find_file(OPENCL_HPP CL/opencl.hpp HINTS ${OpenCL_INCLUDE_DIRS}) + message(STATUS " -- ${OPENCL_HPP} --") + if(OPENCL_HPP) + target_compile_definitions(OpenCL INTERFACE VEXCL_HAVE_OPENCL_HPP) + endif() target_compile_options(Common INTERFACE $<$:-Wno-catch-value> diff --git a/vexcl/backend/opencl.hpp b/vexcl/backend/opencl.hpp index a0095037..3cbb14f1 100644 --- a/vexcl/backend/opencl.hpp +++ b/vexcl/backend/opencl.hpp @@ -36,7 +36,11 @@ THE SOFTWARE. #endif #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif #include #include diff --git a/vexcl/backend/opencl/compiler.hpp b/vexcl/backend/opencl/compiler.hpp index 914ff38e..18a21c7c 100644 --- a/vexcl/backend/opencl/compiler.hpp +++ b/vexcl/backend/opencl/compiler.hpp @@ -39,7 +39,11 @@ THE SOFTWARE. #include #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif namespace vex { namespace backend { diff --git a/vexcl/backend/opencl/context.hpp b/vexcl/backend/opencl/context.hpp index 53991286..d9c3b86b 100644 --- a/vexcl/backend/opencl/context.hpp +++ b/vexcl/backend/opencl/context.hpp @@ -35,7 +35,11 @@ THE SOFTWARE. #include #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif namespace vex { namespace backend { diff --git a/vexcl/backend/opencl/device_vector.hpp b/vexcl/backend/opencl/device_vector.hpp index 80e4bea1..8e012534 100644 --- a/vexcl/backend/opencl/device_vector.hpp +++ b/vexcl/backend/opencl/device_vector.hpp @@ -32,7 +32,11 @@ THE SOFTWARE. */ #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif namespace vex { namespace backend { diff --git a/vexcl/backend/opencl/error.hpp b/vexcl/backend/opencl/error.hpp index 0cb1339c..8b48492b 100644 --- a/vexcl/backend/opencl/error.hpp +++ b/vexcl/backend/opencl/error.hpp @@ -34,7 +34,11 @@ THE SOFTWARE. #include #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif namespace vex { namespace backend { diff --git a/vexcl/backend/opencl/event.hpp b/vexcl/backend/opencl/event.hpp index 44bf53c0..a1fbd175 100644 --- a/vexcl/backend/opencl/event.hpp +++ b/vexcl/backend/opencl/event.hpp @@ -34,7 +34,11 @@ THE SOFTWARE. #include #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif #include diff --git a/vexcl/backend/opencl/filter.hpp b/vexcl/backend/opencl/filter.hpp index fac5ae81..beb013aa 100644 --- a/vexcl/backend/opencl/filter.hpp +++ b/vexcl/backend/opencl/filter.hpp @@ -46,7 +46,11 @@ THE SOFTWARE. #include #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif namespace vex { diff --git a/vexcl/backend/opencl/image.hpp b/vexcl/backend/opencl/image.hpp index de419fc7..5f0fa04e 100644 --- a/vexcl/backend/opencl/image.hpp +++ b/vexcl/backend/opencl/image.hpp @@ -33,7 +33,11 @@ THE SOFTWARE. #include #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif namespace vex { diff --git a/vexcl/backend/opencl/kernel.hpp b/vexcl/backend/opencl/kernel.hpp index 623ed95c..abceb9e4 100644 --- a/vexcl/backend/opencl/kernel.hpp +++ b/vexcl/backend/opencl/kernel.hpp @@ -34,7 +34,11 @@ THE SOFTWARE. #include #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif #include diff --git a/vexcl/backend/opencl/svm_vector.hpp b/vexcl/backend/opencl/svm_vector.hpp index 7c9b1df2..94b4cb48 100644 --- a/vexcl/backend/opencl/svm_vector.hpp +++ b/vexcl/backend/opencl/svm_vector.hpp @@ -34,7 +34,11 @@ THE SOFTWARE. #include #include -#include +#ifdef VEXCL_HAVE_OPENCL_HPP +# include +#else +# include +#endif #include