Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions .github/workflows/reusable_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
install_tbb: ['ON']
disable_hwloc: ['OFF']
link_hwloc_statically: ['OFF']
cmake_ver: ['latest']
include:
- os: 'ubuntu-22.04'
build_type: Release
Expand All @@ -36,6 +37,8 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
# check minimum supported cmake version
cmake_ver: '3.14.0'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
Expand All @@ -45,6 +48,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
- os: 'ubuntu-24.04'
build_type: Debug
compiler: {c: gcc, cxx: g++}
Expand All @@ -54,6 +58,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
# test level_zero_provider='OFF' and cuda_provider='OFF'
- os: 'ubuntu-22.04'
build_type: Release
Expand All @@ -64,6 +69,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
# test icx compiler
- os: 'ubuntu-22.04'
build_type: Release
Expand All @@ -74,6 +80,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
# test lld linker
- os: 'ubuntu-24.04'
build_type: Release
Expand All @@ -85,7 +92,8 @@ jobs:
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
llvm_linker: '-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld"'
# test without installing TBB
cmake_ver: 'latest'
# test without installing TBB
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
Expand All @@ -95,6 +103,7 @@ jobs:
install_tbb: 'OFF'
disable_hwloc: 'OFF'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
- os: 'ubuntu-22.04'
build_type: Debug
compiler: {c: gcc, cxx: g++}
Expand All @@ -104,6 +113,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'ON'
link_hwloc_statically: 'OFF'
cmake_ver: 'latest'
- os: 'ubuntu-22.04'
build_type: Release
compiler: {c: gcc, cxx: g++}
Expand All @@ -113,6 +123,7 @@ jobs:
install_tbb: 'ON'
disable_hwloc: 'OFF'
link_hwloc_statically: 'ON'
cmake_ver: 'latest'
runs-on: ${{matrix.os}}

steps:
Expand All @@ -124,7 +135,15 @@ jobs:
- name: Install apt packages
run: |
sudo apt-get update
sudo apt-get install -y clang cmake libnuma-dev lcov
sudo apt-get install -y clang libnuma-dev lcov

- name: Install cmake (minimum supported version)
if: matrix.cmake_ver != 'latest'
run: |
sudo apt-get remove --purge -y cmake
wget https://github.com/Kitware/CMake/releases/download/v${{matrix.cmake_ver}}/cmake-${{matrix.cmake_ver}}-Linux-x86_64.sh
chmod +x cmake-${{matrix.cmake_ver}}-Linux-x86_64.sh
sudo ./cmake-${{matrix.cmake_ver}}-Linux-x86_64.sh --skip-license --prefix=/usr/local

- name: Install hwloc
if: matrix.disable_hwloc == 'OFF'
Expand Down
146 changes: 86 additions & 60 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

message(STATUS "CMake version: ${CMAKE_VERSION}")
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)

# needed when UMF is used as an external project
set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

Expand Down Expand Up @@ -388,58 +390,94 @@ if(hwloc_targ_SOURCE_DIR)
endif()
endif()

# Fetch L0 loader only if needed i.e.: if building L0 provider is ON and L0
# headers are not provided by the user (via setting UMF_LEVEL_ZERO_INCLUDE_DIR).
if(UMF_BUILD_LEVEL_ZERO_PROVIDER AND (NOT UMF_LEVEL_ZERO_INCLUDE_DIR))
set(LEVEL_ZERO_LOADER_REPO "https://github.com/oneapi-src/level-zero.git")
set(LEVEL_ZERO_LOADER_TAG v1.21.9)
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
if(UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES)
# Level Zero loader library is required to build Level Zero GPU tests
# and examples
find_package(ZE_LOADER REQUIRED ze_loader)
else()
find_package(ZE_LOADER COMPONENTS ze_loader)
endif()

message(
STATUS
"Fetching L0 loader (${LEVEL_ZERO_LOADER_TAG}) from ${LEVEL_ZERO_LOADER_REPO} ..."
)
# If the Level Zero headers are not provided by the user and not found in
# the system, we will fetch them from the repo
if(UMF_LEVEL_ZERO_INCLUDE_DIR)
set(LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR})
elseif(ZE_LOADER_INCLUDE_DIR)
set(LEVEL_ZERO_INCLUDE_DIRS ${ZE_LOADER_INCLUDE_DIR})
else()
set(LEVEL_ZERO_LOADER_REPO
"https://github.com/oneapi-src/level-zero.git")
set(LEVEL_ZERO_LOADER_TAG v1.21.9)

message(STATUS "Fetching Level Zero loader (${LEVEL_ZERO_LOADER_TAG}) "
"from ${LEVEL_ZERO_LOADER_REPO} ...")
FetchContent_Declare(
level-zero-loader
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
EXCLUDE_FROM_ALL)
# Only populate the repo - we don't need to build it
FetchContent_Populate(level-zero-loader)

set(LEVEL_ZERO_INCLUDE_DIRS
${level-zero-loader_SOURCE_DIR}/include
CACHE PATH "Path to Level Zero headers")
endif()
message(STATUS "LEVEL_ZERO_INCLUDE_DIRS = ${LEVEL_ZERO_INCLUDE_DIRS}")

FetchContent_Declare(
level-zero-loader
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(level-zero-loader)

set(LEVEL_ZERO_INCLUDE_DIRS
${level-zero-loader_SOURCE_DIR}/include
CACHE PATH "Path to Level Zero Headers")
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
elseif(UMF_BUILD_LEVEL_ZERO_PROVIDER)
# Only header is needed to build UMF
set(LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR})
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
endif()

# Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA
# headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR).
if(UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR))
set(CUDA_REPO
"https://gitlab.com/nvidia/headers/cuda-individual/cudart.git")
set(CUDA_TAG cuda-12.5.1)

message(STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ...")
if(ZE_LOADER_LIBRARIES)
set(UMF_LEVEL_ZERO_ENABLED TRUE)
else()
message(
STATUS
"Disabling tests and examples that use the Level Zero Provider "
"because the Level Zero libraries they require were not found.")
endif()
endif()

FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG}
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(cuda-headers)

set(CUDA_INCLUDE_DIRS
${cuda-headers_SOURCE_DIR}
CACHE PATH "Path to CUDA headers")
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
elseif(UMF_BUILD_CUDA_PROVIDER)
# Only header is needed to build UMF
set(CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR})
if(UMF_BUILD_CUDA_PROVIDER)
if(UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES)
# CUDA library is required to build CUDA GPU tests and examples
find_package(CUDA REQUIRED cuda)
else()
find_package(CUDA COMPONENTS cuda)
endif()

# If the CUDA headers are not provided by the user and not found in the
# system, we will fetch them from the repo
if(UMF_CUDA_INCLUDE_DIR)
set(CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR})
elseif(CUDA_INCLUDE_DIR)
set(CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIR})
else()
set(CUDA_REPO
"https://gitlab.com/nvidia/headers/cuda-individual/cudart.git")
set(CUDA_TAG cuda-12.5.1)

message(
STATUS "Fetching CUDA (${CUDA_TAG}) headers from ${CUDA_REPO} ...")
FetchContent_Declare(
cuda-headers
GIT_REPOSITORY ${CUDA_REPO}
GIT_TAG ${CUDA_TAG}
EXCLUDE_FROM_ALL)
# Only populate the repo - we don't need to build it
FetchContent_Populate(cuda-headers)

set(CUDA_INCLUDE_DIRS
${cuda-headers_SOURCE_DIR}
CACHE PATH "Path to CUDA headers")
endif()
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")

if(CUDA_LIBRARIES)
set(UMF_CUDA_ENABLED TRUE)
else()
message(
STATUS "Disabling tests and examples that use the CUDA Provider "
"because the CUDA libraries they require were not found.")
endif()
endif()

# Build the umfd target in a separate directory with Debug configuration
Expand Down Expand Up @@ -707,18 +745,6 @@ else()
)
endif()

if((UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES) AND UMF_BUILD_CUDA_PROVIDER)
find_package(CUDA REQUIRED cuda)
if(CUDA_LIBRARIES)
set(UMF_CUDA_ENABLED TRUE)
else()
message(
STATUS "Disabling tests and examples that use the CUDA provider "
"because the CUDA libraries they require were not found.")
endif()
# TODO do the same for ze_loader
endif()

add_subdirectory(src)

if(UMF_BUILD_TESTS)
Expand Down
32 changes: 11 additions & 21 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ function(add_umf_benchmark)
LIBS ${BENCH_LIBS})

target_include_directories(
${BENCH_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/src/utils)
${BENCH_NAME}
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
${UMF_CMAKE_SOURCE_DIR}/src/utils
${UMF_CMAKE_SOURCE_DIR}/test/common)

target_link_directories(${BENCH_NAME} PRIVATE ${ARG_LIBDIRS})

Expand All @@ -87,16 +89,6 @@ function(add_umf_benchmark)
set_property(TEST ${BENCH_NAME} PROPERTY ENVIRONMENT_MODIFICATION
"${DLL_PATH_LIST}")
endif()
if(LINUX)
# prepend LD_LIBRARY_PATH with ${CMAKE_BINARY_DIR}/lib it is required
# because ${CMAKE_BINARY_DIR}/lib contains libze_loader.so and tests
# should use it instead of system one.
set_property(
TEST ${BENCH_NAME}
PROPERTY ENVIRONMENT_MODIFICATION
"LD_LIBRARY_PATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib"
)
endif()

if(UMF_POOL_JEMALLOC_ENABLED)
target_compile_definitions(${BENCH_NAME}
Expand All @@ -106,19 +98,16 @@ function(add_umf_benchmark)
target_compile_definitions(${BENCH_NAME}
PRIVATE UMF_POOL_SCALABLE_ENABLED=1)
endif()
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
if(UMF_LEVEL_ZERO_ENABLED)
target_compile_definitions(${BENCH_NAME}
PRIVATE UMF_PROVIDER_LEVEL_ZERO_ENABLED=1)
target_include_directories(
${BENCH_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/test/common
${LEVEL_ZERO_INCLUDE_DIRS})
target_include_directories(${BENCH_NAME}
PRIVATE ${LEVEL_ZERO_INCLUDE_DIRS})
endif()
if(UMF_BUILD_CUDA_PROVIDER)
if(UMF_CUDA_ENABLED)
target_compile_definitions(${BENCH_NAME}
PRIVATE UMF_BUILD_CUDA_PROVIDER=1)
target_include_directories(
${BENCH_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/test/common
${CUDA_INCLUDE_DIRS})
target_include_directories(${BENCH_NAME} PRIVATE ${CUDA_INCLUDE_DIRS})
endif()
if(UMF_BUILD_GPU_TESTS)
target_compile_definitions(${BENCH_NAME} PRIVATE UMF_BUILD_GPU_TESTS=1)
Expand All @@ -131,8 +120,9 @@ set(LIB_DIRS ${LIBHWLOC_LIBRARY_DIRS})
if(LINUX)
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} m)
endif()
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
if(UMF_BUILD_GPU_TESTS AND UMF_LEVEL_ZERO_ENABLED)
set(SRCS_OPTIONAL ${SRCS_OPTIONAL} ../src/utils/utils_level_zero.cpp)
set(LIB_DIRS ${LIB_DIRS} ${ZE_LOADER_LIBRARY_DIRS})
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} ze_loader)
# TODO add CUDA
endif()
Expand Down
6 changes: 5 additions & 1 deletion cmake/FindCUDA.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2024 Intel Corporation
# Copyright (C) 2024-2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

Expand All @@ -7,6 +7,10 @@ message(STATUS "Checking for module 'cuda' using find_library()")
find_library(CUDA_LIBRARY NAMES libcuda cuda)
set(CUDA_LIBRARIES ${CUDA_LIBRARY})

find_file(CUDA_HEADER NAMES "cuda.h")
get_filename_component(CUDA_INCLUDE_DIR ${CUDA_HEADER} DIRECTORY)
set(CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIR})

get_filename_component(CUDA_LIB_DIR ${CUDA_LIBRARIES} DIRECTORY)
set(CUDA_LIBRARY_DIRS ${CUDA_LIB_DIR})

Expand Down
39 changes: 39 additions & 0 deletions cmake/FindZE_LOADER.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright (C) 2025 Intel Corporation
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

message(STATUS "Checking for module 'ze_loader' using find_library()")

find_library(ZE_LOADER_LIBRARY NAMES libze_loader ze_loader)
set(ZE_LOADER_LIBRARIES ${ZE_LOADER_LIBRARY})

find_file(ZE_LOADER_HEADER NAMES "ze_api.h" "level_zero/ze_api.h")
get_filename_component(ZE_LOADER_INCLUDE_DIR ${ZE_LOADER_HEADER} DIRECTORY)
set(ZE_LOADER_INCLUDE_DIRS ${ZE_LOADER_INCLUDE_DIR})

get_filename_component(ZE_LOADER_LIB_DIR ${ZE_LOADER_LIBRARIES} DIRECTORY)
set(ZE_LOADER_LIBRARY_DIRS ${ZE_LOADER_LIB_DIR})

if(WINDOWS)
find_file(ZE_LOADER_DLL NAMES "ze_loader.dll")
get_filename_component(ZE_LOADER_DLL_DIR ${ZE_LOADER_DLL} DIRECTORY)
set(ZE_LOADER_DLL_DIRS ${ZE_LOADER_DLL_DIR})
endif()

if(ZE_LOADER_LIBRARY)
message(STATUS " Found ZE_LOADER using find_library()")
message(STATUS " ZE_LOADER_LIBRARIES = ${ZE_LOADER_LIBRARIES}")
message(STATUS " ZE_LOADER_INCLUDE_DIRS = ${ZE_LOADER_INCLUDE_DIRS}")
message(STATUS " ZE_LOADER_LIBRARY_DIRS = ${ZE_LOADER_LIBRARY_DIRS}")
if(WINDOWS)
message(STATUS " ZE_LOADER_DLL_DIRS = ${ZE_LOADER_DLL_DIRS}")
endif()
else()
set(MSG_NOT_FOUND "ZE_LOADER NOT found (set CMAKE_PREFIX_PATH to point the "
"location)")
if(ZE_LOADER_FIND_REQUIRED)
message(FATAL_ERROR ${MSG_NOT_FOUND})
else()
message(WARNING ${MSG_NOT_FOUND})
endif()
endif()
Loading