git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #97540 from danieldk/fix-clpeak

clpeak: fix build

commit5d131d332680f719320360eccfad220514436f18 authorWORLDofPEACE <worldofpeace@protonmail.ch> dateWed 9 Sep 2020, 10:23 (6 years ago) parent88f0b995f67382
2 files changed+80
pkgs/tools/misc/clpeak/clpeak-clhpp2.diff+72 pkgs/tools/misc/clpeak/default.nix+8
pkgs/tools/misc/clpeak/clpeak-clhpp2.diffnew file+72
@@ -0,0 +1,72 @@
1+diff --git a/CMakeLists.txt b/CMakeLists.txt
2+index 86fec9e..b9d0341 100644
3+--- a/CMakeLists.txt
4++++ b/CMakeLists.txt
5+@@ -22,7 +22,7 @@ elseif(WIN32 AND ${OpenCL_LIBRARIES} MATCHES "OpenCL.lib")
6+ set(OpenCL_LIBRARIES ${OpenCL_LIBRARIES} cfgmgr32.lib)
7+ endif()
8+
9+-FIND_PATH(HPP_FOUND CL/cl.hpp PATHS ${OpenCL_INCLUDE_DIRS})
10++FIND_PATH(HPP_FOUND CL/cl2.hpp PATHS ${OpenCL_INCLUDE_DIRS})
11+ if(NOT HPP_FOUND)
12+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
13+ include(BuildCLHpp)
14+diff --git a/include/clpeak.h b/include/clpeak.h
15+index c090d31..0d9d5e2 100644
16+--- a/include/clpeak.h
17++++ b/include/clpeak.h
18+@@ -1,14 +1,10 @@
19+ #ifndef CLPEAK_HPP
20+ #define CLPEAK_HPP
21+
22+-#define __CL_ENABLE_EXCEPTIONS
23+-
24+-#include <CL/cl.hpp>
25+-
26+ #include <iostream>
27+ #include <stdio.h>
28+ #include <iomanip>
29+-#include <string.h>
30++#include <string>
31+ #include <sstream>
32+ #include <common.h>
33+ #include <logger.h>
34+diff --git a/include/common.h b/include/common.h
35+index 91318cb..6aaca04 100644
36+--- a/include/common.h
37++++ b/include/common.h
38+@@ -1,7 +1,11 @@
39+ #ifndef COMMON_H
40+ #define COMMON_H
41+
42+-#include <CL/cl.hpp>
43++#define CL_HPP_ENABLE_EXCEPTIONS
44++#define CL_HPP_MINIMUM_OPENCL_VERSION 120
45++#define CL_HPP_TARGET_OPENCL_VERSION 120
46++#include <CL/cl2.hpp>
47++
48+ #if defined(__APPLE__) || defined(__MACOSX) || defined(__FreeBSD__)
49+ #include <sys/types.h>
50+ #endif
51+diff --git a/src/clpeak.cpp b/src/clpeak.cpp
52+index 8708463..4a47842 100644
53+--- a/src/clpeak.cpp
54++++ b/src/clpeak.cpp
55+@@ -3,7 +3,7 @@
56+
57+ #define MSTRINGIFY(...) #__VA_ARGS__
58+
59+-static const char *stringifiedKernels =
60++static const std::string stringifiedKernels =
61+ #include "global_bandwidth_kernels.cl"
62+ #include "compute_sp_kernels.cl"
63+ #include "compute_hp_kernels.cl"
64+@@ -65,7 +65,7 @@ int clPeak::runAll()
65+
66+ cl::Context ctx(CL_DEVICE_TYPE_ALL, cps);
67+ vector<cl::Device> devices = ctx.getInfo<CL_CONTEXT_DEVICES>();
68+- cl::Program::Sources source(1, make_pair(stringifiedKernels, (strlen(stringifiedKernels) + 1)));
69++ cl::Program::Sources source(1, stringifiedKernels);
70+ cl::Program prog = cl::Program(ctx, source);
71+
72+ for (size_t d = 0; d < devices.size(); d++)
pkgs/tools/misc/clpeak/default.nix+8
@@ -12,6 +12,14 @@ stdenv.mkDerivation rec {
1212 sha256 = "1wkjpvn4r89c3y06rv7gfpwpqw6ljmqwz0w0mljl9y5hn1r4pkx2";
1313 };
1414
15+ patches = [
16+ # The cl.hpp header was removed from opencl-clhpp. This patch
17+ # updates clpeak to use the new cp2.hpp header. The patch comes
18+ # from the following PR and was updated to apply against more
19+ # recent versions: https://github.com/krrishnarraj/clpeak/pull/46
20+ ./clpeak-clhpp2.diff
21+ ];
22+
1523 nativeBuildInputs = [ cmake ];
1624
1725 buildInputs = [ ocl-icd opencl-clhpp ];