Skip to content
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

Implemented support for non-standard installation of oneAPI compiler by dpctl #481

Merged
merged 1 commit into from
May 27, 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
14 changes: 9 additions & 5 deletions dpctl-capi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ project(
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
find_package(Git REQUIRED)

option(DPCTL_CUSTOM_DPCPP_INSTALL_DIR
"Use a custom version of DPCPP installed at the provided location."
option(DPCTL_DPCPP_HOME_DIR
"The installation home for the DPC++ toolchain compiler."
OFF
)
option(DPCTL_DPCPP_FROM_ONEAPI
"Indicates whether DPCTL_DPCPP_HOME_DIR points to a oneAPI installation."
ON
)
# Option to turn on support for creating Level Zero interoperability programs
# from a SPIR-V binary file.
option(DPCTL_ENABLE_LO_PROGRAM_CREATION
Expand All @@ -36,10 +40,10 @@ option(DPCTL_BUILD_CAPI_TESTS
)

# Minimum version requirement only when oneAPI dpcpp is used.
if(DPCTL_CUSTOM_DPCPP_INSTALL_DIR)
find_package(IntelSycl REQUIRED)
else()
if(DPCTL_DPCPP_FROM_ONEAPI)
find_package(IntelSycl 2021.2.0 REQUIRED)
else()
find_package(IntelSycl REQUIRED)
endif()

if(DPCTL_ENABLE_LO_PROGRAM_CREATION)
Expand Down
30 changes: 11 additions & 19 deletions dpctl-capi/cmake/modules/FindIntelSycl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ include(FindPackageHandleStandardArgs)

# Check if a specific DPC++ installation directory was provided then set
# IntelSycl_ROOT to that path.
if(DPCTL_CUSTOM_DPCPP_INSTALL_DIR)
set(IntelSycl_ROOT ${DPCTL_CUSTOM_DPCPP_INSTALL_DIR})
set(USING_ONEAPI_DPCPP False)
message(STATUS "Not using oneAPI, but IntelSycl at " ${IntelSycl_ROOT})
if(DPCTL_DPCPP_HOME_DIR)
set(IntelSycl_ROOT ${DPCTL_DPCPP_HOME_DIR})
message(STATUS "Not using standard oneAPI installation, but IntelSycl at " ${IntelSycl_ROOT})
# If DPC++ installation was not specified, check for ONEAPI_ROOT
elseif(DEFINED ENV{ONEAPI_ROOT})
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
Expand All @@ -49,38 +48,31 @@ elseif(DEFINED ENV{ONEAPI_ROOT})
else()
message(FATAL_ERROR "Unsupported system.")
endif()
set(USING_ONEAPI_DPCPP True)
else()
message(FATAL_ERROR,
"Could not locate a DPC++ installation. Either pass the path to a "
"custom location using CUSTOM_IntelSycl_INSTALL_DIR or set the "
"custom location using DPCTL_DPCPP_HOME_DIR or set the "
" ONEAPI_ROOT environment variable."
)
return()
endif()

# We will extract the version information from the compiler
if(USING_ONEAPI_DPCPP)
set(dpcpp_cmd "${IntelSycl_ROOT}/bin/dpcpp")
set(dpcpp_arg "--version")
else()
set(dpcpp_cmd "${IntelSycl_ROOT}/bin/clang++")
set(dpcpp_arg "--version")
endif()
set(clangxx_cmd "${IntelSycl_ROOT}/bin/clang++")
set(clangxx_arg "--version")

# Check if dpcpp is available
execute_process(
COMMAND ${dpcpp_cmd} ${dpcpp_arg}
COMMAND ${clangxx_cmd} ${clangxx_arg}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE dpcpp_result
OUTPUT_VARIABLE dpcpp_ver
RESULT_VARIABLE clangxx_result
OUTPUT_VARIABLE clangxx_ver
)

# If dpcpp is found then set the package variables
if(${dpcpp_result} MATCHES "0")
string(REPLACE "\n" ";" IntelSycl_VERSION_LIST "${dpcpp_ver}")
if(${clangxx_result} MATCHES "0")
string(REPLACE "\n" ";" IntelSycl_VERSION_LIST "${clangxx_ver}")
set(IDX 0)
list(GET IntelSycl_VERSION_LIST 0 dpcpp_ver_line)
foreach(X ${IntelSycl_VERSION_LIST})
message(STATUS "dpcpp ver[${IDX}]: ${X}")
MATH(EXPR IDX "${IDX}+1")
Expand Down
5 changes: 4 additions & 1 deletion scripts/build_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,17 @@ def build_backend(
if IS_LIN:
if os.path.exists(os.path.join(DPCPP_ROOT, "bin", "dpcpp")):
cmake_compiler_args = [
"-DDPCTL_DPCPP_HOME_DIR=" + DPCPP_ROOT,
"-DDPCTL_DPCPP_FROM_ONEAPI=ON",
"-DCMAKE_C_COMPILER:PATH="
+ os.path.join(DPCPP_ROOT, "bin", "clang"),
"-DCMAKE_CXX_COMPILER:PATH="
+ os.path.join(DPCPP_ROOT, "bin", "dpcpp"),
]
else:
cmake_compiler_args = [
"-DDPCTL_CUSTOM_DPCPP_INSTALL_DIR=" + DPCPP_ROOT,
"-DDPCTL_DPCPP_HOME_DIR=" + DPCPP_ROOT,
"-DDPCTL_DPCPP_FROM_ONEAPI=OFF",
"-DCMAKE_C_COMPILER:PATH="
+ os.path.join(DPCPP_ROOT, "bin", "clang"),
"-DCMAKE_CXX_COMPILER:PATH="
Expand Down