Skip to content

Commit 8be34ec

Browse files
author
Diptorup Deb
authored
Add a version requirement for dpcpp inside CMakeList.txt. (#339)
* Add a version requirement for dpcpp inside CMakeList.txt. * Add dpcpp_cpp_rt version requirement to dpctl.
1 parent c9fd48b commit 8be34ec

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

conda-recipe/meta.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ requirements:
2828
run:
2929
- python
3030
- numpy >=1.17
31-
- dpcpp_cpp_rt
31+
- dpcpp_cpp_rt >=2021.2
32+
3233
test:
33-
requires:
34-
- pytest
35-
- pytest-cov
34+
requires:
35+
- pytest
36+
- pytest-cov
37+
3638
about:
3739
home: https://github.com/IntelPython/dpctl.git
3840
license: Apache-2.0

dpctl-capi/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ option(DPCTL_BUILD_CAPI_TESTS
2525

2626
# Load our CMake modules to search for DPCPP and Level Zero
2727
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
28-
find_package(DPCPP REQUIRED)
28+
find_package(DPCPP 2021.2.0 REQUIRED)
2929

3030
if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
3131
set(DPCTL_ENABLE_LO_PROGRAM_CREATION 1)

dpctl-capi/cmake/modules/FindDPCPP.cmake

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424
# If successful, the following variables will be defined:
2525
# DPCPP_FOUND
2626
# DPCPP_VERSION
27+
# DPCPP_VERSION_MAJOR
28+
# DPCPP_VERSION_MINOR
2729
# DPCPP_INCLUDE_DIR
2830
# DPCPP_SYCL_INCLUDE_DIR
2931
# DPCPP_LIBRARY_DIR
3032
# DPCPP_SYCL_LIBRARY
3133
# DPCPP_OPENCL_LIBRARY
3234

33-
include( FindPackageHandleStandardArgs )
35+
include(FindPackageHandleStandardArgs)
3436

3537
string(COMPARE EQUAL "${DPCPP_INSTALL_DIR}" "" no_dpcpp_root)
3638
if(${no_dpcpp_root})
@@ -57,10 +59,13 @@ execute_process(
5759
# If dpcpp is found then set the package variables
5860
if(${dpcpp_result} MATCHES "0")
5961
string(REPLACE "\n" ";" DPCPP_VERSION_LIST "${dpcpp_ver}")
62+
set(IDX 0)
6063
list(GET DPCPP_VERSION_LIST 0 dpcpp_ver_line)
6164
foreach(X ${DPCPP_VERSION_LIST})
62-
message(STATUS "dpcpp ver[${dpcpp_result}]: ${X}")
65+
message(STATUS "dpcpp ver[${IDX}]: ${X}")
66+
MATH(EXPR IDX "${IDX}+1")
6367
endforeach()
68+
list(GET DPCPP_VERSION_LIST 0 VERSION_STRING)
6469

6570
# check if llvm-cov and llvm-profdata are packaged as part of dpcpp
6671
find_program(LLVM_COV_EXE
@@ -89,7 +94,13 @@ if(${dpcpp_result} MATCHES "0")
8994

9095
# set package-level variables
9196
set(DPCPP_ROOT ${DPCPP_INSTALL_DIR})
92-
list(GET DPCPP_VERSION_LIST 0 DPCPP_VERSION)
97+
# Get the dpcpp version
98+
string(REGEX MATCH "[0-9]+\.[0-9]+\.[0-9]+" DPCPP_VERSION ${VERSION_STRING})
99+
# Split out the version into major, minor an patch
100+
string(REPLACE "." ";" DPCPP_VERSION_LIST1 "${DPCPP_VERSION}")
101+
list(GET DPCPP_VERSION_LIST1 0 DPCPP_VERSION_MAJOR)
102+
list(GET DPCPP_VERSION_LIST1 1 DPCPP_VERSION_MINOR)
103+
list(GET DPCPP_VERSION_LIST1 2 DPCPP_VERSION_PATCH)
93104
set(DPCPP_INCLUDE_DIR ${DPCPP_INSTALL_DIR}/include)
94105
set(DPCPP_SYCL_INCLUDE_DIR ${DPCPP_INSTALL_DIR}/include/sycl)
95106
set(DPCPP_LIBRARY_DIR ${DPCPP_INSTALL_DIR}/lib)
@@ -100,15 +111,26 @@ if(${dpcpp_result} MATCHES "0")
100111
set(DPCPP_SYCL_LIBRARY ${DPCPP_INSTALL_DIR}/lib/libsycl.so)
101112
set(DPCPP_OPENCL_LIBRARY ${DPCPP_INSTALL_DIR}/lib/libOpenCL.so)
102113
endif()
103-
set(DPCPP_FOUND TRUE)
104114
else()
105115
message(STATUS "DPCPP needed to build dpctl_sycl_interface")
106116
return()
107117
endif()
108118

119+
# Check if a specific version of DPCPP is requested
120+
if(DPCPP_FIND_VERSION)
121+
string(COMPARE EQUAL ${DPCPP_FIND_VERSION} ${DPCPP_VERSION} VERSION_MATCH)
122+
if(VERSION_MATCH)
123+
set(DPCPP_FOUND TRUE)
124+
endif()
125+
else()
126+
set(DPCPP_FOUND TRUE)
127+
endif()
128+
109129
find_package_handle_standard_args(DPCPP DEFAULT_MSG
110130
DPCPP_FOUND
111131
DPCPP_VERSION
132+
DPCPP_VERSION_MAJOR
133+
DPCPP_VERSION_MINOR
112134
DPCPP_INCLUDE_DIR
113135
DPCPP_SYCL_INCLUDE_DIR
114136
DPCPP_LIBRARY_DIR

0 commit comments

Comments
 (0)