From 5f70c5cb0cb2645928cafe46196a8c8a83a9ef98 Mon Sep 17 00:00:00 2001 From: Yevhenii Havrylko Date: Tue, 7 Nov 2023 15:53:44 -0500 Subject: [PATCH] Switch to sycl compiler --- .github/workflows/coverage.yml | 2 +- conda-recipe/bld.bat | 14 ++++++++++++++ conda-recipe/build.sh | 13 +++++++++++++ numba_dpex/core/runtime/CMakeLists.txt | 15 +++++++++++++-- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d615760451..ea42f32b1d 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -38,7 +38,7 @@ jobs: - name: Build numba-dpex run: | export PATH=$CONDA/bin-llvm:$PATH - python setup.py develop + CC=icx CXX=icpx python setup.py develop - name: Test installation run: | diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat index a649d5da31..33741e024b 100644 --- a/conda-recipe/bld.bat +++ b/conda-recipe/bld.bat @@ -3,6 +3,20 @@ @REM used BUILD_PREFIX as compiler installed in build section of meta.yml set "PATH=%BUILD_PREFIX%\Library\bin-llvm;%PATH%" +REM A workaround for activate-dpcpp.bat issue to be addressed in 2021.4 +set "LIB=%BUILD_PREFIX%\Library\lib;%BUILD_PREFIX%\compiler\lib;%LIB%" +SET "INCLUDE=%BUILD_PREFIX%\include;%INCLUDE%" + +REM Since the 60.0.0 release, setuptools includes a local, vendored copy +REM of distutils (from late copies of CPython) that is enabled by default. +REM It breaks build for Windows, so use distutils from "stdlib" as before. +REM @TODO: remove the setting, once transition to build backend on Windows +REM to cmake is complete. +SET "SETUPTOOLS_USE_DISTUTILS=stdlib" + +set "CC=icx" +set "CXX=icx" + set "SKBUILD_ARGS=-G Ninja --" set "SKBUILD_ARGS=%SKBUILD_ARGS% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh index cba34794c4..84833176a4 100644 --- a/conda-recipe/build.sh +++ b/conda-recipe/build.sh @@ -2,6 +2,19 @@ set -euxo pipefail +# Intel LLVM must cooperate with compiler and sysroot from conda +export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:${BUILD_PREFIX}/lib" + +echo "--gcc-toolchain=${BUILD_PREFIX} --sysroot=${BUILD_PREFIX}/${HOST}/sysroot -target ${HOST}" > icpx_for_conda.cfg +ICPXCFG="$(pwd)/icpx_for_conda.cfg" +ICXCFG="$(pwd)/icpx_for_conda.cfg" + +export ICXCFG +export ICPXCFG + +export CC=icx +export CXX=icpx + # new llvm-spirv location # starting from dpcpp_impl_linux-64=2022.0.0=intel_3610 export PATH=$CONDA_PREFIX/bin-llvm:$PATH diff --git a/numba_dpex/core/runtime/CMakeLists.txt b/numba_dpex/core/runtime/CMakeLists.txt index 674cc03db6..3d00278fcb 100644 --- a/numba_dpex/core/runtime/CMakeLists.txt +++ b/numba_dpex/core/runtime/CMakeLists.txt @@ -24,6 +24,10 @@ project(_dpexrt_python DESCRIPTION "A Python C extension for numba-dpex runtime." ) +# Help conda build find path from both host and build env. +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) + # Get numba include path if(NOT DEFINED Numba_INCLUDE_DIRS) execute_process( @@ -79,9 +83,10 @@ message(STATUS "CMAKE_MODULE_PATH=" "${CMAKE_MODULE_PATH}") # Add packages find_package(Python 3.9 REQUIRED - COMPONENTS Interpreter Development.Module NumPy) + COMPONENTS Interpreter Development.Module) find_package(Dpctl REQUIRED) find_package(NumPy REQUIRED) +find_package(IntelSYCL REQUIRED) # Includes include(GNUInstallDirs) @@ -92,7 +97,9 @@ include_directories(${Dpctl_INCLUDE_DIRS}) include_directories(.) # Source files, *.c -file(GLOB SOURCES "*.c") +file(GLOB_RECURSE DPEXRT_SOURCES CONFIGURE_DEPENDS "*.c") +file(GLOB_RECURSE KERNEL_SOURCES CONFIGURE_DEPENDS "*.cpp") +set(SOURCES ${DPEXRT_SOURCES} ${KERNEL_SOURCES}) # Link dpctl library path with -L link_directories(${DPCTL_LIBRARY_PATH}) @@ -100,6 +107,10 @@ link_directories(${DPCTL_LIBRARY_PATH}) # Output static library, *.so or *.dll python_add_library(${PROJECT_NAME} MODULE ${SOURCES}) +# Add SYCL to target, this must come after python_add_library() +# FIXME: sources incompatible with sycl include? +# add_sycl_to_target(TARGET ${PROJECT_NAME} SOURCES ${KERNEL_SOURCES}) + # Link the DPCTLSyclInterface library to target target_link_libraries(${PROJECT_NAME} PRIVATE DPCTLSyclInterface)