From 081a1c9efe817f1a039d1752bfa9b3a3277c0cc0 Mon Sep 17 00:00:00 2001 From: "Albert-Jan N. Yzelman" Date: Sat, 11 Jan 2025 11:38:40 +0100 Subject: [PATCH] Also better label naming for hand-written compiler-optimised kernels --- tests/performance/bench_kernels.c | 4 ++++ tests/performance/bench_kernels.h | 9 ++++++++- tests/performance/dot.cpp | 10 ++++++++-- tests/performance/fma.cpp | 9 +++++++-- tests/performance/reduce.cpp | 8 +++++++- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/tests/performance/bench_kernels.c b/tests/performance/bench_kernels.c index 83b5b72ec..6c32a8ee6 100644 --- a/tests/performance/bench_kernels.c +++ b/tests/performance/bench_kernels.c @@ -21,6 +21,8 @@ #ifdef BENCH_KERNELS_OPENMP +bool bench_kernels_parallel() { return true; } + void bench_kernels_axpy( double * restrict a, const double alpha, const double * restrict x, @@ -120,6 +122,8 @@ void bench_kernels_reduce( #else +bool bench_kernels_parallel() { return false; } + void bench_kernels_axpy( double * restrict a, const double alpha, const double * restrict x, diff --git a/tests/performance/bench_kernels.h b/tests/performance/bench_kernels.h index 29901a1dc..c58dd890f 100644 --- a/tests/performance/bench_kernels.h +++ b/tests/performance/bench_kernels.h @@ -18,7 +18,7 @@ #include #include -#include //for size_t +#include // for size_t #ifdef __cplusplus @@ -41,10 +41,14 @@ extern "C" { double * __restrict__ const, const double * __restrict__, const size_t ); + bool bench_kernels_parallel(); + } #else +#include // for bool + /** * Executes \f$ a = \alpha x + y \f$ for \a a, \a x, and \a y vectors of * length \a n. @@ -89,5 +93,8 @@ void bench_kernels_reduce( double * restrict const alpha, const double * restrict x, const size_t n ); +/** @returns Whether the kernels defined here are (shared-memory) parallel. */ +bool bench_kernels_parallel(); + #endif diff --git a/tests/performance/dot.cpp b/tests/performance/dot.cpp index e76f0ca9e..35d23df78 100644 --- a/tests/performance/dot.cpp +++ b/tests/performance/dot.cpp @@ -463,8 +463,14 @@ int main( int argc, char ** argv ) { } // start benchmark test 1 - std::cout << "\nBenchmark label: compiler-optimised dot product on raw " - << "arrays of size " << in.n << std::endl; + std::cout << "\nBenchmark label: "; + if( bench_kernels_parallel() ) { + std::cout << "parallel (OpenMP) "; + } else { + std::cout << "sequential (C) "; + } + std::cout << "compiler-optimised dot product on raw arrays of size " << in.n + << std::endl; if( bench.exec( &bench_raw, in, out, 1, outer, true ) != SUCCESS ) { std::cerr << "Error launching raw benchmark test.\nTest FAILED." << std::endl; return 60; diff --git a/tests/performance/fma.cpp b/tests/performance/fma.cpp index 980a642c8..334721c81 100644 --- a/tests/performance/fma.cpp +++ b/tests/performance/fma.cpp @@ -382,8 +382,13 @@ int main( int argc, char ** argv ) { return 50; } - std::cout << "\nBenchmark label: compiler-optimised axpy of size " << in.n - << std::endl; + std::cout << "\nBenchmark label: "; + if( bench_kernels_parallel() ) { + std::cout << "parallel (OpenMP) "; + } else { + std::cout << "sequential (C) "; + } + std::cout << "compiler-optimised axpy of size " << in.n << std::endl; rc = bench.exec( &(test< RAW >), in, out, 1, outer, true ); if( rc != SUCCESS || out.error != SUCCESS ) { std::cerr << "Functional test exits with nonzero exit code. " diff --git a/tests/performance/reduce.cpp b/tests/performance/reduce.cpp index 8305a08cb..31e5b48bc 100644 --- a/tests/performance/reduce.cpp +++ b/tests/performance/reduce.cpp @@ -266,7 +266,13 @@ int main( int argc, char ** argv ) { rc = bench.exec( &(test< LAMBDA >), in, out, 1, outer, true ); } if( rc == SUCCESS ) { - std::cout << "\nBenchmark label: compiler-optimised reduce-to-scalar of size " + std::cout << "\nBenchmark label: "; + if( bench_kernels_parallel() ) { + std::cout << "parallel (OpenMP) "; + } else { + std::cout << "sequential (C) "; + } + std::cout << "compiler-optimised reduce-to-scalar of size " << in.n << std::endl; rc = bench.exec( &(test< RAW >), in, out, 1, outer, true ); }