diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 4ecf9da2f84d4..f722f35ad1be3 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -83,7 +83,7 @@ if(MSVC) endif() include(FetchEmhash) -include(FetchUnifiedRuntime) +include(BuildUnifiedRuntime) # The change in SYCL_MAJOR_VERSION must be accompanied with the same update in # llvm/clang/lib/Driver/CMakeLists.txt. diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/BuildUnifiedRuntime.cmake similarity index 61% rename from sycl/cmake/modules/FetchUnifiedRuntime.cmake rename to sycl/cmake/modules/BuildUnifiedRuntime.cmake index cca4b209cebaa..3196202dda660 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/BuildUnifiedRuntime.cmake @@ -1,5 +1,4 @@ -# Either fetches UR from the appropriate repo or sets up variables based on user -# preference. +# Builds in-tree UR # TODO: taken from sycl/plugins/CMakeLists.txt - maybe we should handle this # within UR (although it is an obscure warning that the build system here @@ -9,20 +8,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|IntelLLVM" ) endif() -# Options to override the default behaviour of the FetchContent to include UR -# source code. -set(SYCL_UR_OVERRIDE_FETCH_CONTENT_REPO - "" CACHE STRING "Override the Unified Runtime FetchContent repository") -set(SYCL_UR_OVERRIDE_FETCH_CONTENT_TAG - "" CACHE STRING "Override the Unified Runtime FetchContent tag") - -# Options to disable use of FetchContent to include Unified Runtime source code -# to improve developer workflow. -option(SYCL_UR_USE_FETCH_CONTENT - "Use FetchContent to acquire the Unified Runtime source code" ON) -set(SYCL_UR_SOURCE_DIR - "" CACHE PATH "Path to root of Unified Runtime repository") - option(SYCL_UR_BUILD_TESTS "Build tests for UR" OFF) set(UR_BUILD_TESTS "${SYCL_UR_BUILD_TESTS}" CACHE BOOL "" FORCE) # UR tests require the examples to be built @@ -80,154 +65,26 @@ endif() set(UR_INTREE_SOURCE_DIR "${LLVM_SOURCE_DIR}/../unified-runtime") cmake_path(NORMAL_PATH UR_INTREE_SOURCE_DIR OUTPUT_VARIABLE UR_INTREE_SOURCE_DIR) -if(IS_DIRECTORY "${UR_INTREE_SOURCE_DIR}") - set(UR_INTREE_BINARY_DIR ${LLVM_BINARY_DIR}/unified-runtime) - set(UNIFIED_RUNTIME_SOURCE_DIR - "${UR_INTREE_SOURCE_DIR}" CACHE PATH - "Path to Unified Runtime Headers" FORCE) - set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") - # Due to the use of dependentloadflag and no installer for UMF and hwloc we need - # to link statically on windows - if(WIN32) - set(UMF_BUILD_SHARED_LIBRARY OFF CACHE INTERNAL "Build UMF shared library") - set(UMF_LINK_HWLOC_STATICALLY ON CACHE INTERNAL "static HWLOC") - endif() - add_subdirectory(${UNIFIED_RUNTIME_SOURCE_DIR} ${UR_INTREE_BINARY_DIR}) -elseif(SYCL_UR_USE_FETCH_CONTENT) - include(FetchContent) - - # The fetch_adapter_source function can be used to perform a separate content - # fetch for a UR adapter (backend), this allows development of adapters to be decoupled - # from each other. - # - # A separate content fetch will not be performed if: - # * The adapter name is not present in the SYCL_ENABLE_BACKENDS variable. - # * The repo and tag provided match the values of the - # UNIFIED_RUNTIME_REPO/UNIFIED_RUNTIME_TAG variables - # - # Args: - # * name - Must be the directory name of the adapter - # * repo - A valid Git URL of a Unified Runtime repo - # * tag - A valid Git branch/tag/commit in the Unified Runtime repo - function(fetch_adapter_source name repo tag) - if(NOT ${name} IN_LIST SYCL_ENABLE_BACKENDS) - return() - endif() - if(repo STREQUAL UNIFIED_RUNTIME_REPO AND - tag STREQUAL UNIFIED_RUNTIME_TAG) - # If the adapter sources are taken from the main checkout, reset the - # adapter specific source path. - string(TOUPPER ${name} NAME) - set(UR_ADAPTER_${NAME}_SOURCE_DIR "" - CACHE PATH "Path to external '${name}' adapter source dir" FORCE) - return() - endif() - message(STATUS - "Will fetch Unified Runtime ${name} adapter from ${repo} at ${tag}") - set(fetch-name ur-${name}) - FetchContent_Declare(${fetch-name} - GIT_REPOSITORY ${repo} GIT_TAG ${tag}) - # We don't want to add this repo to the build, only fetch its source. - FetchContent_Populate(${fetch-name}) - # Get the path to the source directory - string(TOUPPER ${name} NAME) - set(source_dir_var UR_ADAPTER_${NAME}_SOURCE_DIR) - FetchContent_GetProperties(${fetch-name} SOURCE_DIR UR_ADAPTER_${NAME}_SOURCE_DIR) - # Set the variable which informs UR where to get the adapter source from. - set(UR_ADAPTER_${NAME}_SOURCE_DIR - "${UR_ADAPTER_${NAME}_SOURCE_DIR}/source/adapters/${name}" - CACHE PATH "Path to external '${name}' adapter source dir" FORCE) - endfunction() - - set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git") - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UnifiedRuntimeTag.cmake) - - set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") - # Due to the use of dependentloadflag and no installer for UMF and hwloc we need - # to link statically on windows - if(WIN32) - set(UMF_BUILD_SHARED_LIBRARY OFF CACHE INTERNAL "Build UMF shared library") - set(UMF_LINK_HWLOC_STATICALLY ON CACHE INTERNAL "static HWLOC") - endif() - - fetch_adapter_source(level_zero - ${UNIFIED_RUNTIME_REPO} - ${UNIFIED_RUNTIME_TAG} - ) - - fetch_adapter_source(opencl - ${UNIFIED_RUNTIME_REPO} - ${UNIFIED_RUNTIME_TAG} - ) - - fetch_adapter_source(cuda - ${UNIFIED_RUNTIME_REPO} - ${UNIFIED_RUNTIME_TAG} - ) - - fetch_adapter_source(hip - ${UNIFIED_RUNTIME_REPO} - ${UNIFIED_RUNTIME_TAG} - ) - - fetch_adapter_source(native_cpu - ${UNIFIED_RUNTIME_REPO} - ${UNIFIED_RUNTIME_TAG} - ) - - if(SYCL_UR_OVERRIDE_FETCH_CONTENT_REPO) - set(UNIFIED_RUNTIME_REPO "${SYCL_UR_OVERRIDE_FETCH_CONTENT_REPO}") - endif() - if(SYCL_UR_OVERRIDE_FETCH_CONTENT_TAG) - set(UNIFIED_RUNTIME_TAG "${SYCL_UR_OVERRIDE_FETCH_CONTENT_TAG}") - endif() - - message(STATUS "Will fetch Unified Runtime from ${UNIFIED_RUNTIME_REPO}") - FetchContent_Declare(unified-runtime - GIT_REPOSITORY ${UNIFIED_RUNTIME_REPO} - GIT_TAG ${UNIFIED_RUNTIME_TAG} - ) +if(NOT IS_DIRECTORY "${UR_INTREE_SOURCE_DIR}") + message(FATAL_ERROR "unified-runtime folder not found at repo root") +endif() - FetchContent_GetProperties(unified-runtime) - FetchContent_MakeAvailable(unified-runtime) - - set(UNIFIED_RUNTIME_SOURCE_DIR - "${unified-runtime_SOURCE_DIR}" CACHE PATH - "Path to Unified Runtime Headers" FORCE) -elseif(SYCL_UR_SOURCE_DIR) - # SYCL_UR_USE_FETCH_CONTENT is OFF and SYCL_UR_SOURCE_DIR has been set, - # use the external Unified Runtime source directory. - set(UNIFIED_RUNTIME_SOURCE_DIR - "${SYCL_UR_SOURCE_DIR}" CACHE PATH - "Path to Unified Runtime Headers" FORCE) - add_subdirectory( - ${UNIFIED_RUNTIME_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/unified-runtime) -else() - # SYCL_UR_USE_FETCH_CONTENT is OFF and SYCL_UR_SOURCE_DIR has not been - # set, check if the fallback local directory exists. - if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/unified-runtime) - message(FATAL_ERROR - "SYCL_UR_USE_FETCH_CONTENT is disabled but no alternative Unified \ - Runtime source directory has been provided, either: - - * Set -DSYCL_UR_SOURCE_DIR=/path/to/unified-runtime - * Clone the UR repo in ${CMAKE_CURRENT_SOURCE_DIR}/unified-runtime") - endif() - # The fallback local directory for the Unified Runtime repository has been - # found, use it. - set(UNIFIED_RUNTIME_SOURCE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/unified-runtime" CACHE PATH - "Path to Unified Runtime Headers" FORCE) - add_subdirectory(${UNIFIED_RUNTIME_SOURCE_DIR}) +set(UR_INTREE_BINARY_DIR ${LLVM_BINARY_DIR}/unified-runtime) +set(UNIFIED_RUNTIME_SOURCE_DIR + "${UR_INTREE_SOURCE_DIR}" CACHE PATH + "Path to Unified Runtime Headers" FORCE) +set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES") +# Due to the use of dependentloadflag and no installer for UMF and hwloc we need +# to link statically on windows +if(WIN32) + set(UMF_BUILD_SHARED_LIBRARY OFF CACHE INTERNAL "Build UMF shared library") + set(UMF_LINK_HWLOC_STATICALLY ON CACHE INTERNAL "static HWLOC") endif() +add_subdirectory(${UNIFIED_RUNTIME_SOURCE_DIR} ${UR_INTREE_BINARY_DIR}) # Restore original flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_BAK}") -message(STATUS - "Using Unified Runtime source directory: ${UNIFIED_RUNTIME_SOURCE_DIR}") - set(UNIFIED_RUNTIME_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR}/include") set(UNIFIED_RUNTIME_SRC_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR}/source") set(UNIFIED_RUNTIME_COMMON_INCLUDE_DIR "${UNIFIED_RUNTIME_SOURCE_DIR}/source/common") diff --git a/sycl/cmake/modules/UnifiedRuntimeTag.cmake b/sycl/cmake/modules/UnifiedRuntimeTag.cmake deleted file mode 100644 index 62720fd524b37..0000000000000 --- a/sycl/cmake/modules/UnifiedRuntimeTag.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# commit d03f19a88e42cb98be9604ff24b61190d1e48727 -# Merge: 3ce6fcc9 84454b0e -# Author: Kenneth Benzie (Benie) -# Date: Thu Feb 13 11:43:34 2025 +0000 -# Merge pull request #2680 from ldorau/Set_UMF_CUDA_INCLUDE_DIR_to_not_fetch_cudart_from_gitlab -# Do not fetch cudart from gitlab for UMF -set(UNIFIED_RUNTIME_TAG d03f19a88e42cb98be9604ff24b61190d1e48727) diff --git a/sycl/doc/GetStartedGuide.md b/sycl/doc/GetStartedGuide.md index e5eb7b154f6d1..2b171fa0a82f0 100644 --- a/sycl/doc/GetStartedGuide.md +++ b/sycl/doc/GetStartedGuide.md @@ -14,7 +14,6 @@ and a wide range of compute accelerators such as GPU and FPGA. * [Build DPC++ toolchain with support for HIP NVIDIA](#build-dpc-toolchain-with-support-for-hip-nvidia) * [Build DPC++ toolchain with support for ARM processors](#build-dpc-toolchain-with-support-for-arm-processors) * [Build DPC++ toolchain with additional features enabled that require runtime/JIT compilation](#build-dpc-toolchain-with-additional-features-enabled-that-require-runtimejit-compilation) - * [Build DPC++ toolchain with a custom Unified Runtime](#build-dpc-toolchain-with-a-custom-unified-runtime) * [Build DPC++ toolchain with device image compression support](#build-dpc-toolchain-with-device-image-compression-support) * [Build Doxygen documentation](#build-doxygen-documentation) * [Deployment](#deployment) @@ -369,36 +368,6 @@ After CMake cache is generated, build the documentation with `doxygen-sycl` target. It will be put to `$DPCPP_HOME/llvm/build/tools/sycl/doc/html` directory. -### Build DPC++ toolchain with a custom Unified Runtime - -DPC++ uses the [Unified Runtime](https://github.com/oneapi-src/unified-runtime) -under the hood to provide implementations of various SYCL backends. By default -the source code for the Unified Runtime will be acquired using CMake's -[FetchCotent](https://cmake.org/cmake/help/latest/module/FetchContent.html). The -specific repository URL and revision tag used can be found in the file -`sycl/cmake/modules/FetchUnifiedRuntime.cmake` searching for the variables -`UNIFIED_RUNTIME_REPO` and `UNIFIED_RUNTIME_TAG`. - -In order to enable developers, a number of CMake variables are available to -control which revision of Unified Runtime should be used when building DPC++: - -* `SYCL_UR_OVERRIDE_FETCH_CONTENT_REPO` is a variable which can be used to - override the `UNIFIED_RUNTIME_REPO` variable used by `FetchContent` to attain - the Unified Runtime source code. -* `SYCL_UR_OVERRIDE_FETCH_CONTENT_TAG` is a variable which can be used to - override the `UNIFIED_RUNTIME_TAG` variable used by `FetchContent` to attain - the Unified Runtime source code. -* `SYCL_UR_USE_FETCH_CONTENT` is an option to control if CMake should use - `FetchContent` to pull in the Unified Runtime repository, it defaults to `ON`. - When set to `OFF`, `FetchContent` will not be used, instead: - * The path specified by variable `SYCL_UR_SOURCE_DIR` will be used with - `add_directory()`. This can be used to point at an adjacent directory - containing a clone of the Unified Runtime repository. - * The path `sycl/unified-runtime` will be used, if it - exists. This can be used as-if an in-tree build. -* `SYCL_UR_SOURCE_DIR` is a variable used to specify the path to the Unified - Runtime repository when `SYCL_UR_USE_FETCH_CONTENT` is set of `OFF`. - ### Build DPC++ libclc with a custom toolchain libclc is an implementation of the OpenCL required libraries, as described in