From 06475b7c7973a95bd9b73df2f5a9c5621e34da5a Mon Sep 17 00:00:00 2001 From: Lukasz Stolarczuk Date: Tue, 29 Sep 2026 17:32:17 +0200 Subject: [PATCH] [Bench] Add sync vs async usm allocator bench for UR and SYCL --- .../benchmarks/benches/compute/compute.py | 68 +++++++++++++++---- .../benches/compute/compute_enums.py | 5 ++ .../benchmarks/tests/test_integration.py | 8 +++ 3 files changed, 69 insertions(+), 12 deletions(-) diff --git a/devops/scripts/benchmarks/benches/compute/compute.py b/devops/scripts/benchmarks/benches/compute/compute.py index 0cf6ae59767e8..f0e36781e07be 100644 --- a/devops/scripts/benchmarks/benches/compute/compute.py +++ b/devops/scripts/benchmarks/benches/compute/compute.py @@ -21,6 +21,7 @@ RUNTIMES, SUBMIT_KERNEL_RUNTIMES, SYCL_AND_LEVEL_ZERO_RUNTIMES, + SYCL_AND_UR_RUNTIMES, SYCL_RUNTIMES, TORCH_BENCHMARK_RUNTIMES, runtime_to_tag_name, @@ -61,8 +62,8 @@ def git_url(self) -> str: return "https://github.com/intel/compute-benchmarks.git" def git_hash(self) -> str: - # Sep 14, 2026 - return "32dcb8b6d0e3a4ad138cee7cbf1217ac78ba2fd1" + # Sep 15, 2026 + return "be7b31f7b0d5a06b4fdacb3aa1d7a8694e6f6ea0" def setup(self) -> None: if options.sycl is None: @@ -744,8 +745,6 @@ def createTorchGraphVllmMockBench(variant_name: str, **kwargs): # MemcpyExecute(self, RUNTIMES.UR, 100, 4, 102400, 10, 1, 1, 0, 0, 0), # MemcpyExecute(self, RUNTIMES.UR, 4096, 4, 1024, 10, 0, 1, 0, 1, 0), # MemcpyExecute(self, RUNTIMES.UR, 4096, 4, 1024, 10, 0, 1, 0, 1, 1), - UsmMemoryAllocation(self, RUNTIMES.UR, "Device", 256, "Both"), - UsmMemoryAllocation(self, RUNTIMES.UR, "Device", 256 * 1024, "Both"), UsmBatchMemoryAllocation(self, RUNTIMES.UR, "Device", 128, 256, "Both"), UsmBatchMemoryAllocation( self, RUNTIMES.UR, "Device", 128, 16 * 1024, "Both" @@ -755,6 +754,33 @@ def createTorchGraphVllmMockBench(variant_name: str, **kwargs): ), ] + # UsmMemoryAllocation (comparison of sync and async allocations in UR vs SYCL) + usm_alloc_params = product( + SYCL_AND_UR_RUNTIMES, + [256, 256 * 1024], # size + ["Sync", "Async"], # strategy + ["Both", "Allocate"], # measure mode + [0, 1], # disable L0 USM pool allocator + ) + for ( + runtime, + size, + strategy, + measure_mode, + disable_usm_allocator, + ) in usm_alloc_params: + benches.append( + UsmMemoryAllocation( + self, + runtime, + "Device", + size, + measure_mode, + strategy, + disable_usm_allocator, + ) + ) + benches += [ MemcpyExecute( self, RUNTIMES.SYCL_PREVIEW, 4096, 1, 1024, 40, 1, 1, 0, 1, 0 @@ -1521,11 +1547,20 @@ def _bin_args(self, flamegraph_enabled: bool = False) -> list[str]: class UsmMemoryAllocation(ComputeBenchmark): def __init__( - self, bench, runtime: RUNTIMES, usm_memory_placement, size, measure_mode + self, + bench, + runtime: RUNTIMES, + usm_memory_placement, + size, + measure_mode, + strategy, + disable_usm_allocator=0, ): self._usm_memory_placement = usm_memory_placement self._size = size self._measure_mode = measure_mode + self._strategy = strategy + self._disable_usm_allocator = disable_usm_allocator # iterations per bin_args: --iterations=10000 self._iterations_regular = 10000 self._iterations_trace = 10 @@ -1538,18 +1573,23 @@ def __init__( def name(self): return ( - f"api_overhead_benchmark_{self._runtime.value} UsmMemoryAllocation " - f"usmMemoryPlacement:{self._usm_memory_placement} size:{self._size} measureMode:{self._measure_mode}" + f"api_overhead_benchmark_{self._runtime.value} UsmMemoryAllocation usmMemoryPlacement:{self._usm_memory_placement} " + f"size:{self._size} measureMode:{self._measure_mode} strategy:{self._strategy} " + f"disableUsmAllocator:{self._disable_usm_allocator}" ) def display_name(self) -> str: return ( - f"{self._runtime.value.upper()} UsmMemoryAllocation, " - f"usmMemoryPlacement {self._usm_memory_placement}, size {self._size}, measureMode {self._measure_mode}" + f"{self._runtime.value.upper()} UsmMemoryAllocation, usmMemoryPlacement {self._usm_memory_placement}, " + f"size {self._size}, measureMode {self._measure_mode}, strategy {self._strategy}, " + f"L0 pool allocator {'disabled' if self._disable_usm_allocator else 'enabled'}" ) def explicit_group(self): - return f"UsmMemoryAllocation" + return ( + f"UsmMemoryAllocation, measureMode {self._measure_mode}, usmMemoryPlacement {self._usm_memory_placement}, " + f"size {self._size}, disableUsmAllocator {self._disable_usm_allocator}" + ) def description(self) -> str: what_is_measured = "Both memory allocation and memory free are timed" @@ -1559,13 +1599,16 @@ def description(self) -> str: what_is_measured = "Only memory free is timed" return ( f"Measures memory allocation overhead by allocating {self._size} bytes of " - f"usm {self._usm_memory_placement} memory and free'ing it immediately. " - f"{what_is_measured}. " + f"usm {self._usm_memory_placement} memory and free'ing it immediately, " + f"using strategy {self._strategy}. {what_is_measured}." ) def get_tags(self): return [runtime_to_tag_name(self._runtime), "micro", "latency", "memory"] + def _extra_env_vars(self) -> dict: + return {"UR_L0_DISABLE_USM_ALLOCATOR": str(self._disable_usm_allocator)} + def _bin_args(self, flamegraph_enabled: bool = False) -> list[str]: iters = self._get_iters(flamegraph_enabled) return [ @@ -1573,6 +1616,7 @@ def _bin_args(self, flamegraph_enabled: bool = False) -> list[str]: f"--type={self._usm_memory_placement}", f"--size={self._size}", f"--measureMode={self._measure_mode}", + f"--strategy={self._strategy}", ] diff --git a/devops/scripts/benchmarks/benches/compute/compute_enums.py b/devops/scripts/benchmarks/benches/compute/compute_enums.py index 7ce3832e9592a..4b391f2cb0943 100644 --- a/devops/scripts/benchmarks/benches/compute/compute_enums.py +++ b/devops/scripts/benchmarks/benches/compute/compute_enums.py @@ -50,6 +50,11 @@ class RUNTIMES(Enum): RUNTIMES.LEVEL_ZERO, ] +SYCL_AND_UR_RUNTIMES = [ + RUNTIMES.SYCL, + RUNTIMES.UR, +] + NATIVE_GRAPH_RUNTIMES = [ RUNTIMES.LEVEL_ZERO, RUNTIMES.UR, diff --git a/devops/scripts/benchmarks/tests/test_integration.py b/devops/scripts/benchmarks/tests/test_integration.py index ad2a220cc12bd..77e90cf03fdfc 100644 --- a/devops/scripts/benchmarks/tests/test_integration.py +++ b/devops/scripts/benchmarks/tests/test_integration.py @@ -208,6 +208,14 @@ def test_record_and_replay(self): {"L0"}, ) + def test_usm_mem_alloc_ur(self): + self._checkCase( + "api_overhead_benchmark_ur UsmMemoryAllocation usmMemoryPlacement:Device size:256 " + "measureMode:Allocate strategy:Sync disableUsmAllocator:0", + "UsmMemoryAllocation, measureMode Allocate, usmMemoryPlacement Device, size 256, disableUsmAllocator 0", + {"UR", "latency", "micro", "memory"}, + ) + def test_submit_kernel_ur(self): self._checkCase( "api_overhead_benchmark_ur SubmitKernel out of order not using events",