Skip to content

Commit f57617a

Browse files
committed
Adapt project to work on windows with L0 and GPU
1 parent 92f3cd6 commit f57617a

File tree

12 files changed

+152
-229
lines changed

12 files changed

+152
-229
lines changed

.github/workflows/gpu.yml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,65 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
# TODO: add support for tests on Windows
1312
gpu:
1413
name: Build
14+
env:
15+
BUILD_TYPE: Release
1516
# run only on upstream; forks will not have the HW
1617
if: github.repository == 'oneapi-src/unified-memory-framework'
1718

1819
strategy:
20+
fail-fast: false
1921
matrix:
20-
build_type: [Release]
21-
compiler: [{c: gcc, cxx: g++}]
2222
shared_library: ['ON', 'OFF']
23-
# TODO enable testing on DSS-WINDOWS
24-
runs-on: [ "DSS-LEVEL_ZERO", "DSS-UBUNTU" ]
23+
os: ['Ubuntu', 'Windows']
24+
include:
25+
- os: 'Ubuntu'
26+
compiler: {c: gcc, cxx: g++}
27+
number_of_processors: '$(nproc)'
28+
- os: 'Windows'
29+
compiler: {c: cl, cxx: cl}
30+
number_of_processors: '$Env:NUMBER_OF_PROCESSORS'
31+
extra_arg: "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Administrator/repo/vcpkg/scripts/buildsystems/vcpkg.cmake"
32+
33+
runs-on: ["DSS-LEVEL_ZERO", "DSS-${{matrix.os}}"]
2534

26-
steps:
2735
- name: Checkout
2836
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2937

3038
- name: Get information about platform
39+
if: matrix.os == 'Ubuntu'
3140
run: .github/scripts/get_system_info.sh
32-
41+
3342
- name: Configure build
3443
run: >
3544
cmake
3645
-B ${{github.workspace}}/build
37-
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
46+
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
3847
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
3948
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
4049
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
4150
-DUMF_BUILD_BENCHMARKS=ON
4251
-DUMF_BUILD_TESTS=ON
4352
-DUMF_BUILD_GPU_TESTS=ON
4453
-DUMF_BUILD_GPU_EXAMPLES=ON
45-
-DUMF_FORMAT_CODE_STYLE=ON
54+
-DUMF_FORMAT_CODE_STYLE=OFF
4655
-DUMF_DEVELOPER_MODE=ON
4756
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
57+
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
58+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
4859
-DUMF_ENABLE_POOL_TRACKING=ON
60+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
61+
${{matrix.extra_arg}}
4962
5063
- name: Build UMF
51-
run: cmake --build ${{github.workspace}}/build -j $(nproc)
64+
run: >
65+
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j ${{matrix.number_of_processors}}
5266
5367
- name: Run tests
5468
working-directory: ${{github.workspace}}/build
55-
run: ctest --output-on-failure --test-dir test
69+
run: ctest -C ${{env.build_type}} --output-on-failure --test-dir test
5670

5771
- name: Run examples
5872
working-directory: ${{github.workspace}}/build
59-
run: ctest --output-on-failure --test-dir examples -C ${{matrix.build_type}}
60-
73+
run: ctest --output-on-failure --test-dir examples -C ${{env.BUILD_TYPE}}

.github/workflows/pr_push.yml

Lines changed: 22 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -11,159 +11,28 @@ permissions:
1111
contents: read
1212

1313
jobs:
14-
FastBuild:
15-
name: Fast build
16-
env:
17-
VCPKG_PATH: "${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows"
18-
strategy:
19-
matrix:
20-
include:
21-
- os: windows-latest
22-
disjoint: 'OFF'
23-
build_tests: 'ON'
24-
# pure C build (Windows)
25-
- os: windows-latest
26-
disjoint: 'OFF'
27-
# Tests' building is off for a pure C build
28-
build_tests: 'OFF'
29-
- os: ubuntu-latest
30-
disjoint: 'ON'
31-
build_tests: 'ON'
32-
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
33-
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON -DUMF_BUILD_BENCHMARKS_MT=ON'
34-
# pure C build (Linux)
35-
- os: ubuntu-latest
36-
disjoint: 'OFF'
37-
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command
38-
# Tests' building is off for a pure C build
39-
build_tests: 'OFF'
40-
extra_build_options: '-DCMAKE_BUILD_TYPE=Release -DUMF_BUILD_BENCHMARKS=ON'
41-
runs-on: ${{matrix.os}}
4214

43-
steps:
44-
- name: Checkout repository
45-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
46-
47-
- name: Initialize vcpkg
48-
if: matrix.os == 'windows-latest'
49-
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
50-
with:
51-
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
52-
vcpkgDirectory: ${{github.workspace}}/build/vcpkg
53-
vcpkgJsonGlob: '**/vcpkg.json'
54-
55-
- name: Install dependencies
56-
if: matrix.os == 'windows-latest'
57-
run: vcpkg install
58-
shell: pwsh # Specifies PowerShell as the shell for running the script.
59-
60-
- name: Install apt packages
61-
if: matrix.os == 'ubuntu-latest'
62-
run: |
63-
sudo apt-get update
64-
sudo apt-get install -y cmake libjemalloc-dev libhwloc-dev libnuma-dev libtbb-dev
65-
66-
- name: Configure CMake
67-
run: >
68-
cmake
69-
-B ${{github.workspace}}/build
70-
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
71-
-DUMF_FORMAT_CODE_STYLE=OFF
72-
-DUMF_DEVELOPER_MODE=ON
73-
-DUMF_ENABLE_POOL_TRACKING=ON
74-
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=ON
75-
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=${{matrix.disjoint}}
76-
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
77-
-DUMF_BUILD_TESTS=${{matrix.build_tests}}
78-
-DUMF_BUILD_EXAMPLES=ON
79-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
80-
${{matrix.extra_build_options}}
81-
82-
- name: Build
83-
run: cmake --build ${{github.workspace}}/build --config Release -j
84-
85-
- name: Run examples
86-
working-directory: ${{github.workspace}}/build
87-
run: ctest --output-on-failure --test-dir examples -C Release
88-
89-
- name: Run tests
90-
if: matrix.build_tests == 'ON'
91-
working-directory: ${{github.workspace}}/build
92-
run: ctest --output-on-failure --test-dir test -C Release
93-
94-
CodeStyle:
95-
name: Coding style
96-
runs-on: ubuntu-latest
97-
98-
steps:
99-
- name: Checkout repository
100-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
101-
102-
- name: Install apt packages
103-
run: |
104-
sudo apt-get update
105-
sudo apt-get install -y black cmake clang-format-15 cmake-format libhwloc-dev
106-
107-
- name: Configure CMake
108-
run: >
109-
cmake
110-
-B ${{github.workspace}}/build
111-
-DUMF_FORMAT_CODE_STYLE=ON
112-
-DUMF_BUILD_TESTS=OFF
113-
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
114-
-DUMF_BUILD_LIBUMF_POOL_SCALABLE=OFF
115-
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=OFF
116-
117-
- name: Check C/C++ formatting
118-
run: cmake --build build --target clang-format-check
119-
120-
- name: Check CMake formatting
121-
run: cmake --build build --target cmake-format-check
122-
123-
- name: Check Python formatting
124-
run: cmake --build build --target black-format-check
125-
126-
DocsBuild:
127-
name: Build docs
128-
runs-on: ubuntu-latest
129-
130-
steps:
131-
- name: Checkout repository
132-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
133-
134-
- name: Install doxygen
135-
run: |
136-
sudo apt-get update
137-
sudo apt-get install -y doxygen
138-
139-
- name: Install pip requirements
140-
run: python3 -m pip install -r third_party/requirements.txt
141-
142-
- name: Build the documentation
143-
working-directory: scripts
144-
run: python3 generate_docs.py
145-
146-
Spellcheck:
147-
uses: ./.github/workflows/spellcheck.yml
148-
Build:
149-
name: Basic builds
150-
needs: [Spellcheck, FastBuild, CodeStyle]
151-
uses: ./.github/workflows/basic.yml
152-
Sanitizers:
153-
needs: [Spellcheck, FastBuild, CodeStyle]
154-
uses: ./.github/workflows/sanitizers.yml
155-
Benchmarks:
156-
needs: [Build]
157-
uses: ./.github/workflows/benchmarks.yml
158-
ProxyLib:
159-
needs: [Build]
160-
uses: ./.github/workflows/proxy_lib.yml
15+
#Spellcheck:
16+
# uses: ./.github/workflows/spellcheck.yml
17+
#Build:
18+
# name: Basic builds
19+
# needs: [Spellcheck, FastBuild, CodeStyle]
20+
# uses: ./.github/workflows/basic.yml
21+
#Sanitizers:
22+
# needs: [Spellcheck, FastBuild, CodeStyle]
23+
# uses: ./.github/workflows/sanitizers.yml
24+
#Benchmarks:
25+
# needs: [Build]
26+
# uses: ./.github/workflows/benchmarks.yml
27+
#ProxyLib:
28+
# needs: [Build]
29+
# uses: ./.github/workflows/proxy_lib.yml
16130
GPU:
162-
needs: [Build]
31+
# needs: [Build]
16332
uses: ./.github/workflows/gpu.yml
164-
Qemu:
165-
needs: [Build]
166-
uses: ./.github/workflows/qemu.yml
167-
Valgrind:
168-
needs: [Build]
169-
uses: ./.github/workflows/valgrind.yml
33+
#Qemu:
34+
# needs: [Build]
35+
# uses: ./.github/workflows/qemu.yml
36+
#Valgrind:
37+
# needs: [Build]
38+
# uses: ./.github/workflows/valgrind.yml

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ if(UMF_BUILD_EXAMPLES)
254254
add_subdirectory(examples)
255255
endif()
256256

257+
# Conditional configuration for Level Zero provider
258+
if(UMF_BUILD_LEVEL_ZERO_PROVIDER)
259+
set(OPTIONAL_SYMBOLS "umfLevelZeroMemoryProviderOps")
260+
else()
261+
set(OPTIONAL_SYMBOLS "")
262+
endif()
263+
264+
# Configure the DEF file based on whether Level Zero provider is built
265+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/libumf.def.in"
266+
"${CMAKE_CURRENT_BINARY_DIR}/src/libumf.def" @ONLY)
267+
257268
if(UMF_FORMAT_CODE_STYLE)
258269
find_program(CLANG_FORMAT NAMES clang-format-15 clang-format-15.0
259270
clang-format)

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ A memory provider that provides memory from an operating system.
143143
Required packages for tests (Linux-only yet):
144144
- libnuma-dev
145145

146-
#### Level Zero memory provider (Linux-only yet)
146+
#### Level Zero memory provider
147147

148148
A memory provider that provides memory from L0 device.
149149

@@ -154,11 +154,10 @@ A memory provider that provides memory from L0 device.
154154

155155
Additionally, required for tests:
156156

157-
3) Linux OS
158-
4) The `UMF_BUILD_GPU_TESTS` option turned `ON`
159-
5) System with Level Zero compatible GPU
160-
6) Required packages:
161-
- liblevel-zero-dev
157+
3) The `UMF_BUILD_GPU_TESTS` option turned `ON`
158+
4) System with Level Zero compatible GPU
159+
5) Required packages:
160+
- liblevel-zero-dev (Linux) or level-zero-sdk (Windows)
162161

163162
### Memory pool managers
164163

examples/basic/utils_level_zero.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
#include <stdio.h>
1111
#include <stdlib.h>
1212

13-
#include <level_zero/ze_api.h>
13+
#ifdef _WIN32
14+
#include <ze_api.h>
15+
#else
16+
#include <level_zero/ze_api.h>
17+
#endif
1418

1519
static int init_level_zero() {
1620
ze_init_flag_t flags = ZE_INIT_FLAG_GPU_ONLY;

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ if(UMF_BUILD_SHARED_LIBRARY)
106106
SRCS ${UMF_SOURCES}
107107
LIBS ${UMF_LIBS}
108108
LINUX_MAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libumf.map
109-
WINDOWS_DEF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libumf.def)
109+
WINDOWS_DEF_FILE ${CMAKE_CURRENT_BINARY_DIR}/libumf.def)
110110
set(UMF_PRIVATE_COMPILE_DEFINITIONS ${UMF_PRIVATE_COMPILE_DEFINITIONS}
111111
"UMF_SHARED_LIBRARY")
112112
set_target_properties(umf PROPERTIES RUNTIME_OUTPUT_DIRECTORY

src/libumf.def renamed to src/libumf.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ EXPORTS
4949
umfProxyPoolOps
5050
umfPutIPCHandle
5151
umfOsMemoryProviderOps
52+
@OPTIONAL_SYMBOLS@

src/pool/pool_scalable.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,21 +115,22 @@ static int init_tbb_callbacks(tbb_callbacks_t *tbb_callbacks) {
115115
}
116116

117117
*(void **)&tbb_callbacks->pool_malloc = util_get_symbol_addr(
118-
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_MALLOC]);
118+
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_MALLOC], lib_name);
119119
*(void **)&tbb_callbacks->pool_realloc = util_get_symbol_addr(
120-
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_REALLOC]);
121-
*(void **)&tbb_callbacks->pool_aligned_malloc = util_get_symbol_addr(
122-
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_ALIGNED_MALLOC]);
120+
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_REALLOC], lib_name);
121+
*(void **)&tbb_callbacks->pool_aligned_malloc =
122+
util_get_symbol_addr(tbb_callbacks->lib_handle,
123+
tbb_symbol[TBB_POOL_ALIGNED_MALLOC], lib_name);
123124
*(void **)&tbb_callbacks->pool_free = util_get_symbol_addr(
124-
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_FREE]);
125+
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_FREE], lib_name);
125126
*(void **)&tbb_callbacks->pool_create_v1 = util_get_symbol_addr(
126-
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_CREATE_V1]);
127+
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_CREATE_V1], lib_name);
127128
*(void **)&tbb_callbacks->pool_destroy = util_get_symbol_addr(
128-
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_DESTROY]);
129+
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_DESTROY], lib_name);
129130
*(void **)&tbb_callbacks->pool_identify = util_get_symbol_addr(
130-
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_IDENTIFY]);
131+
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_IDENTIFY], lib_name);
131132
*(void **)&tbb_callbacks->pool_msize = util_get_symbol_addr(
132-
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_MSIZE]);
133+
tbb_callbacks->lib_handle, tbb_symbol[TBB_POOL_MSIZE], lib_name);
133134

134135
if (!tbb_callbacks->pool_malloc || !tbb_callbacks->pool_realloc ||
135136
!tbb_callbacks->pool_aligned_malloc || !tbb_callbacks->pool_free ||

0 commit comments

Comments
 (0)