Skip to content

Commit 1360515

Browse files
committed
Compute-benchmarks use already compiled UR
1 parent 7f1332e commit 1360515

File tree

13 files changed

+56
-23
lines changed

13 files changed

+56
-23
lines changed

.github/workflows/benchmarks_compute.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,20 +152,31 @@ jobs:
152152
run: cmake --build ${{github.workspace}}/sycl_build -j
153153

154154
- name: Configure UR
155-
working-directory: ${{github.workspace}}/ur-repo
156155
run: >
157156
cmake -DCMAKE_BUILD_TYPE=Release
158-
-B${{github.workspace}}/ur-repo/build
157+
-S${{github.workspace}}/ur-repo
158+
-B${{github.workspace}}/ur_build
159+
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/ur_install
159160
-DUR_BUILD_TESTS=OFF
160161
-DUR_BUILD_ADAPTER_L0=ON
161162
-DUR_BUILD_ADAPTER_L0_V2=ON
163+
-DUMF_DISABLE_HWLOC=ON
162164
163165
- name: Build UR
164-
run: cmake --build ${{github.workspace}}/ur-repo/build -j $(nproc)
166+
run: cmake --build ${{github.workspace}}/ur_build -j $(nproc)
167+
168+
- name: Install UR
169+
run: cmake --install ${{github.workspace}}/ur_build
165170

166171
- name: Run benchmarks
167172
id: benchmarks
168-
run: numactl -N 0 ${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py ~/bench_workdir ${{github.workspace}}/sycl_build ${{github.workspace}}/ur-repo ${{ matrix.adapter.str_name }} ${{ inputs.bench_script_params }}
173+
run: >
174+
numactl -N 0 ${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py
175+
~/bench_workdir
176+
${{github.workspace}}/sycl_build
177+
${{github.workspace}}/ur_install
178+
${{ matrix.adapter.str_name }}
179+
${{ inputs.bench_script_params }}
169180
170181
- name: Add comment to PR
171182
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1

cmake/helpers.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ function(add_ur_library name)
139139
endif()
140140
endfunction()
141141

142+
function(install_ur_library name)
143+
install(TARGETS ${name}
144+
EXPORT ${PROJECT_NAME}-targets
145+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
146+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
147+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT unified-runtime
148+
)
149+
endfunction()
150+
142151
include(FetchContent)
143152

144153
function(FetchSource GIT_REPOSITORY GIT_TAG GIT_DIR DEST)

scripts/benchmarks/benches/base.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,27 @@
1515
class Benchmark:
1616
def __init__(self, directory):
1717
self.directory = directory
18-
self.adapter_path = os.path.join(options.ur_dir, 'build', 'lib', f"libur_adapter_{options.ur_adapter_name}.so")
18+
19+
@staticmethod
20+
def get_adapter_full_path():
21+
for libs_dir_name in ['lib', 'lib64']:
22+
adapter_path = os.path.join(
23+
options.ur_dir, libs_dir_name, f"libur_adapter_{options.ur_adapter_name}.so")
24+
if os.path.isfile(adapter_path):
25+
return adapter_path
26+
assert False, \
27+
f"could not find adapter file {adapter_path} (and in similar lib paths)"
1928

2029
def run_bench(self, command, env_vars):
2130
env_vars_with_forced_adapter = env_vars.copy()
22-
env_vars_with_forced_adapter.update({'UR_ADAPTERS_FORCE_LOAD': self.adapter_path})
23-
return run(command=command, env_vars=env_vars_with_forced_adapter, add_sycl=True, cwd=options.benchmark_cwd).stdout.decode()
31+
env_vars_with_forced_adapter.update(
32+
{'UR_ADAPTERS_FORCE_LOAD': Benchmark.get_adapter_full_path()})
33+
return run(
34+
command=command,
35+
env_vars=env_vars_with_forced_adapter,
36+
add_sycl=True,
37+
cwd=options.benchmark_cwd
38+
).stdout.decode()
2439

2540
def create_data_path(self, name):
2641
data_path = os.path.join(self.directory, "data", name)

scripts/benchmarks/benches/compute.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ class ComputeBench:
1515
def __init__(self, directory):
1616
self.directory = directory
1717
self.built = False
18-
return
1918

2019
def setup(self):
2120
if self.built:
2221
return
2322

24-
repo_path = git_clone(self.directory, "compute-benchmarks-repo", "https://github.com/intel/compute-benchmarks.git", "08c41bb8bc1762ad53c6194df6d36bfcceff4aa2")
23+
repo_path = git_clone(self.directory, "compute-benchmarks-repo", "https://github.com/intel/compute-benchmarks.git", "f6882552215736f90295244046fcb6e17fe53e83")
2524
build_path = create_build_path(self.directory, 'compute-benchmarks-build')
2625

2726
configure_command = [
@@ -33,10 +32,7 @@ def setup(self):
3332
f"-DSYCL_COMPILER_ROOT={options.sycl}",
3433
f"-DALLOW_WARNINGS=ON",
3534
f"-DBUILD_UR=ON",
36-
f"-DUR_BUILD_TESTS=OFF",
37-
f"-DUR_BUILD_TESTS=OFF",
38-
f"-DUMF_DISABLE_HWLOC=ON",
39-
f"-DBENCHMARK_UR_SOURCE_DIR={options.ur_dir}",
35+
f"-Dunified-runtime_DIR={options.ur_dir}/lib/cmake/unified-runtime",
4036
]
4137
run(configure_command, add_sycl=True)
4238

scripts/benchmarks/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def validate_and_parse_env_args(env_args):
177177
parser = argparse.ArgumentParser(description='Unified Runtime Benchmark Runner')
178178
parser.add_argument('benchmark_directory', type=str, help='Working directory to setup benchmarks.')
179179
parser.add_argument('sycl', type=str, help='Root directory of the SYCL compiler.')
180-
parser.add_argument('ur_dir', type=str, help='Root directory of the UR.')
180+
parser.add_argument('ur_dir', type=str, help='UR install prefix path')
181181
parser.add_argument('ur_adapter_name', type=str, help='Options to build the Unified Runtime as part of the benchmark')
182182
parser.add_argument("--no-rebuild", help='Rebuild the benchmarks from scratch.', action="store_true")
183183
parser.add_argument("--env", type=str, help='Use env variable for a benchmark run.', action="append", default=[])

scripts/benchmarks/utils/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def git_clone(dir, name, repo, commit):
4242

4343
if os.path.isdir(repo_path) and os.path.isdir(os.path.join(repo_path, '.git')):
4444
run("git fetch", cwd=repo_path)
45+
run("git reset --hard", cwd=repo_path)
4546
run(f"git checkout {commit}", cwd=repo_path)
4647
elif not os.path.exists(repo_path):
4748
run(f"git clone --recursive {repo} {repo_path}")

source/adapters/cuda/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ add_ur_adapter(${TARGET_NAME}
4545
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
4646
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
4747
)
48+
install_ur_library(${TARGET_NAME})
4849

4950
set_target_properties(${TARGET_NAME} PROPERTIES
5051
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
@@ -100,7 +101,7 @@ if (UR_ENABLE_TRACING)
100101
XPTI_ENABLE_INSTRUMENTATION
101102
XPTI_STATIC_LIBRARY
102103
)
103-
target_include_directories(${TARGET_NAME} PUBLIC
104+
target_include_directories(${TARGET_NAME} PRIVATE
104105
${XPTI_INCLUDES}
105106
${CUDA_CUPTI_INCLUDE_DIR}
106107
)

source/adapters/hip/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ add_ur_adapter(${TARGET_NAME}
9292
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
9393
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
9494
)
95+
install_ur_library(${TARGET_NAME})
9596

9697
if(NOT MSVC)
9798
target_compile_options(${TARGET_NAME} PRIVATE

source/adapters/level_zero/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,15 @@ if(UR_BUILD_ADAPTER_L0)
140140
${CMAKE_CURRENT_SOURCE_DIR}/helpers/memory_helpers.cpp
141141
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
142142
)
143+
install_ur_library(ur_adapter_level_zero)
143144

144145
if(UR_STATIC_ADAPTER_L0)
145146
target_compile_definitions(ur_adapter_level_zero PUBLIC UR_STATIC_ADAPTER_LEVEL_ZERO)
146147

147148
# 'utils' target from 'level-zero-loader' includes path which is prefixed
148149
# in the source directory, this breaks the installation of 'utils' target.
149150
set_target_properties(utils PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
150-
install(TARGETS ur_adapter_level_zero ur_umf LevelZeroLoader LevelZeroLoader-Headers ze_loader utils
151+
install(TARGETS ur_umf LevelZeroLoader LevelZeroLoader-Headers ze_loader utils
151152
EXPORT ${PROJECT_NAME}-targets
152153
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
153154
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
@@ -240,6 +241,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
240241
${CMAKE_CURRENT_SOURCE_DIR}/v2/queue_immediate_in_order.cpp
241242
${CMAKE_CURRENT_SOURCE_DIR}/v2/usm.cpp
242243
)
244+
install_ur_library(ur_adapter_level_zero_v2)
243245

244246
if(NOT WIN32)
245247
# api.cpp contains NOT_SUPPORTED functions-only

source/adapters/native_cpu/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ add_ur_adapter(${TARGET_NAME}
4141
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
4242
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
4343
)
44+
install_ur_library(${TARGET_NAME})
4445

4546
set_target_properties(${TARGET_NAME} PROPERTIES
4647
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"

0 commit comments

Comments
 (0)