Skip to content

Commit

Permalink
used find_package to find a Python3 interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravil Dorozhinskii committed Apr 3, 2023
1 parent b28f778 commit a6dab74
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ else()
endif()
endif()

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
option(ENABLE_PROFILING_MARKERS "enable profiling markers if available" OFF)

string(TOLOWER ${DEVICE_BACKEND} BACKEND_FOLDER)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ If you want to run the examples, follow the instructions in the belonging packag
* Set the environment variable `PREFERRED_DEVICE_TYPE` to compile for the defined `DEVICE_ARCH`
* If `PREFERRED_DEVICE_TYPE` is not specified on build, JIT compilation is assumed and the value of `DEVICE_ARCH` is ignored
* Options for `PREFERRED_DEVICE_TYPE` are `GPU`, `CPU`, or `FPGA`
* The environment variable must be also set before running any code using this lib. The runtime needs this hint to select the right device the code was compile for. If the value was not specified or illegal, the runtime applies a default selection strategy, preferring GPUs over CPUs and CPUs over the host. This might crashes the application if the targeted compilation architecture differs from the runtime target
* The environment variable must be also set before running any code using this lib. The runtime needs this hint to select the right device the code was compile for. If the value was not specified or illegal, the runtime applies a default selection strategy, preferring GPUs over CPUs and CPUs over the host. This might crash the application if the targeted compilation architecture differs from the runtime target
* If `PREFERRED_DEVICE_TYPE` was not specified on build but before running an application, the JIT compiler will generate the kernels and allows switching the device type at runtime
* Complete example call: `export PREFERRED_DEVICE_TYPE=GPU` and `cmake .. -DDEVICE_BACKEND:STRING=oneapi -DREAL_SIZE_IN_BYTES=4 -DDEVICE_ARCH=dg1`

Expand Down
5 changes: 3 additions & 2 deletions cmake/FindDpcppFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ if (NOT TARGET dpcpp::device_flags)

target_compile_definitions(dpcpp::device_flags INTERFACE __DPCPP_COMPILER)
target_compile_definitions(dpcpp::interface INTERFACE __DPCPP_COMPILER)

execute_process(COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/find-dpcpp.py

find_package(Python3 REQUIRED COMPONENTS Interpreter)
execute_process(COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_LIST_DIR}/find-dpcpp.py
OUTPUT_VARIABLE _DPCPP_ROOT)

target_include_directories(dpcpp::interface INTERFACE ${_DPCPP_ROOT}/include
Expand Down
7 changes: 4 additions & 3 deletions cmake/FindOpenSYCLSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ if (NOT TARGET opensycl-settings::interface)
message(FATAL_ERROR "`DEVICE_ARCH` env. variable is not provided.")
else()

find_package(Python3 REQUIRED COMPONENTS Interpreter)
add_library(opensycl-settings::interface INTERFACE IMPORTED)

execute_process(COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py -i
execute_process(COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py -i
OUTPUT_VARIABLE _OPENSYCL_INLCUDE_DIR)

target_include_directories(opensycl-settings::interface INTERFACE ${_OPENSYCL_INLCUDE_DIR}
${_OPENSYCL_INLCUDE_DIR}/sycl)

execute_process(COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py --vendor
execute_process(COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py --vendor
OUTPUT_VARIABLE _OPENSYCL_VENDOR)

target_compile_definitions(opensycl-settings::interface INTERFACE SYCL_PLATFORM_"${_OPENSYCL_VENDOR}")


execute_process(COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py -t -a "${DEVICE_ARCH}"
execute_process(COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_LIST_DIR}/find-opensycl.py -t -a "${DEVICE_ARCH}"
OUTPUT_VARIABLE _OPENSYCL_FULL_TARGET_NAME)

set(HIPSYCL_TARGETS "${_OPENSYCL_FULL_TARGET_NAME}")
Expand Down
2 changes: 0 additions & 2 deletions cmake/find-opensycl.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,3 @@ def get_include_dir():

if (args.vendor):
get_vendor_name()


2 changes: 1 addition & 1 deletion examples/jacobi/src/gpu/kernels/sycl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target_compile_definitions(${TARGET_NAME} PRIVATE DEVICE_${DEVICE_BACKEND}_LANG
target_include_directories(${TARGET_NAME} PUBLIC root)
target_link_libraries(${TARGET_NAME} PUBLIC device)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/root/cmake" "${CMAKE_ROOT}/Modules")
set(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/root/cmake")
if (${DEVICE_BACKEND} STREQUAL "opensycl")
find_package(OpenSYCLSettings REQUIRED)
find_package(OpenSYCL REQUIRED)
Expand Down

0 comments on commit a6dab74

Please sign in to comment.