1- # Copyright (C) 2025 Intel Corporation
1+ # Copyright (C) 2025-2026 Intel Corporation
22# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
33# See LICENSE.TXT
44# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -63,7 +63,7 @@ def remove_dirs(self):
6363 if d is not None :
6464 shutil .rmtree (d , ignore_errors = True )
6565
66- def run_main (self , * args ):
66+ def run_main (self , * args ) -> subprocess . CompletedProcess :
6767
6868 # TODO: not yet tested: "--detect-version", "sycl,compute_runtime"
6969
@@ -101,9 +101,9 @@ def run_main(self, *args):
101101 "MAIN_PY_STDERR:" ,
102102 "\n " + proc .stderr .decode () if proc .stderr else " <empty>" ,
103103 )
104- return proc . returncode
104+ return proc
105105
106- def get_output (self ):
106+ def get_benchmark_output_data (self ):
107107 with open (os .path .join (self .OUTPUT_DIR , "data.json" )) as f :
108108 out = json .load (f )
109109 return DataJson (
@@ -169,11 +169,30 @@ def _checkGroup(
169169 def _checkResultsExist (self , caseName : str , out : DataJson ):
170170 self .assertIn (caseName , [r .name for r in out .runs [0 ].results ])
171171
172- def _checkCase (self , caseName : str , groupName : str , tags : set [str ]):
173- run_result = self .app .run_main ("--filter" , caseName + "$" )
174- self .assertEqual (run_result , 0 , "Subprocess did not exit cleanly" )
172+ def _checkExistsInProcessOutput (
173+ self , proc : subprocess .CompletedProcess , expected : str
174+ ):
175+ """
176+ Check that expected regex string exists in process output.
177+ It's useful for checking e.g. if expected params are passed to the benchmark's bin execution.
178+ """
179+ stdout = proc .stdout .decode ()
180+ self .assertRegex (stdout , expected , "Expected string not found in output" )
181+
182+ def _checkCase (
183+ self ,
184+ caseName : str ,
185+ groupName : str ,
186+ tags : set [str ],
187+ expected_in_output : str = None ,
188+ ):
189+ return_proc = self .app .run_main ("--filter" , caseName + "$" )
190+ self .assertEqual (return_proc .returncode , 0 , "Subprocess did not exit cleanly" )
191+
192+ if expected_in_output :
193+ self ._checkExistsInProcessOutput (return_proc , expected_in_output )
175194
176- out = self .app .get_output ()
195+ out = self .app .get_benchmark_output_data ()
177196 self ._checkResultsExist (caseName , out )
178197
179198 metadata = out .metadata [caseName ]
@@ -199,11 +218,13 @@ def test_torch_l0(self):
199218 "torch_benchmark_l0 KernelSubmitSingleQueue KernelBatchSize 512, KernelDataType Int32, KernelName Add, KernelParamsNum 5, KernelSubmitPattern Single, KernelWGCount 4096, KernelWGSize 512" ,
200219 "KernelSubmitSingleQueue Int32Large" ,
201220 {"pytorch" , "L0" },
221+ "--test=KernelSubmitSingleQueue.*--profilerType=timer" ,
202222 )
203223 self ._checkCase (
204224 "torch_benchmark_l0 KernelSubmitSingleQueue KernelBatchSize 512, KernelDataType Int32, KernelName Add, KernelParamsNum 5, KernelSubmitPattern Single, KernelWGCount 4096, KernelWGSize 512 CPU count" ,
205225 "KernelSubmitSingleQueue Int32Large, CPU count" ,
206226 {"pytorch" , "L0" },
227+ "--test=KernelSubmitSingleQueue.*--profilerType=cpuCounter" ,
207228 )
208229 self ._checkCase (
209230 "torch_benchmark_l0 KernelSubmitMultiQueue kernelsPerQueue 20, workgroupCount 4096, workgroupSize 512" ,
0 commit comments