test: Get cpc expected branches and instructions counts from perf
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
@@ -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
@@ -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
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.
Signed-off-by Eugene Loh <[email protected]>--- 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@@ -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@@ -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