From 664b7a1ca6eb28955f45e101f74b77105f360697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Chor=C4=85=C5=BCewicz?= Date: Fri, 15 Mar 2024 17:41:06 -0700 Subject: [PATCH] Remove UMF from ur::common and make a separate ur_umf interface library. This way, components that do not require UMF (e.g. loader) do not need to link with it. --- source/adapters/cuda/CMakeLists.txt | 1 + source/adapters/hip/CMakeLists.txt | 2 ++ source/adapters/level_zero/CMakeLists.txt | 1 + source/adapters/native_cpu/CMakeLists.txt | 1 + source/adapters/opencl/CMakeLists.txt | 1 + source/common/CMakeLists.txt | 20 ++++++++++++++------ test/usm/CMakeLists.txt | 1 + 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/source/adapters/cuda/CMakeLists.txt b/source/adapters/cuda/CMakeLists.txt index 0a4fbb67ad..9384a591f8 100644 --- a/source/adapters/cuda/CMakeLists.txt +++ b/source/adapters/cuda/CMakeLists.txt @@ -77,6 +77,7 @@ endif() target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::umf Threads::Threads cudadrv ) diff --git a/source/adapters/hip/CMakeLists.txt b/source/adapters/hip/CMakeLists.txt index 764cfeedf9..f769267c5a 100644 --- a/source/adapters/hip/CMakeLists.txt +++ b/source/adapters/hip/CMakeLists.txt @@ -139,6 +139,7 @@ if("${UR_HIP_PLATFORM}" STREQUAL "AMD") target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::umf rocmdrv ) @@ -173,6 +174,7 @@ elseif("${UR_HIP_PLATFORM}" STREQUAL "NVIDIA") target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::umf Threads::Threads cudadrv cudart diff --git a/source/adapters/level_zero/CMakeLists.txt b/source/adapters/level_zero/CMakeLists.txt index d26d0aeb26..9c53153b76 100644 --- a/source/adapters/level_zero/CMakeLists.txt +++ b/source/adapters/level_zero/CMakeLists.txt @@ -147,6 +147,7 @@ endif() target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::umf LevelZeroLoader LevelZeroLoader-Headers ) diff --git a/source/adapters/native_cpu/CMakeLists.txt b/source/adapters/native_cpu/CMakeLists.txt index 87391ac615..dbe480592b 100644 --- a/source/adapters/native_cpu/CMakeLists.txt +++ b/source/adapters/native_cpu/CMakeLists.txt @@ -52,6 +52,7 @@ find_package(Threads REQUIRED) target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::umf Threads::Threads ) diff --git a/source/adapters/opencl/CMakeLists.txt b/source/adapters/opencl/CMakeLists.txt index 38f8e9a523..aad94a9129 100644 --- a/source/adapters/opencl/CMakeLists.txt +++ b/source/adapters/opencl/CMakeLists.txt @@ -95,6 +95,7 @@ target_include_directories(${TARGET_NAME} PRIVATE target_link_libraries(${TARGET_NAME} PRIVATE ${PROJECT_NAME}::headers ${PROJECT_NAME}::common + ${PROJECT_NAME}::umf Threads::Threads ${OpenCLICDLoaderLibrary} ) diff --git a/source/common/CMakeLists.txt b/source/common/CMakeLists.txt index ba1aa07bb7..27745ac39b 100644 --- a/source/common/CMakeLists.txt +++ b/source/common/CMakeLists.txt @@ -4,9 +4,6 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception add_ur_library(ur_common STATIC - umf_helpers.hpp - umf_pools/disjoint_pool_config_parser.cpp - ur_pool_manager.hpp ur_util.cpp ur_util.hpp $<$:windows/ur_lib_loader.cpp> @@ -51,9 +48,6 @@ FetchContent_MakeAvailable(unified-memory-framework) FetchContent_GetProperties(unified-memory-framework) target_link_libraries(ur_common PUBLIC - unified-memory-framework::umf - unified-memory-framework::headers - unified-memory-framework::disjoint_pool ${CMAKE_DL_LIBS} ${PROJECT_NAME}::headers ) @@ -64,3 +58,17 @@ if (UNIX) find_package(Threads REQUIRED) target_link_libraries(ur_common PUBLIC Threads::Threads) endif() + +add_library(ur_umf INTERFACE + umf_helpers.hpp + umf_pools/disjoint_pool_config_parser.cpp + ur_pool_manager.hpp +) + +add_library(${PROJECT_NAME}::umf ALIAS ur_umf) + +target_link_libraries(ur_umf INTERFACE + unified-memory-framework::umf + unified-memory-framework::headers + unified-memory-framework::disjoint_pool +) diff --git a/test/usm/CMakeLists.txt b/test/usm/CMakeLists.txt index 3496328ce9..6916452373 100644 --- a/test/usm/CMakeLists.txt +++ b/test/usm/CMakeLists.txt @@ -15,6 +15,7 @@ function(add_usm_test name) PRIVATE ${PROJECT_NAME}::common ${PROJECT_NAME}::loader + ${PROJECT_NAME}::umf ur_testing GTest::gtest_main) add_test(NAME usm-${name}