Skip to content

Commit

Permalink
Compute-benchmarks use already compiled UR
Browse files Browse the repository at this point in the history
  • Loading branch information
lslusarczyk committed Oct 3, 2024
1 parent 7f1332e commit 1360515
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 23 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/benchmarks_compute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,31 @@ jobs:
run: cmake --build ${{github.workspace}}/sycl_build -j

- name: Configure UR
working-directory: ${{github.workspace}}/ur-repo
run: >
cmake -DCMAKE_BUILD_TYPE=Release
-B${{github.workspace}}/ur-repo/build
-S${{github.workspace}}/ur-repo
-B${{github.workspace}}/ur_build
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/ur_install
-DUR_BUILD_TESTS=OFF
-DUR_BUILD_ADAPTER_L0=ON
-DUR_BUILD_ADAPTER_L0_V2=ON
-DUMF_DISABLE_HWLOC=ON
- name: Build UR
run: cmake --build ${{github.workspace}}/ur-repo/build -j $(nproc)
run: cmake --build ${{github.workspace}}/ur_build -j $(nproc)

- name: Install UR
run: cmake --install ${{github.workspace}}/ur_build

- name: Run benchmarks
id: benchmarks
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 }}
run: >
numactl -N 0 ${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py
~/bench_workdir
${{github.workspace}}/sycl_build
${{github.workspace}}/ur_install
${{ matrix.adapter.str_name }}
${{ inputs.bench_script_params }}
- name: Add comment to PR
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand Down
9 changes: 9 additions & 0 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ function(add_ur_library name)
endif()
endfunction()

function(install_ur_library name)
install(TARGETS ${name}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT unified-runtime
)
endfunction()

include(FetchContent)

function(FetchSource GIT_REPOSITORY GIT_TAG GIT_DIR DEST)
Expand Down
21 changes: 18 additions & 3 deletions scripts/benchmarks/benches/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,27 @@
class Benchmark:
def __init__(self, directory):
self.directory = directory
self.adapter_path = os.path.join(options.ur_dir, 'build', 'lib', f"libur_adapter_{options.ur_adapter_name}.so")

@staticmethod
def get_adapter_full_path():
for libs_dir_name in ['lib', 'lib64']:
adapter_path = os.path.join(
options.ur_dir, libs_dir_name, f"libur_adapter_{options.ur_adapter_name}.so")
if os.path.isfile(adapter_path):
return adapter_path
assert False, \
f"could not find adapter file {adapter_path} (and in similar lib paths)"

def run_bench(self, command, env_vars):
env_vars_with_forced_adapter = env_vars.copy()
env_vars_with_forced_adapter.update({'UR_ADAPTERS_FORCE_LOAD': self.adapter_path})
return run(command=command, env_vars=env_vars_with_forced_adapter, add_sycl=True, cwd=options.benchmark_cwd).stdout.decode()
env_vars_with_forced_adapter.update(
{'UR_ADAPTERS_FORCE_LOAD': Benchmark.get_adapter_full_path()})
return run(
command=command,
env_vars=env_vars_with_forced_adapter,
add_sycl=True,
cwd=options.benchmark_cwd
).stdout.decode()

def create_data_path(self, name):
data_path = os.path.join(self.directory, "data", name)
Expand Down
8 changes: 2 additions & 6 deletions scripts/benchmarks/benches/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ class ComputeBench:
def __init__(self, directory):
self.directory = directory
self.built = False
return

def setup(self):
if self.built:
return

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

configure_command = [
Expand All @@ -33,10 +32,7 @@ def setup(self):
f"-DSYCL_COMPILER_ROOT={options.sycl}",
f"-DALLOW_WARNINGS=ON",
f"-DBUILD_UR=ON",
f"-DUR_BUILD_TESTS=OFF",
f"-DUR_BUILD_TESTS=OFF",
f"-DUMF_DISABLE_HWLOC=ON",
f"-DBENCHMARK_UR_SOURCE_DIR={options.ur_dir}",
f"-Dunified-runtime_DIR={options.ur_dir}/lib/cmake/unified-runtime",
]
run(configure_command, add_sycl=True)

Expand Down
2 changes: 1 addition & 1 deletion scripts/benchmarks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def validate_and_parse_env_args(env_args):
parser = argparse.ArgumentParser(description='Unified Runtime Benchmark Runner')
parser.add_argument('benchmark_directory', type=str, help='Working directory to setup benchmarks.')
parser.add_argument('sycl', type=str, help='Root directory of the SYCL compiler.')
parser.add_argument('ur_dir', type=str, help='Root directory of the UR.')
parser.add_argument('ur_dir', type=str, help='UR install prefix path')
parser.add_argument('ur_adapter_name', type=str, help='Options to build the Unified Runtime as part of the benchmark')
parser.add_argument("--no-rebuild", help='Rebuild the benchmarks from scratch.', action="store_true")
parser.add_argument("--env", type=str, help='Use env variable for a benchmark run.', action="append", default=[])
Expand Down
1 change: 1 addition & 0 deletions scripts/benchmarks/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def git_clone(dir, name, repo, commit):

if os.path.isdir(repo_path) and os.path.isdir(os.path.join(repo_path, '.git')):
run("git fetch", cwd=repo_path)
run("git reset --hard", cwd=repo_path)
run(f"git checkout {commit}", cwd=repo_path)
elif not os.path.exists(repo_path):
run(f"git clone --recursive {repo} {repo_path}")
Expand Down
3 changes: 2 additions & 1 deletion source/adapters/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_ur_adapter(${TARGET_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
)
install_ur_library(${TARGET_NAME})

set_target_properties(${TARGET_NAME} PROPERTIES
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
Expand Down Expand Up @@ -100,7 +101,7 @@ if (UR_ENABLE_TRACING)
XPTI_ENABLE_INSTRUMENTATION
XPTI_STATIC_LIBRARY
)
target_include_directories(${TARGET_NAME} PUBLIC
target_include_directories(${TARGET_NAME} PRIVATE
${XPTI_INCLUDES}
${CUDA_CUPTI_INCLUDE_DIR}
)
Expand Down
1 change: 1 addition & 0 deletions source/adapters/hip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ add_ur_adapter(${TARGET_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
)
install_ur_library(${TARGET_NAME})

if(NOT MSVC)
target_compile_options(${TARGET_NAME} PRIVATE
Expand Down
4 changes: 3 additions & 1 deletion source/adapters/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ if(UR_BUILD_ADAPTER_L0)
${CMAKE_CURRENT_SOURCE_DIR}/helpers/memory_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
)
install_ur_library(ur_adapter_level_zero)

if(UR_STATIC_ADAPTER_L0)
target_compile_definitions(ur_adapter_level_zero PUBLIC UR_STATIC_ADAPTER_LEVEL_ZERO)

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

if(NOT WIN32)
# api.cpp contains NOT_SUPPORTED functions-only
Expand Down
1 change: 1 addition & 0 deletions source/adapters/native_cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ add_ur_adapter(${TARGET_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
)
install_ur_library(${TARGET_NAME})

set_target_properties(${TARGET_NAME} PROPERTIES
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
Expand Down
1 change: 1 addition & 0 deletions source/adapters/opencl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ add_ur_adapter(${TARGET_NAME} SHARED
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../../ur/ur.hpp
)
install_ur_library(${TARGET_NAME})

set_target_properties(${TARGET_NAME} PROPERTIES
VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}"
Expand Down
8 changes: 1 addition & 7 deletions source/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ add_ur_library(ur_loader
""
${CMAKE_CURRENT_BINARY_DIR}/UrLoaderVersion.rc
)
install_ur_library(ur_loader)

if (MSVC)
set(TARGET_LIBNAME ur_loader)
Expand Down Expand Up @@ -101,13 +102,6 @@ if(UNIX)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libur_loader.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" COMPONENT unified-runtime)
endif()

install(TARGETS ur_loader
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT unified-runtime
)

target_sources(ur_loader
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/ur_object.hpp
Expand Down
1 change: 1 addition & 0 deletions test/adapters/level_zero/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if(UR_BUILD_ADAPTER_L0)
# Make L0 use CallMap from a seprate shared lib so that we can access the map
# from the tests. This only seems to work on linux
add_library(zeCallMap SHARED zeCallMap.cpp)
install_ur_library(zeCallMap)
target_compile_definitions(ur_adapter_level_zero PRIVATE UR_L0_CALL_COUNT_IN_TESTS)
# TODO: stop exporting internals like this for tests...
target_link_libraries(ur_adapter_level_zero PRIVATE zeCallMap)
Expand Down

0 comments on commit 1360515

Please sign in to comment.