Skip to contentSkip to conversation

test: Get cpc expected branches and instructions counts from perf

PATCH In review [email protected] 2 participants 2 messages Apr 6, 2025 – Apr 24, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: Get cpc expected branches and instructions counts from perf

From: Eugene Loh <[email protected]>

For a number of the cpc tests, we get expected counts from perf. For branches and instructions, however, we can determine the expected counts more directly since there is one branch and a fixed number of instructions per iteration. Thus, we can derive an expected cpc counts simply by knowing the number of iterations.

For some compilers, however, there is apparently some loop unrolling even at low, default levels of optimization.

So, revert to the perf count to estimate the expected cpc count even for the branches and instructions tests.

---
 test/unittest/cpc/tst.branches.sh     | 2 +-
 test/unittest/cpc/tst.instructions.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
test/unittest/cpc/tst.branches.sh +1 -1
index 87250c371..442d65332 100755
@@ -53,7 +53,7 @@ fi
 actual=$(($period * `cat tmp.txt`))
 
 # determine expected count (one branch per interation)
-expect=$niters
+expect=`$utils/perf_count_event.sh branches workload_user $niters`
 
 # check
 $utils/check_result.sh $actual $expect $(($expect / 4))
test/unittest/cpc/tst.instructions.sh +1 -1
index a7fad3e78..34112c6e7 100755
@@ -61,7 +61,7 @@ fi
 actual=$(($period * `cat tmp.txt`))
 
 # determine expected count
-expect=$(($niters * $ninstructions_per_iter))
+expect=`$utils/perf_count_event.sh instructions workload_user $niters`
 
 # check
 $utils/check_result.sh $actual $expect $(($expect / 4))
Signature · 1 line
2.43.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 49 lines · On Sun, Apr 06, 2025 at 01:19:17AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

For a number of the cpc tests, we get expected counts from perf. For branches and instructions, however, we can determine the expected counts more directly since there is one branch and a fixed number of instructions per iteration. Thus, we can derive an expected cpc counts simply by knowing the number of iterations.

For some compilers, however, there is apparently some loop unrolling even at low, default levels of optimization.

So, revert to the perf count to estimate the expected cpc count even for the branches and instructions tests.

---
 test/unittest/cpc/tst.branches.sh     | 2 +-
 test/unittest/cpc/tst.instructions.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
test/unittest/cpc/tst.branches.sh +1 -1
index 87250c371..442d65332 100755
@@ -53,7 +53,7 @@ fi
 actual=$(($period * `cat tmp.txt`))
 
 # determine expected count (one branch per interation)
-expect=$niters
+expect=`$utils/perf_count_event.sh branches workload_user $niters`
 
 # check
 $utils/check_result.sh $actual $expect $(($expect / 4))
test/unittest/cpc/tst.instructions.sh +1 -1
index a7fad3e78..34112c6e7 100755
@@ -61,7 +61,7 @@ fi
 actual=$(($period * `cat tmp.txt`))
 
 # determine expected count
-expect=$(($niters * $ninstructions_per_iter))
+expect=`$utils/perf_count_event.sh instructions workload_user $niters`
 
 # check
 $utils/check_result.sh $actual $expect $(($expect / 4))
Signature · 1 line
2.43.5