Skip to content

Commit

Permalink
Adjust selecting CL version to new OpenCL headers
Browse files Browse the repository at this point in the history
OpenCL 1.0/1.1/1.2/2.0/2.1/2.2 headers are now unified into single
sets of header files. CL version is selected by defining
CL_TARGET_OPENCL_VERSION macro.

See https://github.com/KhronosGroup/OpenCL-Headers
  • Loading branch information
jszuppe committed Dec 25, 2018
1 parent 9189a76 commit 78dd431
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 52 deletions.
18 changes: 1 addition & 17 deletions include/boost/compute/cl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,7 @@
#ifndef BOOST_COMPUTE_CL_HPP
#define BOOST_COMPUTE_CL_HPP

#if defined(BOOST_COMPUTE_MAX_CL_VERSION)
# if !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 202
# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 201
# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 200
# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 102
# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 101
# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
# endif
#endif
#include <boost/compute/detail/cl_versions.hpp>

#if defined(__APPLE__)
#include <OpenCL/cl.h>
Expand Down
18 changes: 1 addition & 17 deletions include/boost/compute/cl_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,7 @@
#ifndef BOOST_COMPUTE_CL_EXT_HPP
#define BOOST_COMPUTE_CL_EXT_HPP

#if defined(BOOST_COMPUTE_MAX_CL_VERSION)
# if !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 202
# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 201
# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 200
# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 102
# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 101
# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
# endif
#endif
#include "detail/cl_versions.hpp"

#if defined(__APPLE__)
#include <OpenCL/cl_ext.h>
Expand Down
64 changes: 64 additions & 0 deletions include/boost/compute/detail/cl_versions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2018 Jakub Szuppe <[email protected]>
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
// http:https://www.boost.org/LICENSE_1_0.txt
//
// See http:https://boostorg.github.com/compute for more information.
//---------------------------------------------------------------------------//

#ifndef BOOST_COMPUTE_DETAIL_CL_VERSION_HPP
#define BOOST_COMPUTE_DETAIL_CL_VERSION_HPP

#if defined(BOOST_COMPUTE_MAX_CL_VERSION)
# if !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 202
# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 201
# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 200
# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 102
# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 101
# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
# endif
#endif

#if defined(BOOST_COMPUTE_MAX_CL_VERSION) && !defined(CL_TARGET_OPENCL_VERSION)
# if BOOST_COMPUTE_MAX_CL_VERSION == 201
# define CL_TARGET_OPENCL_VERSION 210
# elif BOOST_COMPUTE_MAX_CL_VERSION == 200
# define CL_TARGET_OPENCL_VERSION 200
# elif BOOST_COMPUTE_MAX_CL_VERSION == 102
# define CL_TARGET_OPENCL_VERSION 120
# elif BOOST_COMPUTE_MAX_CL_VERSION == 101
# define CL_TARGET_OPENCL_VERSION 110
# elif BOOST_COMPUTE_MAX_CL_VERSION == 100
# define CL_TARGET_OPENCL_VERSION 100
# else
# define CL_TARGET_OPENCL_VERSION 220
# endif
#endif

#if defined(BOOST_COMPUTE_MAX_CL_VERSION) && defined(CL_TARGET_OPENCL_VERSION)
# if BOOST_COMPUTE_MAX_CL_VERSION == 202 && CL_TARGET_OPENCL_VERSION != 220
# error "Boost.Compute: CL_TARGET_OPENCL_VERSION definition does not match BOOST_COMPUTE_MAX_CL_VERSION"
# elif BOOST_COMPUTE_MAX_CL_VERSION == 201 && CL_TARGET_OPENCL_VERSION != 210
# error "Boost.Compute: CL_TARGET_OPENCL_VERSION definition does not match BOOST_COMPUTE_MAX_CL_VERSION"
# elif BOOST_COMPUTE_MAX_CL_VERSION == 200 && CL_TARGET_OPENCL_VERSION != 200
# error "Boost.Compute: CL_TARGET_OPENCL_VERSION definition does not match BOOST_COMPUTE_MAX_CL_VERSION"
# elif BOOST_COMPUTE_MAX_CL_VERSION == 102 && CL_TARGET_OPENCL_VERSION != 120
# error "Boost.Compute: CL_TARGET_OPENCL_VERSION definition does not match BOOST_COMPUTE_MAX_CL_VERSION"
# elif BOOST_COMPUTE_MAX_CL_VERSION == 101 && CL_TARGET_OPENCL_VERSION != 110
# error "Boost.Compute: CL_TARGET_OPENCL_VERSION definition does not match BOOST_COMPUTE_MAX_CL_VERSION"
# elif BOOST_COMPUTE_MAX_CL_VERSION == 100 && CL_TARGET_OPENCL_VERSION != 100
# error "Boost.Compute: CL_TARGET_OPENCL_VERSION definition does not match BOOST_COMPUTE_MAX_CL_VERSION"
# endif
#endif

#endif // BOOST_COMPUTE_DETAIL_CL_VERSION_HPP
3 changes: 2 additions & 1 deletion include/boost/compute/detail/nvidia_compute_capability.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

#include <boost/compute/device.hpp>

#ifdef BOOST_COMPUTE_HAVE_HDR_CL_EXT
#ifdef BOOST_COMPUTE_HAVE_HDR_CL_EXT
#include <boost/compute/detail/cl_versions.hpp>
#include <CL/cl_ext.h>
#endif

Expand Down
2 changes: 2 additions & 0 deletions include/boost/compute/interop/opengl/cl_gl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_HPP

#include <boost/compute/detail/cl_versions.hpp>

#if defined(__APPLE__)
#include <OpenCL/cl_gl.h>
#else
Expand Down
18 changes: 1 addition & 17 deletions include/boost/compute/interop/opengl/cl_gl_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,7 @@
#ifndef BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_EXT_HPP
#define BOOST_COMPUTE_INTEROP_OPENGL_CL_GL_EXT_HPP

#if defined(BOOST_COMPUTE_MAX_CL_VERSION)
# if !defined(CL_USE_DEPRECATED_OPENCL_2_1_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 202
# define CL_USE_DEPRECATED_OPENCL_2_1_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_2_0_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 201
# define CL_USE_DEPRECATED_OPENCL_2_0_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_2_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 200
# define CL_USE_DEPRECATED_OPENCL_1_2_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 102
# define CL_USE_DEPRECATED_OPENCL_1_1_APIS
# endif
# if !defined(CL_USE_DEPRECATED_OPENCL_1_0_APIS) && BOOST_COMPUTE_MAX_CL_VERSION < 101
# define CL_USE_DEPRECATED_OPENCL_1_0_APIS
# endif
#endif
#include <boost/compute/detail/cl_versions.hpp>

#if defined(__APPLE__)
#include <OpenCL/cl_gl_ext.h>
Expand Down

0 comments on commit 78dd431

Please sign in to comment.