-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from intel/gh/arthuryuan1987/1/head
SYCL building system
- Loading branch information
Showing
11 changed files
with
1,166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# torch-xpu-ops: XPU implementation for PyTorch ATen | ||
|
||
# outputs: | ||
# | ||
# PYTORCH_FOUND_XPU | ||
# -- The flag to indicate whether XPU backend stacks are setup successfully or not. | ||
# | ||
# libtorch_xpu_ops | ||
# -- Static archive library target | ||
|
||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR) | ||
project(${TORCH_XPU_OPS_PROJ_NAME} VERSION ${CMAKE_PROJECT_VERSION}) | ||
|
||
set(PYTORCH_FOUND_XPU FALSE) | ||
|
||
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux") | ||
message("torch-xpu-ops only supports Linux system so far. We will support more systems in future.") | ||
return() | ||
endif() | ||
|
||
set(TORCH_XPU_OPS_ROOT ${PROJECT_SOURCE_DIR}) | ||
list(APPEND CMAKE_MODULE_PATH ${TORCH_XPU_OPS_ROOT}/cmake/Modules) | ||
|
||
include(${TORCH_XPU_OPS_ROOT}/cmake/SYCL.cmake) | ||
include(${TORCH_XPU_OPS_ROOT}/cmake/BuildFlags.cmake) | ||
|
||
if(BUILD_TEST) | ||
add_subdirectory(${TORCH_XPU_OPS_ROOT}/test/sycl ${CMAKE_BINARY_DIR}/test_sycl) | ||
endif() | ||
|
||
set(PYTORCH_FOUND_XPU TRUE) | ||
|
||
message(STATUS "XPU found") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Setup building flags for SYCL device and host codes. | ||
|
||
# Support GCC only at the moment. | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
# # -- Host flags (SYCL_CXX_FLAGS) | ||
list(APPEND SYCL_HOST_FLAGS -fPIC) | ||
list(APPEND SYCL_HOST_FLAGS -std=c++17) | ||
# SYCL headers warnings | ||
list(APPEND SYCL_HOST_FLAGS -Wno-deprecated-declarations) | ||
list(APPEND SYCL_HOST_FLAGS -Wno-attributes) | ||
|
||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
list(APPEND SYCL_HOST_FLAGS -g) | ||
list(APPEND SYCL_HOST_FLAGS -O0) | ||
endif(CMAKE_BUILD_TYPE MATCHES Debug) | ||
|
||
# -- Kernel flags (SYCL_KERNEL_OPTIONS) | ||
# The fast-math will be enabled by default in SYCL compiler. | ||
# Refer to [https://clang.llvm.org/docs/UsersManual.html#cmdoption-fno-fast-math] | ||
# 1. We enable below flags here to be warn about NaN and Infinity, | ||
# which will be hidden by fast-math by default. | ||
# 2. The associative-math in fast-math allows floating point | ||
# operations to be reassociated, which will lead to non-deterministic | ||
# results compared with CUDA backend. | ||
# 3. The approx-func allows certain math function calls (such as log, sqrt, pow, etc) | ||
# to be replaced with an approximately equivalent set of instructions or | ||
# alternative math function calls, which have great errors. | ||
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -fno-sycl-unnamed-lambda) | ||
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -sycl-std=2020) | ||
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -fhonor-nans) | ||
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -fhonor-infinities) | ||
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -fno-associative-math) | ||
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -fno-approx-func) | ||
# TODO: Align with PyTorch and switch to ABI=0 eventually, after | ||
# resolving incompatible implementation in SYCL runtime. | ||
set(SYCL_KERNEL_OPTIONS ${SYCL_KERNEL_OPTIONS} -D_GLIBCXX_USE_CXX11_ABI=1) | ||
set(SYCL_FLAGS ${SYCL_FLAGS} ${SYCL_KERNEL_OPTIONS}) | ||
else() | ||
message("Not compiling with XPU. Only support GCC compiler as CXX compiler.") | ||
return() | ||
endif() |
Oops, something went wrong.