如何在 windows10 的 Clion 中使用 intel opencl sdk?

How to use intel opencl sdk in Clion in windows 10?

我已经为 windows 安装了 Intel opencl sdk,并将 opencl 变量添加到环境变量中。我想将此 sdk 与我的 Clion ide 一起使用,但我无法将其包含在我当前的项目中,因为它 CL/cl.hpp 未找到。如何将它添加到我在 Clion 的项目中?

Cl/cl.hpp 位于C:\Program Files(x86)\IntelSWTools\OpenCL\sdk\include\CL

以下是我的CMakeLists.txt


project(tpch_framework)

# enable c++11
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_BUILD_TYPE "Release")

find_package(OpenMP REQUIRED)
find_package(OpenCL REQUIRED)

if (OPENMP_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif() 

# Configure required Boost libraries
set(BOOST_ROOT "" CACHE PATH "Boost build root (useful on Windows)")
option(Boost_USE_STATIC_LIBS
       "Search for static boost libs" OFF)
option(Boost_USE_MULTITHREADED
       "Search for multithreaded boost libs" ON)
option(Boost_USE_STATIC_RUNTIME
       "Search for boost libs linked against static C++ runtime" OFF)
find_package(Boost 1.47.0 REQUIRED filesystem system)

# ensure that dependant libraries not explicitly specified here
# are found by the linker:
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})

#Bring the headers into the project
include_directories(include)

FILE(GLOB_RECURSE INC_ALL "include/*.hpp")

#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")

add_library(tpch_framework ${SOURCES})
add_executable(framework main.cpp ${INC_ALL})
target_link_libraries(framework tpch_framework)
#target_link_libraries(framework stdc++fs)
target_link_libraries(framework ${LIBS})

您需要像为 Boost headers 提供的那样为 OpenCL headers 提供有关包含目录的信息。此外,您需要 link OpenCL 库与您的目标。

在您的 CMakeLists 中...

对于包含和 link 目录:

link_directories(${Boost_LIBRARY_DIRS} ${OpenCL_LIBRARY})
include_directories(${Boost_INCLUDE_DIRS} ${OpenCL_INCLUDE_DIRS})

对于 linking 库:

set(LIBS ${LIBS} ${Boost_LIBRARIES} ${OpenCL_LIBRARY})