Skip to content

Commit 27f1587

Browse files
pbalcerCompute-Runtime-Automation
authored andcommitted
Fix accuracy of time measurement in submit_kernel_ur
The timer was also measuring the overhead of capturing CPU counters. This patch moves capturing the CPU counters to be outside of the timed scope. Signed-off-by: Piotr Balcer <[email protected]>
1 parent d1f84b6 commit 27f1587

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

source/benchmarks/api_overhead_benchmark/implementations/ur/submit_kernel_ur.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 Intel Corporation
2+
* Copyright (C) 2024-2025 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -92,8 +92,8 @@ static TestResult run(const SubmitKernelArguments &arguments, Statistics &statis
9292

9393
// Benchmark
9494
for (auto i = 0u; i < arguments.iterations; i++) {
95-
timer.measureStart();
9695
cpuCounter.measureStart();
96+
timer.measureStart();
9797
for (auto iteration = 0u; iteration < arguments.numKernels; iteration++) {
9898
EXPECT_UR_RESULT_SUCCESS(urKernelSetArgValue(
9999
kernel, 0, sizeof(int), nullptr,
@@ -110,17 +110,17 @@ static TestResult run(const SubmitKernelArguments &arguments, Statistics &statis
110110
}
111111

112112
if (!arguments.measureCompletionTime) {
113-
cpuCounter.measureEnd();
114113
timer.measureEnd();
114+
cpuCounter.measureEnd();
115115
statistics.pushValue(timer.get(), typeSelector.getUnit(), typeSelector.getType(), "time");
116116
statistics.pushCpuCounter(cpuCounter.get(), typeSelectorHwI.getUnit(), typeSelectorHwI.getType(), "hw instructions");
117117
}
118118

119119
EXPECT_UR_RESULT_SUCCESS(urQueueFinish(queue));
120120

121121
if (arguments.measureCompletionTime) {
122-
cpuCounter.measureEnd();
123122
timer.measureEnd();
123+
cpuCounter.measureEnd();
124124
statistics.pushValue(timer.get(), typeSelector.getUnit(), typeSelector.getType(), "time");
125125
statistics.pushCpuCounter(cpuCounter.get(), typeSelectorHwI.getUnit(), typeSelectorHwI.getType(), "hw instructions");
126126
}

0 commit comments

Comments
 (0)