Skip to content

Commit 0c09d06

Browse files
authored
Merge pull request #1285 from bratpiorka/rrudnick_fix_ze_install
do not install libze_loader
2 parents a622dc7 + a0eb6cb commit 0c09d06

File tree

12 files changed

+269
-221
lines changed

12 files changed

+269
-221
lines changed

.github/workflows/reusable_basic.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
install_tbb: ['ON']
2727
disable_hwloc: ['OFF']
2828
link_hwloc_statically: ['OFF']
29+
cmake_ver: ['latest']
2930
include:
3031
- os: 'ubuntu-22.04'
3132
build_type: Release
@@ -36,6 +37,8 @@ jobs:
3637
install_tbb: 'ON'
3738
disable_hwloc: 'OFF'
3839
link_hwloc_statically: 'OFF'
40+
# check minimum supported cmake version
41+
cmake_ver: '3.14.0'
3942
- os: 'ubuntu-22.04'
4043
build_type: Release
4144
compiler: {c: gcc, cxx: g++}
@@ -45,6 +48,7 @@ jobs:
4548
install_tbb: 'ON'
4649
disable_hwloc: 'OFF'
4750
link_hwloc_statically: 'OFF'
51+
cmake_ver: 'latest'
4852
- os: 'ubuntu-24.04'
4953
build_type: Debug
5054
compiler: {c: gcc, cxx: g++}
@@ -54,6 +58,7 @@ jobs:
5458
install_tbb: 'ON'
5559
disable_hwloc: 'OFF'
5660
link_hwloc_statically: 'OFF'
61+
cmake_ver: 'latest'
5762
# test level_zero_provider='OFF' and cuda_provider='OFF'
5863
- os: 'ubuntu-22.04'
5964
build_type: Release
@@ -64,6 +69,7 @@ jobs:
6469
install_tbb: 'ON'
6570
disable_hwloc: 'OFF'
6671
link_hwloc_statically: 'OFF'
72+
cmake_ver: 'latest'
6773
# test icx compiler
6874
- os: 'ubuntu-22.04'
6975
build_type: Release
@@ -74,6 +80,7 @@ jobs:
7480
install_tbb: 'ON'
7581
disable_hwloc: 'OFF'
7682
link_hwloc_statically: 'OFF'
83+
cmake_ver: 'latest'
7784
# test lld linker
7885
- os: 'ubuntu-24.04'
7986
build_type: Release
@@ -85,7 +92,8 @@ jobs:
8592
disable_hwloc: 'OFF'
8693
link_hwloc_statically: 'OFF'
8794
llvm_linker: '-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_MODULE_LINKER_FLAGS="-fuse-ld=lld" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=lld"'
88-
# test without installing TBB
95+
cmake_ver: 'latest'
96+
# test without installing TBB
8997
- os: 'ubuntu-22.04'
9098
build_type: Release
9199
compiler: {c: gcc, cxx: g++}
@@ -95,6 +103,7 @@ jobs:
95103
install_tbb: 'OFF'
96104
disable_hwloc: 'OFF'
97105
link_hwloc_statically: 'OFF'
106+
cmake_ver: 'latest'
98107
- os: 'ubuntu-22.04'
99108
build_type: Debug
100109
compiler: {c: gcc, cxx: g++}
@@ -104,6 +113,7 @@ jobs:
104113
install_tbb: 'ON'
105114
disable_hwloc: 'ON'
106115
link_hwloc_statically: 'OFF'
116+
cmake_ver: 'latest'
107117
- os: 'ubuntu-22.04'
108118
build_type: Release
109119
compiler: {c: gcc, cxx: g++}
@@ -113,6 +123,7 @@ jobs:
113123
install_tbb: 'ON'
114124
disable_hwloc: 'OFF'
115125
link_hwloc_statically: 'ON'
126+
cmake_ver: 'latest'
116127
runs-on: ${{matrix.os}}
117128

118129
steps:
@@ -124,7 +135,15 @@ jobs:
124135
- name: Install apt packages
125136
run: |
126137
sudo apt-get update
127-
sudo apt-get install -y clang cmake libnuma-dev lcov
138+
sudo apt-get install -y clang libnuma-dev lcov
139+
140+
- name: Install cmake (minimum supported version)
141+
if: matrix.cmake_ver != 'latest'
142+
run: |
143+
sudo apt-get remove --purge -y cmake
144+
wget https://github.com/Kitware/CMake/releases/download/v${{matrix.cmake_ver}}/cmake-${{matrix.cmake_ver}}-Linux-x86_64.sh
145+
chmod +x cmake-${{matrix.cmake_ver}}-Linux-x86_64.sh
146+
sudo ./cmake-${{matrix.cmake_ver}}-Linux-x86_64.sh --skip-license --prefix=/usr/local
128147
129148
- name: Install hwloc
130149
if: matrix.disable_hwloc == 'OFF'

CMakeLists.txt

Lines changed: 86 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

5+
message(STATUS "CMake version: ${CMAKE_VERSION}")
56
cmake_minimum_required(VERSION 3.14.0 FATAL_ERROR)
7+
68
# needed when UMF is used as an external project
79
set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
810

@@ -388,58 +390,94 @@ if(hwloc_targ_SOURCE_DIR)
388390
endif()
389391
endif()
390392

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

397-
message(
398-
STATUS
399-
"Fetching L0 loader (${LEVEL_ZERO_LOADER_TAG}) from ${LEVEL_ZERO_LOADER_REPO} ..."
400-
)
402+
# If the Level Zero headers are not provided by the user and not found in
403+
# the system, we will fetch them from the repo
404+
if(UMF_LEVEL_ZERO_INCLUDE_DIR)
405+
set(LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR})
406+
elseif(ZE_LOADER_INCLUDE_DIR)
407+
set(LEVEL_ZERO_INCLUDE_DIRS ${ZE_LOADER_INCLUDE_DIR})
408+
else()
409+
set(LEVEL_ZERO_LOADER_REPO
410+
"https://github.com/oneapi-src/level-zero.git")
411+
set(LEVEL_ZERO_LOADER_TAG v1.21.9)
412+
413+
message(STATUS "Fetching Level Zero loader (${LEVEL_ZERO_LOADER_TAG}) "
414+
"from ${LEVEL_ZERO_LOADER_REPO} ...")
415+
FetchContent_Declare(
416+
level-zero-loader
417+
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
418+
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
419+
EXCLUDE_FROM_ALL)
420+
# Only populate the repo - we don't need to build it
421+
FetchContent_Populate(level-zero-loader)
422+
423+
set(LEVEL_ZERO_INCLUDE_DIRS
424+
${level-zero-loader_SOURCE_DIR}/include
425+
CACHE PATH "Path to Level Zero headers")
426+
endif()
427+
message(STATUS "LEVEL_ZERO_INCLUDE_DIRS = ${LEVEL_ZERO_INCLUDE_DIRS}")
401428

402-
FetchContent_Declare(
403-
level-zero-loader
404-
GIT_REPOSITORY ${LEVEL_ZERO_LOADER_REPO}
405-
GIT_TAG ${LEVEL_ZERO_LOADER_TAG}
406-
EXCLUDE_FROM_ALL)
407-
FetchContent_MakeAvailable(level-zero-loader)
408-
409-
set(LEVEL_ZERO_INCLUDE_DIRS
410-
${level-zero-loader_SOURCE_DIR}/include
411-
CACHE PATH "Path to Level Zero Headers")
412-
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
413-
elseif(UMF_BUILD_LEVEL_ZERO_PROVIDER)
414-
# Only header is needed to build UMF
415-
set(LEVEL_ZERO_INCLUDE_DIRS ${UMF_LEVEL_ZERO_INCLUDE_DIR})
416-
message(STATUS "Level Zero include directory: ${LEVEL_ZERO_INCLUDE_DIRS}")
417-
endif()
418-
419-
# Fetch CUDA only if needed i.e.: if building CUDA provider is ON and CUDA
420-
# headers are not provided by the user (via setting UMF_CUDA_INCLUDE_DIR).
421-
if(UMF_BUILD_CUDA_PROVIDER AND (NOT UMF_CUDA_INCLUDE_DIR))
422-
set(CUDA_REPO
423-
"https://gitlab.com/nvidia/headers/cuda-individual/cudart.git")
424-
set(CUDA_TAG cuda-12.5.1)
425-
426-
message(STATUS "Fetching CUDA ${CUDA_TAG} from ${CUDA_REPO} ...")
429+
if(ZE_LOADER_LIBRARIES)
430+
set(UMF_LEVEL_ZERO_ENABLED TRUE)
431+
else()
432+
message(
433+
STATUS
434+
"Disabling tests and examples that use the Level Zero Provider "
435+
"because the Level Zero libraries they require were not found.")
436+
endif()
437+
endif()
427438

428-
FetchContent_Declare(
429-
cuda-headers
430-
GIT_REPOSITORY ${CUDA_REPO}
431-
GIT_TAG ${CUDA_TAG}
432-
EXCLUDE_FROM_ALL)
433-
FetchContent_MakeAvailable(cuda-headers)
434-
435-
set(CUDA_INCLUDE_DIRS
436-
${cuda-headers_SOURCE_DIR}
437-
CACHE PATH "Path to CUDA headers")
438-
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
439-
elseif(UMF_BUILD_CUDA_PROVIDER)
440-
# Only header is needed to build UMF
441-
set(CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR})
439+
if(UMF_BUILD_CUDA_PROVIDER)
440+
if(UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES)
441+
# CUDA library is required to build CUDA GPU tests and examples
442+
find_package(CUDA REQUIRED cuda)
443+
else()
444+
find_package(CUDA COMPONENTS cuda)
445+
endif()
446+
447+
# If the CUDA headers are not provided by the user and not found in the
448+
# system, we will fetch them from the repo
449+
if(UMF_CUDA_INCLUDE_DIR)
450+
set(CUDA_INCLUDE_DIRS ${UMF_CUDA_INCLUDE_DIR})
451+
elseif(CUDA_INCLUDE_DIR)
452+
set(CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIR})
453+
else()
454+
set(CUDA_REPO
455+
"https://gitlab.com/nvidia/headers/cuda-individual/cudart.git")
456+
set(CUDA_TAG cuda-12.5.1)
457+
458+
message(
459+
STATUS "Fetching CUDA (${CUDA_TAG}) headers from ${CUDA_REPO} ...")
460+
FetchContent_Declare(
461+
cuda-headers
462+
GIT_REPOSITORY ${CUDA_REPO}
463+
GIT_TAG ${CUDA_TAG}
464+
EXCLUDE_FROM_ALL)
465+
# Only populate the repo - we don't need to build it
466+
FetchContent_Populate(cuda-headers)
467+
468+
set(CUDA_INCLUDE_DIRS
469+
${cuda-headers_SOURCE_DIR}
470+
CACHE PATH "Path to CUDA headers")
471+
endif()
442472
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
473+
474+
if(CUDA_LIBRARIES)
475+
set(UMF_CUDA_ENABLED TRUE)
476+
else()
477+
message(
478+
STATUS "Disabling tests and examples that use the CUDA Provider "
479+
"because the CUDA libraries they require were not found.")
480+
endif()
443481
endif()
444482

445483
# Build the umfd target in a separate directory with Debug configuration
@@ -707,18 +745,6 @@ else()
707745
)
708746
endif()
709747

710-
if((UMF_BUILD_GPU_TESTS OR UMF_BUILD_GPU_EXAMPLES) AND UMF_BUILD_CUDA_PROVIDER)
711-
find_package(CUDA REQUIRED cuda)
712-
if(CUDA_LIBRARIES)
713-
set(UMF_CUDA_ENABLED TRUE)
714-
else()
715-
message(
716-
STATUS "Disabling tests and examples that use the CUDA provider "
717-
"because the CUDA libraries they require were not found.")
718-
endif()
719-
# TODO do the same for ze_loader
720-
endif()
721-
722748
add_subdirectory(src)
723749

724750
if(UMF_BUILD_TESTS)

benchmark/CMakeLists.txt

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ function(add_umf_benchmark)
6060
LIBS ${BENCH_LIBS})
6161

6262
target_include_directories(
63-
${BENCH_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
64-
${UMF_CMAKE_SOURCE_DIR}/src/utils)
63+
${BENCH_NAME}
64+
PRIVATE ${UMF_CMAKE_SOURCE_DIR}/include
65+
${UMF_CMAKE_SOURCE_DIR}/src/utils
66+
${UMF_CMAKE_SOURCE_DIR}/test/common)
6567

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

@@ -87,16 +89,6 @@ function(add_umf_benchmark)
8789
set_property(TEST ${BENCH_NAME} PROPERTY ENVIRONMENT_MODIFICATION
8890
"${DLL_PATH_LIST}")
8991
endif()
90-
if(LINUX)
91-
# prepend LD_LIBRARY_PATH with ${CMAKE_BINARY_DIR}/lib it is required
92-
# because ${CMAKE_BINARY_DIR}/lib contains libze_loader.so and tests
93-
# should use it instead of system one.
94-
set_property(
95-
TEST ${BENCH_NAME}
96-
PROPERTY ENVIRONMENT_MODIFICATION
97-
"LD_LIBRARY_PATH=path_list_prepend:${CMAKE_BINARY_DIR}/lib"
98-
)
99-
endif()
10092

10193
if(UMF_POOL_JEMALLOC_ENABLED)
10294
target_compile_definitions(${BENCH_NAME}
@@ -106,19 +98,16 @@ function(add_umf_benchmark)
10698
target_compile_definitions(${BENCH_NAME}
10799
PRIVATE UMF_POOL_SCALABLE_ENABLED=1)
108100
endif()
109-
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
101+
if(UMF_LEVEL_ZERO_ENABLED)
110102
target_compile_definitions(${BENCH_NAME}
111103
PRIVATE UMF_PROVIDER_LEVEL_ZERO_ENABLED=1)
112-
target_include_directories(
113-
${BENCH_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/test/common
114-
${LEVEL_ZERO_INCLUDE_DIRS})
104+
target_include_directories(${BENCH_NAME}
105+
PRIVATE ${LEVEL_ZERO_INCLUDE_DIRS})
115106
endif()
116-
if(UMF_BUILD_CUDA_PROVIDER)
107+
if(UMF_CUDA_ENABLED)
117108
target_compile_definitions(${BENCH_NAME}
118109
PRIVATE UMF_BUILD_CUDA_PROVIDER=1)
119-
target_include_directories(
120-
${BENCH_NAME} PRIVATE ${UMF_CMAKE_SOURCE_DIR}/test/common
121-
${CUDA_INCLUDE_DIRS})
110+
target_include_directories(${BENCH_NAME} PRIVATE ${CUDA_INCLUDE_DIRS})
122111
endif()
123112
if(UMF_BUILD_GPU_TESTS)
124113
target_compile_definitions(${BENCH_NAME} PRIVATE UMF_BUILD_GPU_TESTS=1)
@@ -131,8 +120,9 @@ set(LIB_DIRS ${LIBHWLOC_LIBRARY_DIRS})
131120
if(LINUX)
132121
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} m)
133122
endif()
134-
if(UMF_BUILD_GPU_TESTS AND UMF_BUILD_LEVEL_ZERO_PROVIDER)
123+
if(UMF_BUILD_GPU_TESTS AND UMF_LEVEL_ZERO_ENABLED)
135124
set(SRCS_OPTIONAL ${SRCS_OPTIONAL} ../src/utils/utils_level_zero.cpp)
125+
set(LIB_DIRS ${LIB_DIRS} ${ZE_LOADER_LIBRARY_DIRS})
136126
set(LIBS_OPTIONAL ${LIBS_OPTIONAL} ze_loader)
137127
# TODO add CUDA
138128
endif()

cmake/FindCUDA.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2024 Intel Corporation
1+
# Copyright (C) 2024-2025 Intel Corporation
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

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

10+
find_file(CUDA_HEADER NAMES "cuda.h")
11+
get_filename_component(CUDA_INCLUDE_DIR ${CUDA_HEADER} DIRECTORY)
12+
set(CUDA_INCLUDE_DIRS ${CUDA_INCLUDE_DIR})
13+
1014
get_filename_component(CUDA_LIB_DIR ${CUDA_LIBRARIES} DIRECTORY)
1115
set(CUDA_LIBRARY_DIRS ${CUDA_LIB_DIR})
1216

cmake/FindZE_LOADER.cmake

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright (C) 2025 Intel Corporation
2+
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
5+
message(STATUS "Checking for module 'ze_loader' using find_library()")
6+
7+
find_library(ZE_LOADER_LIBRARY NAMES libze_loader ze_loader)
8+
set(ZE_LOADER_LIBRARIES ${ZE_LOADER_LIBRARY})
9+
10+
find_file(ZE_LOADER_HEADER NAMES "ze_api.h" "level_zero/ze_api.h")
11+
get_filename_component(ZE_LOADER_INCLUDE_DIR ${ZE_LOADER_HEADER} DIRECTORY)
12+
set(ZE_LOADER_INCLUDE_DIRS ${ZE_LOADER_INCLUDE_DIR})
13+
14+
get_filename_component(ZE_LOADER_LIB_DIR ${ZE_LOADER_LIBRARIES} DIRECTORY)
15+
set(ZE_LOADER_LIBRARY_DIRS ${ZE_LOADER_LIB_DIR})
16+
17+
if(WINDOWS)
18+
find_file(ZE_LOADER_DLL NAMES "ze_loader.dll")
19+
get_filename_component(ZE_LOADER_DLL_DIR ${ZE_LOADER_DLL} DIRECTORY)
20+
set(ZE_LOADER_DLL_DIRS ${ZE_LOADER_DLL_DIR})
21+
endif()
22+
23+
if(ZE_LOADER_LIBRARY)
24+
message(STATUS " Found ZE_LOADER using find_library()")
25+
message(STATUS " ZE_LOADER_LIBRARIES = ${ZE_LOADER_LIBRARIES}")
26+
message(STATUS " ZE_LOADER_INCLUDE_DIRS = ${ZE_LOADER_INCLUDE_DIRS}")
27+
message(STATUS " ZE_LOADER_LIBRARY_DIRS = ${ZE_LOADER_LIBRARY_DIRS}")
28+
if(WINDOWS)
29+
message(STATUS " ZE_LOADER_DLL_DIRS = ${ZE_LOADER_DLL_DIRS}")
30+
endif()
31+
else()
32+
set(MSG_NOT_FOUND "ZE_LOADER NOT found (set CMAKE_PREFIX_PATH to point the "
33+
"location)")
34+
if(ZE_LOADER_FIND_REQUIRED)
35+
message(FATAL_ERROR ${MSG_NOT_FOUND})
36+
else()
37+
message(WARNING ${MSG_NOT_FOUND})
38+
endif()
39+
endif()

0 commit comments

Comments
 (0)