diff --git a/CMakeLists.txt b/CMakeLists.txt index f265504636..4a446c19a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,16 @@ set(DPCTL_TARGET_HIP CACHE STRING "Build DPCTL to target a HIP device architecture" ) -option(DPCTL_WITH_REDIST "Build DPCTL assuming DPC++ redistributable is installed into Python prefix" OFF) +option( + DPCTL_WITH_REDIST + "Build DPCTL assuming DPC++ redistributable is installed into Python prefix" + OFF) +option( + DPCTL_OFFLOAD_COMPRESS + "Build using offload section compression feature of DPC++ to reduce \ +size of shared object with offloading sections" + OFF +) find_package(IntelSYCL REQUIRED PATHS ${CMAKE_SOURCE_DIR}/cmake NO_DEFAULT_PATH) diff --git a/dpctl/CMakeLists.txt b/dpctl/CMakeLists.txt index 781944ea0c..1de0bbf77d 100644 --- a/dpctl/CMakeLists.txt +++ b/dpctl/CMakeLists.txt @@ -111,6 +111,11 @@ function(build_dpctl_ext _trgt _src _dest) Python_add_library(${_trgt} MODULE WITH_SOABI ${_generated_src}) if (BUILD_DPCTL_EXT_SYCL) add_sycl_to_target(TARGET ${_trgt} SOURCES ${_generated_src}) + target_compile_options(${_trgt} PRIVATE -fno-sycl-id-queries-fit-in-int) + target_link_options(${_trgt} PRIVATE -fsycl-device-code-split=per_kernel) + if (DPCTL_OFFLOAD_COMPRESS) + target_link_options(${_trgt} PRIVATE --offload-compress) + endif() if(_dpctl_sycl_targets) # make fat binary target_compile_options( diff --git a/dpctl/tensor/CMakeLists.txt b/dpctl/tensor/CMakeLists.txt index e7d3896680..9c53bd8b08 100644 --- a/dpctl/tensor/CMakeLists.txt +++ b/dpctl/tensor/CMakeLists.txt @@ -268,6 +268,10 @@ set(_linker_options "LINKER:${DPCTL_LDFLAGS}") foreach(python_module_name ${_py_trgts}) target_compile_options(${python_module_name} PRIVATE -fno-sycl-id-queries-fit-in-int) target_link_options(${python_module_name} PRIVATE -fsycl-device-code-split=per_kernel) + if (DPCTL_OFFLOAD_COMPRESS) + target_link_options(${python_module_name} PRIVATE --offload-compress) + endif() + target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/libtensor/include @@ -279,7 +283,7 @@ foreach(python_module_name ${_py_trgts}) target_compile_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping ) - endif() + endif() target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping ) diff --git a/dpctl/utils/CMakeLists.txt b/dpctl/utils/CMakeLists.txt index 6d785c8203..a684983c74 100644 --- a/dpctl/utils/CMakeLists.txt +++ b/dpctl/utils/CMakeLists.txt @@ -29,6 +29,10 @@ set(_linker_options "LINKER:${DPCTL_LDFLAGS}") foreach(python_module_name ${_pybind11_targets}) target_compile_options(${python_module_name} PRIVATE -fno-sycl-id-queries-fit-in-int) target_link_options(${python_module_name} PRIVATE -fsycl-device-code-split=per_kernel) + if (DPCTL_OFFLOAD_COMPRESS) + target_link_options(${python_module_name} PRIVATE --offload-compress) + endif() + target_include_directories(${python_module_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/libtensor/include @@ -40,7 +44,7 @@ foreach(python_module_name ${_pybind11_targets}) target_compile_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping ) - endif() + endif() target_link_options(${python_module_name} PRIVATE -fprofile-instr-generate -fcoverage-mapping )