Skip to content

Add a version requirement for dpcpp inside CMakeList.txt. #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ requirements:
run:
- python
- numpy >=1.17
- dpcpp_cpp_rt
- dpcpp_cpp_rt >=2021.2

test:
requires:
- pytest
- pytest-cov
requires:
- pytest
- pytest-cov

about:
home: https://github.com/IntelPython/dpCtl.git
license: Apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion dpctl-capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ option(DPCTL_BUILD_CAPI_TESTS

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

if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
set(DPCTL_ENABLE_LO_PROGRAM_CREATION 1)
Expand Down
30 changes: 26 additions & 4 deletions dpctl-capi/cmake/modules/FindDPCPP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
# If successful, the following variables will be defined:
# DPCPP_FOUND
# DPCPP_VERSION
# DPCPP_VERSION_MAJOR
# DPCPP_VERSION_MINOR
# DPCPP_INCLUDE_DIR
# DPCPP_SYCL_INCLUDE_DIR
# DPCPP_LIBRARY_DIR
# DPCPP_SYCL_LIBRARY
# DPCPP_OPENCL_LIBRARY

include( FindPackageHandleStandardArgs )
include(FindPackageHandleStandardArgs)

string(COMPARE EQUAL "${DPCPP_INSTALL_DIR}" "" no_dpcpp_root)
if(${no_dpcpp_root})
Expand All @@ -57,10 +59,13 @@ execute_process(
# If dpcpp is found then set the package variables
if(${dpcpp_result} MATCHES "0")
string(REPLACE "\n" ";" DPCPP_VERSION_LIST "${dpcpp_ver}")
set(IDX 0)
list(GET DPCPP_VERSION_LIST 0 dpcpp_ver_line)
foreach(X ${DPCPP_VERSION_LIST})
message(STATUS "dpcpp ver[${dpcpp_result}]: ${X}")
message(STATUS "dpcpp ver[${IDX}]: ${X}")
MATH(EXPR IDX "${IDX}+1")
endforeach()
list(GET DPCPP_VERSION_LIST 0 VERSION_STRING)

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

# set package-level variables
set(DPCPP_ROOT ${DPCPP_INSTALL_DIR})
list(GET DPCPP_VERSION_LIST 0 DPCPP_VERSION)
# Get the dpcpp version
string(REGEX MATCH "[0-9]+\.[0-9]+\.[0-9]+" DPCPP_VERSION ${VERSION_STRING})
# Split out the version into major, minor an patch
string(REPLACE "." ";" DPCPP_VERSION_LIST1 "${DPCPP_VERSION}")
list(GET DPCPP_VERSION_LIST1 0 DPCPP_VERSION_MAJOR)
list(GET DPCPP_VERSION_LIST1 1 DPCPP_VERSION_MINOR)
list(GET DPCPP_VERSION_LIST1 2 DPCPP_VERSION_PATCH)
set(DPCPP_INCLUDE_DIR ${DPCPP_INSTALL_DIR}/include)
set(DPCPP_SYCL_INCLUDE_DIR ${DPCPP_INSTALL_DIR}/include/sycl)
set(DPCPP_LIBRARY_DIR ${DPCPP_INSTALL_DIR}/lib)
Expand All @@ -100,15 +111,26 @@ if(${dpcpp_result} MATCHES "0")
set(DPCPP_SYCL_LIBRARY ${DPCPP_INSTALL_DIR}/lib/libsycl.so)
set(DPCPP_OPENCL_LIBRARY ${DPCPP_INSTALL_DIR}/lib/libOpenCL.so)
endif()
set(DPCPP_FOUND TRUE)
else()
message(STATUS "DPCPP needed to build dpctl_sycl_interface")
return()
endif()

# Check if a specific version of DPCPP is requested
if(DPCPP_FIND_VERSION)
string(COMPARE EQUAL ${DPCPP_FIND_VERSION} ${DPCPP_VERSION} VERSION_MATCH)
if(VERSION_MATCH)
set(DPCPP_FOUND TRUE)
endif()
else()
set(DPCPP_FOUND TRUE)
endif()

find_package_handle_standard_args(DPCPP DEFAULT_MSG
DPCPP_FOUND
DPCPP_VERSION
DPCPP_VERSION_MAJOR
DPCPP_VERSION_MINOR
DPCPP_INCLUDE_DIR
DPCPP_SYCL_INCLUDE_DIR
DPCPP_LIBRARY_DIR
Expand Down