Skip to content

Commit

Permalink
Use opencl.hpp instead of cl.hpp
Browse files Browse the repository at this point in the history
fixes #73
  • Loading branch information
krrishnarraj committed Nov 8, 2020
1 parent 24f8c73 commit db42d30
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ elseif(WIN32 AND ${OpenCL_LIBRARIES} MATCHES "OpenCL.lib")
set(OpenCL_LIBRARIES ${OpenCL_LIBRARIES} cfgmgr32.lib)
endif()

FIND_PATH(HPP_FOUND CL/cl.hpp PATHS ${OpenCL_INCLUDE_DIRS})
FIND_PATH(HPP_FOUND CL/opencl.hpp PATHS ${OpenCL_INCLUDE_DIRS})
if(NOT HPP_FOUND)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(BuildCLHpp)
Expand Down Expand Up @@ -63,9 +63,7 @@ target_compile_definitions(clpeak PRIVATE CL_TARGET_OPENCL_VERSION=120)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
target_compile_options(clpeak PRIVATE -fPIC -Wall -Wextra -Wconversion -Wno-deprecated-declarations -Wno-unused-parameter -Wno-ignored-attributes)
elseif(MSVC)
target_compile_options(clpeak PRIVATE /wd4996)
target_compile_options(clpeak PRIVATE -fPIC -Wall -Wextra -Wno-unused-parameter)
endif()

install(TARGETS clpeak RUNTIME DESTINATION bin)
Expand Down
2 changes: 1 addition & 1 deletion cmake/BuildCLHpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_LIST_CONTENT "
ExternalProject_add( hpp_headers
PREFIX hpp
GIT_REPOSITORY https://github.com/KhronosGroup/OpenCL-CLHPP
GIT_TAG opencl21
GIT_TAG master
GIT_SHALLOW 1
GIT_PROGRESS 1
CMAKE_ARGS
Expand Down
4 changes: 0 additions & 4 deletions include/clpeak.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#ifndef CLPEAK_HPP
#define CLPEAK_HPP

#define __CL_ENABLE_EXCEPTIONS

#include <CL/cl.hpp>

#include <iostream>
#include <stdio.h>
#include <iomanip>
Expand Down
7 changes: 6 additions & 1 deletion include/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#ifndef COMMON_H
#define COMMON_H

#include <CL/cl.hpp>
#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_MINIMUM_OPENCL_VERSION 120
#define CL_HPP_TARGET_OPENCL_VERSION 120

#include <CL/opencl.hpp>

#if defined(__APPLE__) || defined(__MACOSX) || defined(__FreeBSD__)
#include <sys/types.h>
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/clpeak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define MSTRINGIFY(...) #__VA_ARGS__

static const char *stringifiedKernels =
static const std::string stringifiedKernels =
#include "global_bandwidth_kernels.cl"
#include "compute_sp_kernels.cl"
#include "compute_hp_kernels.cl"
Expand Down Expand Up @@ -66,7 +66,7 @@ int clPeak::runAll()

cl::Context ctx(CL_DEVICE_TYPE_ALL, cps);
vector<cl::Device> devices = ctx.getInfo<CL_CONTEXT_DEVICES>();
cl::Program::Sources source(1, make_pair(stringifiedKernels, (strlen(stringifiedKernels) + 1)));
cl::Program::Sources source(1, stringifiedKernels);
cl::Program prog = cl::Program(ctx, source);

for (size_t d = 0; d < devices.size(); d++)
Expand Down

0 comments on commit db42d30

Please sign in to comment.