11cmake_minimum_required (VERSION 3.3.2 FATAL_ERROR)
2- project ("DPPPY-Oneapi-Interface - A lightweight SYCL wrapper for Python" )
3-
4- set (ONEAPI_ROOT "$ENV{ONEAPI_ROOT} " )
5- string (COMPARE EQUAL "${ONEAPI_ROOT} " "" ONEAPI_ROOT_EMPTY)
6- if (${ONEAPI_ROOT_EMPTY} )
7- message (FATAL_ERROR "Please set an environment varaible ONEAPI_ROOT \
8- pointing to you oneAPI install directory." )
9- else ()
10- message (STATUS "oneAPI Root: ${ONEAPI_ROOT} " )
11- endif ()
12-
13- if (WIN32 )
14- set (DPCPP_ROOT "${ONEAPI_ROOT} /compiler/latest/windows" )
15- elseif (UNIX )
16- set (DPCPP_ROOT "${ONEAPI_ROOT} /compiler/latest/linux" )
17- endif ()
18-
19- if (WIN32 )
20- set (dpcpp_cmd "${DPCPP_ROOT} /bin/dpcpp-cl" )
21- set (dpcpp_arg "--version" )
22- elseif (UNIX )
23- set (dpcpp_cmd "${DPCPP_ROOT} /bin/dpcpp" )
24- set (dpcpp_arg "--version" )
25- else ()
26- message (FATAL_ERROR "Unsupported system." )
27- endif ()
2+ project ("PyDPPL - A lightweight SYCL wrapper for Python" )
3+
4+ # The function checks is DPCPP_ROOT is valid and points to a dpcpp installation
5+ function (check_for_dpcpp)
6+ string (COMPARE EQUAL "${DPCPP_ROOT} " "" no_dpcpp_root)
7+ if (${no_dpcpp_root} )
8+ message (FATAL_ERROR "Set the DPCPP_ROOT argument providing the path to \
9+ a dpcpp installation." )
10+ endif ()
11+
12+ if (WIN32 )
13+ set (dpcpp_cmd "${DPCPP_ROOT} /bin/dpcpp-cl" )
14+ set (dpcpp_arg "--version" )
15+ elseif (UNIX )
16+ set (dpcpp_cmd "${DPCPP_ROOT} /bin/dpcpp" )
17+ set (dpcpp_arg "--version" )
18+ else ()
19+ message (FATAL_ERROR "Unsupported system." )
20+ endif ()
21+
22+ # Check if dpcpp is available
23+ execute_process (
24+ COMMAND ${dpcpp_cmd} ${dpcpp_arg}
25+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
26+ RESULT_VARIABLE dpcpp_result
27+ OUTPUT_VARIABLE dpcpp_ver
28+ )
2829
29- execute_process (
30- COMMAND ${dpcpp_cmd} ${dpcpp_arg}
31- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
32- RESULT_VARIABLE dpcpp_result
33- OUTPUT_VARIABLE dpcpp_ver)
34-
35- if (${dpcpp_result} MATCHES "0" )
36- string (REPLACE "\n " ";" DPCPP_VERSION_LIST "${dpcpp_ver} " )
37- list (GET DPCPP_VERSION_LIST 0 dpcpp_ver_line)
38- foreach (X ${DPCPP_VERSION_LIST} )
39- message (STATUS "dpcpp ver[${dpcpp_result} ]: ${X} " )
40- endforeach ()
41- else ()
42- message (FATAL_MESSAGE "DPCPP needed to build DPPL-Oneapi-Interface" )
43- endif ()
30+ if (${dpcpp_result} MATCHES "0" )
31+ string (REPLACE "\n " ";" DPCPP_VERSION_LIST "${dpcpp_ver} " )
32+ list (GET DPCPP_VERSION_LIST 0 dpcpp_ver_line)
33+ foreach (X ${DPCPP_VERSION_LIST} )
34+ message (STATUS "dpcpp ver[${dpcpp_result} ]: ${X} " )
35+ endforeach ()
36+ else ()
37+ message (FATAL_MESSAGE "DPCPP needed to build dppl_oneapi_interface" )
38+ endif ()
39+ endfunction ()
40+
41+ function (check_for_numpy_inc)
42+ string (COMPARE EQUAL "${NUMPY_INCLUDE_DIR} " "" no_numpy_inc)
43+ if (${no_dpcpp_root} )
44+ message (FATAL_ERROR "Set the NUMPY_INCLUDE_DIR argument providing the \
45+ path to NumPy Headers." )
46+ else ()
47+ message (STATUS "NUMPY_INCLUDE_DIR: ${NUMPY_INCLUDE_DIR} " )
48+ endif ()
49+
50+ string (COMPARE EQUAL "${PYTHON_INCLUDE_DIR} " "" no_python_inc)
51+ if (${no_dpcpp_root} )
52+ message (FATAL_ERROR "Set the PYTHON_INCLUDE_DIR argument providing the \
53+ path to Python Headers." )
54+ else ()
55+ message (STATUS "PYTHON_INCLUDE_DIR: ${PYTHON_INCLUDE_DIR} " )
56+ endif ()
57+ endfunction ()
58+
59+ # Check for dpcpp in the specified DPCPP_ROOT
60+ check_for_dpcpp()
61+ # Check if the locations of Numpy and Python headers were provided
62+ check_for_numpy_inc()
4463
4564if (WIN32 )
4665 set (CMAKE_CXX_COMPILER:PATH "${DPCPP_ROOT} /bin/dpcpp-cl" )
4766 set (CMAKE_C_COMPILER:PATH "${DPCPP_ROOT} /bin/clang-cl" )
4867 set (CMAKE_LINKER:PATH "${DPCPP_ROOT} /bin/lld-link" )
68+ message (STATUS "Resetting CXX compiler to: " ${CMAKE_CXX_COMPILER} )
69+ message (STATUS "Resetting C compiler to: " ${CMAKE_C_COMPILER} )
70+ message (STATUS "Resetting Linker to: " ${CMAKE_LINK} )
71+
4972 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
5073 -Wall -Wextra -Winit-self -Wuninitialized -Wmissing-declarations \
5174 -fdiagnostics-color=auto -O3 \
5275 " )
5376 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17" )
5477 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3 -DDEBUG " )
55- message (STATUS "Resetting CXX compiler to: " ${CMAKE_CXX_COMPILER} )
56- message (STATUS "Resetting C compiler to: " ${CMAKE_C_COMPILER} )
57- message (STATUS "Resetting Linker to: " ${CMAKE_LINK} )
5878elseif (UNIX )
59- set (CMAKE_CXX_COMPILER "${DPCPP_ROOT} /bin/dpcpp" )
60- set (CMAKE_C_COMPILER "${DPCPP_ROOT} /bin/clang" )
79+ set (CMAKE_CXX_COMPILER "dpcpp" )
80+ set (CMAKE_C_COMPILER "clang" )
81+
6182 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \
6283 -Wall -Wextra -Winit-self -Wuninitialized -Wmissing-declarations \
6384 -fdiagnostics-color=auto -O3 \
@@ -69,28 +90,8 @@ else()
6990endif ()
7091
7192
72- #set(OPENCL_LIBDIR "$ENV{OpenCL_LIBDIR}")
73- #string(COMPARE EQUAL "${OPENCL_LIBDIR}" "" OPENCL_LIBDIR_EMPTY)
74-
75- # This is a temporary hack to pass in the OpenCL install directory
76- # using an environment variable. We are doing this as we want to pass
77- # OpenCL_LIBDR to build.sh.
78-
79- # if(${OPENCL_LIBDIR_EMPTY})
80- # message(FATAL_ERROR "Set the OpenCL_LIBDIR and OpenCL_INCLUDE_DIR \
81- # environment variables to point to an OpenCL installation.")
82- # endif()
83-
84- #---- We need OpenCL
85- # find_package(OpenCL REQUIRED)
86- # if(WIN32)
87- # set(OpenCL_LIBRARY ${OpenCL_LIBDIR}/libOpenCL.lib)
88- # elseif(UNIX)
89- # set(OpenCL_LIBRARY ${OpenCL_LIBDIR}/libOpenCL.so)
90- # endif()
91-
92- set (OpenCL_INCLUDE_DIR "${ONEAPI_ROOT} /compiler/latest/linux/include/sycl" )
93- set (OpenCL_LIBRARY "${ONEAPI_ROOT} /compiler/latest/linux/lib/libOpenCL.so" )
93+ set (OpenCL_INCLUDE_DIR "${DPCPP_ROOT} /include/sycl" )
94+ set (OpenCL_LIBRARY "${DPCPP_ROOT} /lib/libOpenCL.so" )
9495
9596message (STATUS "OpenCL_INCLUDE_DIR: ${OpenCL_INCLUDE_DIR} " )
9697message (STATUS "OpenCL_LIBRARY: ${OpenCL_LIBRARY} " )
@@ -105,17 +106,20 @@ add_library(
105106 source /dppl_oneapi_interface.cpp
106107)
107108
108- # Install DPPLOpenCLInterface as a separate library to be removed later
109+ # Install DPPLOpenCLInterface
109110add_library (
110111 DPPLOpenCLInterface
111112 SHARED
112113 source /dppl_opencl_interface.c
113114)
114115
116+ # Install DPPLOneAPIInterface
115117target_include_directories (
116118 DPPLOneapiInterface
117119 PRIVATE
118120 ${CMAKE_SOURCE_DIR} /include /
121+ ${PYTHON_INCLUDE_DIR}
122+ ${NUMPY_INCLUDE_DIR}
119123)
120124
121125target_include_directories (
@@ -134,34 +138,23 @@ if(WIN32)
134138 message (
135139 STATUS
136140 "SYCL_INCLUDE_DIR: "
137- ${ONEAPI_ROOT} /compiler/latest/windows /include /sycl
141+ ${DPCPP_ROOT} /include /sycl
138142 )
139143 target_include_directories (
140144 DPPLOneapiInterface
141145 PUBLIC
142- ${ONEAPI_ROOT} /compiler/latest/windows /include /sycl
146+ ${DPCPP_ROOT} /include /sycl
143147 )
144148 target_link_libraries (
145149 DPPLOneapiInterface
146150 PRIVATE
147- ${ONEAPI_ROOT} /compiler/latest/windows /lib/sycl.lib
151+ ${DPCPP_ROOT} /lib/sycl.lib
148152 )
149153 target_link_libraries (
150154 DPPLOpenCLInterface
151155 PRIVATE
152156 ${OpenCL_INCLUDE_DIR} /../lib/x64/OpenCL.lib
153157 )
154- elseif (UNIX )
155- message (
156- STATUS
157- "SYCL_INCLUDE_DIR: "
158- ${ONEAPI_ROOT} /compiler/latest/linux/include /sycl
159- )
160- #target_include_directories(
161- # DPPLOneapiInterface
162- # SYSTEM PUBLIC
163- # /opt/intel/inteloneapi/compiler/latest/linux/include/sycl
164- #)
165158endif ()
166159
167160install (
0 commit comments