Skip to content

Commit

Permalink
Add macros for benchmark registration
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Nov 19, 2024
1 parent e3cd1b3 commit a238f03
Show file tree
Hide file tree
Showing 19 changed files with 198 additions and 269 deletions.
12 changes: 1 addition & 11 deletions benchmarks/array/array_getter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "algebra/array_cmath.hpp"
#include "benchmark/array/data_generator.hpp"
#include "benchmark/common/benchmark_getter.hpp"
#include "benchmark/common/register_benchmark.hpp"

// Benchmark include
#include <benchmark/benchmark.h>
Expand Down Expand Up @@ -48,16 +47,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<phi_f_t>(cfg, "_single");
algebra::register_benchmark<phi_d_t>(cfg, "_double");
algebra::register_benchmark<theta_f_t>(cfg, "_single");
algebra::register_benchmark<theta_d_t>(cfg, "_double");
algebra::register_benchmark<perp_f_t>(cfg, "_single");
algebra::register_benchmark<perp_d_t>(cfg, "_double");
algebra::register_benchmark<norm_f_t>(cfg, "_single");
algebra::register_benchmark<norm_d_t>(cfg, "_double");
algebra::register_benchmark<eta_f_t>(cfg, "_single");
algebra::register_benchmark<eta_d_t>(cfg, "_double");
ALGEBRA_PLUGINS_REGISTER_GETTER_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
22 changes: 1 addition & 21 deletions benchmarks/array/array_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "algebra/array_cmath.hpp"
#include "benchmark/array/data_generator.hpp"
#include "benchmark/common/benchmark_matrix.hpp"
#include "benchmark/common/register_benchmark.hpp"

// Benchmark include
#include <benchmark/benchmark.h>
Expand Down Expand Up @@ -75,26 +74,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<mat44_add_f_t>(cfg, "_4x4_add_single");
algebra::register_benchmark<mat44_add_d_t>(cfg, "_4x4_add_double");
algebra::register_benchmark<mat66_add_f_t>(cfg, "_6x6_add_single");
algebra::register_benchmark<mat66_add_d_t>(cfg, "_6x6_add_double");
algebra::register_benchmark<mat88_add_f_t>(cfg, "_8x8_add_single");
algebra::register_benchmark<mat88_add_d_t>(cfg, "_8x8_add_double");

algebra::register_benchmark<mat44_mul_f_t>(cfg, "_4x4_mul_single");
algebra::register_benchmark<mat44_mul_d_t>(cfg, "_4x4_mul_double");
algebra::register_benchmark<mat66_mul_f_t>(cfg, "_6x6_mul_single");
algebra::register_benchmark<mat66_mul_d_t>(cfg, "_6x6_mul_double");
algebra::register_benchmark<mat88_mul_f_t>(cfg, "_8x8_mul_single");
algebra::register_benchmark<mat88_mul_d_t>(cfg, "_8x8_mul_double");

algebra::register_benchmark<mat44_vec_f_t>(cfg, "_4x4_vec_single");
algebra::register_benchmark<mat44_vec_d_t>(cfg, "_4x4_vec_double");
algebra::register_benchmark<mat66_vec_f_t>(cfg, "_6x6_vec_single");
algebra::register_benchmark<mat66_vec_d_t>(cfg, "_6x6_vec_double");
algebra::register_benchmark<mat88_vec_f_t>(cfg, "_8x8_vec_single");
algebra::register_benchmark<mat88_vec_d_t>(cfg, "_8x8_vec_double");
ALGEBRA_PLUGINS_REGISTER_MATRIX_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
12 changes: 1 addition & 11 deletions benchmarks/array/array_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "algebra/array_cmath.hpp"
#include "benchmark/array/data_generator.hpp"
#include "benchmark/common/benchmark_vector.hpp"
#include "benchmark/common/register_benchmark.hpp"

// Benchmark include
#include <benchmark/benchmark.h>
Expand Down Expand Up @@ -50,16 +49,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<add_f_t>(cfg, "_single");
algebra::register_benchmark<add_d_t>(cfg, "_double");
algebra::register_benchmark<sub_f_t>(cfg, "_single");
algebra::register_benchmark<sub_d_t>(cfg, "_double");
algebra::register_benchmark<dot_f_t>(cfg, "_single");
algebra::register_benchmark<dot_d_t>(cfg, "_double");
algebra::register_benchmark<cross_f_t>(cfg, "_single");
algebra::register_benchmark<cross_d_t>(cfg, "_double");
algebra::register_benchmark<normlz_f_t>(cfg, "_single");
algebra::register_benchmark<normlz_d_t>(cfg, "_double");
ALGEBRA_PLUGINS_REGISTER_VECTOR_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
14 changes: 14 additions & 0 deletions benchmarks/common/include/benchmark/common/benchmark_getter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Project include(s)
#include "benchmark_vector.hpp"
#include "register_benchmark.hpp"

namespace algebra::bench_op {

Expand All @@ -29,4 +30,17 @@ ALGEBRA_PLUGINS_BENCH_GETTER(perp)
ALGEBRA_PLUGINS_BENCH_GETTER(norm)
ALGEBRA_PLUGINS_BENCH_GETTER(eta)

// Macro for registering all getter benchmarks
#define ALGEBRA_PLUGINS_REGISTER_GETTER_BENCH(CFG) \
algebra::register_benchmark<phi_f_t>(CFG, "_single"); \
algebra::register_benchmark<phi_d_t>(CFG, "_double"); \
algebra::register_benchmark<theta_f_t>(CFG, "_single"); \
algebra::register_benchmark<theta_d_t>(CFG, "_double"); \
algebra::register_benchmark<perp_f_t>(CFG, "_single"); \
algebra::register_benchmark<perp_d_t>(CFG, "_double"); \
algebra::register_benchmark<norm_f_t>(CFG, "_single"); \
algebra::register_benchmark<norm_d_t>(CFG, "_double"); \
algebra::register_benchmark<eta_f_t>(CFG, "_single"); \
algebra::register_benchmark<eta_d_t>(CFG, "_double");

} // namespace algebra::bench_op
24 changes: 24 additions & 0 deletions benchmarks/common/include/benchmark/common/benchmark_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Project include(s)
#include "benchmark_base.hpp"
#include "register_benchmark.hpp"

// System include(s)
#include <string>
Expand Down Expand Up @@ -183,4 +184,27 @@ struct mul {

} // namespace bench_op

// Macro for registering all vector benchmarks
#define ALGEBRA_PLUGINS_REGISTER_MATRIX_BENCH(CFG) \
algebra::register_benchmark<mat44_add_f_t>(CFG, "_4x4_add_single"); \
algebra::register_benchmark<mat44_add_d_t>(CFG, "_4x4_add_double"); \
algebra::register_benchmark<mat66_add_f_t>(CFG, "_6x6_add_single"); \
algebra::register_benchmark<mat66_add_d_t>(CFG, "_6x6_add_double"); \
algebra::register_benchmark<mat88_add_f_t>(CFG, "_8x8_add_single"); \
algebra::register_benchmark<mat88_add_d_t>(CFG, "_8x8_add_double"); \
\
algebra::register_benchmark<mat44_mul_f_t>(CFG, "_4x4_mul_single"); \
algebra::register_benchmark<mat44_mul_d_t>(CFG, "_4x4_mul_double"); \
algebra::register_benchmark<mat66_mul_f_t>(CFG, "_6x6_mul_single"); \
algebra::register_benchmark<mat66_mul_d_t>(CFG, "_6x6_mul_double"); \
algebra::register_benchmark<mat88_mul_f_t>(CFG, "_8x8_mul_single"); \
algebra::register_benchmark<mat88_mul_d_t>(CFG, "_8x8_mul_double"); \
\
algebra::register_benchmark<mat44_vec_f_t>(CFG, "_4x4_vec_single"); \
algebra::register_benchmark<mat44_vec_d_t>(CFG, "_4x4_vec_double"); \
algebra::register_benchmark<mat66_vec_f_t>(CFG, "_6x6_vec_single"); \
algebra::register_benchmark<mat66_vec_d_t>(CFG, "_6x6_vec_double"); \
algebra::register_benchmark<mat88_vec_f_t>(CFG, "_8x8_vec_single"); \
algebra::register_benchmark<mat88_vec_d_t>(CFG, "_8x8_vec_double");

} // namespace algebra
14 changes: 14 additions & 0 deletions benchmarks/common/include/benchmark/common/benchmark_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// Project include(s)
#include "benchmark_base.hpp"
#include "register_benchmark.hpp"

// System include(s)
#include <chrono>
Expand Down Expand Up @@ -161,4 +162,17 @@ struct normalize {

} // namespace bench_op

// Macro for registering all vector benchmarks
#define ALGEBRA_PLUGINS_REGISTER_VECTOR_BENCH(CFG) \
algebra::register_benchmark<add_f_t>(CFG, "_single"); \
algebra::register_benchmark<add_d_t>(CFG, "_double"); \
algebra::register_benchmark<sub_f_t>(CFG, "_single"); \
algebra::register_benchmark<sub_d_t>(CFG, "_double"); \
algebra::register_benchmark<dot_f_t>(CFG, "_single"); \
algebra::register_benchmark<dot_d_t>(CFG, "_double"); \
algebra::register_benchmark<cross_f_t>(CFG, "_single"); \
algebra::register_benchmark<cross_d_t>(CFG, "_double"); \
algebra::register_benchmark<normlz_f_t>(CFG, "_single"); \
algebra::register_benchmark<normlz_d_t>(CFG, "_double");

} // namespace algebra
12 changes: 1 addition & 11 deletions benchmarks/eigen/eigen_getter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Project include(s)
#include "algebra/eigen_eigen.hpp"
#include "benchmark/common/benchmark_getter.hpp"
#include "benchmark/common/register_benchmark.hpp"
#include "benchmark/eigen/data_generator.hpp"

// Benchmark include
Expand Down Expand Up @@ -48,16 +47,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<phi_f_t>(cfg, "_single");
algebra::register_benchmark<phi_d_t>(cfg, "_double");
algebra::register_benchmark<theta_f_t>(cfg, "_single");
algebra::register_benchmark<theta_d_t>(cfg, "_double");
algebra::register_benchmark<perp_f_t>(cfg, "_single");
algebra::register_benchmark<perp_d_t>(cfg, "_double");
algebra::register_benchmark<norm_f_t>(cfg, "_single");
algebra::register_benchmark<norm_d_t>(cfg, "_double");
algebra::register_benchmark<eta_f_t>(cfg, "_single");
algebra::register_benchmark<eta_d_t>(cfg, "_double");
ALGEBRA_PLUGINS_REGISTER_GETTER_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
22 changes: 1 addition & 21 deletions benchmarks/eigen/eigen_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Project include(s)
#include "algebra/eigen_eigen.hpp"
#include "benchmark/common/benchmark_matrix.hpp"
#include "benchmark/common/register_benchmark.hpp"
#include "benchmark/eigen/data_generator.hpp"

// Benchmark include
Expand Down Expand Up @@ -75,26 +74,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<mat44_add_f_t>(cfg, "_4x4_add_single");
algebra::register_benchmark<mat44_add_d_t>(cfg, "_4x4_add_double");
algebra::register_benchmark<mat66_add_f_t>(cfg, "_6x6_add_single");
algebra::register_benchmark<mat66_add_d_t>(cfg, "_6x6_add_double");
algebra::register_benchmark<mat88_add_f_t>(cfg, "_8x8_add_single");
algebra::register_benchmark<mat88_add_d_t>(cfg, "_8x8_add_double");

algebra::register_benchmark<mat44_mul_f_t>(cfg, "_4x4_mul_single");
algebra::register_benchmark<mat44_mul_d_t>(cfg, "_4x4_mul_double");
algebra::register_benchmark<mat66_mul_f_t>(cfg, "_6x6_mul_single");
algebra::register_benchmark<mat66_mul_d_t>(cfg, "_6x6_mul_double");
algebra::register_benchmark<mat88_mul_f_t>(cfg, "_8x8_mul_single");
algebra::register_benchmark<mat88_mul_d_t>(cfg, "_8x8_mul_double");

algebra::register_benchmark<mat44_vec_f_t>(cfg, "_4x4_vec_single");
algebra::register_benchmark<mat44_vec_d_t>(cfg, "_4x4_vec_double");
algebra::register_benchmark<mat66_vec_f_t>(cfg, "_6x6_vec_single");
algebra::register_benchmark<mat66_vec_d_t>(cfg, "_6x6_vec_double");
algebra::register_benchmark<mat88_vec_f_t>(cfg, "_8x8_vec_single");
algebra::register_benchmark<mat88_vec_d_t>(cfg, "_8x8_vec_double");
ALGEBRA_PLUGINS_REGISTER_MATRIX_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
12 changes: 1 addition & 11 deletions benchmarks/eigen/eigen_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Project include(s)
#include "algebra/eigen_eigen.hpp"
#include "benchmark/common/benchmark_vector.hpp"
#include "benchmark/common/register_benchmark.hpp"
#include "benchmark/eigen/data_generator.hpp"

// Benchmark include
Expand Down Expand Up @@ -50,16 +49,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<add_f_t>(cfg, "_single");
algebra::register_benchmark<add_d_t>(cfg, "_double");
algebra::register_benchmark<sub_f_t>(cfg, "_single");
algebra::register_benchmark<sub_d_t>(cfg, "_double");
algebra::register_benchmark<dot_f_t>(cfg, "_single");
algebra::register_benchmark<dot_d_t>(cfg, "_double");
algebra::register_benchmark<cross_f_t>(cfg, "_single");
algebra::register_benchmark<cross_d_t>(cfg, "_double");
algebra::register_benchmark<normlz_f_t>(cfg, "_single");
algebra::register_benchmark<normlz_d_t>(cfg, "_double");
ALGEBRA_PLUGINS_REGISTER_VECTOR_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
12 changes: 1 addition & 11 deletions benchmarks/vc_aos/vc_aos_getter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Project include(s)
#include "algebra/vc_aos.hpp"
#include "benchmark/common/benchmark_getter.hpp"
#include "benchmark/common/register_benchmark.hpp"
#include "benchmark/vc_aos/data_generator.hpp"

// Benchmark include
Expand Down Expand Up @@ -48,16 +47,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<phi_f_t>(cfg, "_single");
algebra::register_benchmark<phi_d_t>(cfg, "_double");
algebra::register_benchmark<theta_f_t>(cfg, "_single");
algebra::register_benchmark<theta_d_t>(cfg, "_double");
algebra::register_benchmark<perp_f_t>(cfg, "_single");
algebra::register_benchmark<perp_d_t>(cfg, "_double");
algebra::register_benchmark<norm_f_t>(cfg, "_single");
algebra::register_benchmark<norm_d_t>(cfg, "_double");
algebra::register_benchmark<eta_f_t>(cfg, "_single");
algebra::register_benchmark<eta_d_t>(cfg, "_double");
ALGEBRA_PLUGINS_REGISTER_GETTER_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
22 changes: 1 addition & 21 deletions benchmarks/vc_aos/vc_aos_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Project include(s)
#include "algebra/vc_aos.hpp"
#include "benchmark/common/benchmark_matrix.hpp"
#include "benchmark/common/register_benchmark.hpp"
#include "benchmark/vc_aos/data_generator.hpp"

// Benchmark include
Expand Down Expand Up @@ -75,26 +74,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<mat44_add_f_t>(cfg, "_4x4_add_single");
algebra::register_benchmark<mat44_add_d_t>(cfg, "_4x4_add_double");
algebra::register_benchmark<mat66_add_f_t>(cfg, "_6x6_add_single");
algebra::register_benchmark<mat66_add_d_t>(cfg, "_6x6_add_double");
algebra::register_benchmark<mat88_add_f_t>(cfg, "_8x8_add_single");
algebra::register_benchmark<mat88_add_d_t>(cfg, "_8x8_add_double");

algebra::register_benchmark<mat44_mul_f_t>(cfg, "_4x4_mul_single");
algebra::register_benchmark<mat44_mul_d_t>(cfg, "_4x4_mul_double");
algebra::register_benchmark<mat66_mul_f_t>(cfg, "_6x6_mul_single");
algebra::register_benchmark<mat66_mul_d_t>(cfg, "_6x6_mul_double");
algebra::register_benchmark<mat88_mul_f_t>(cfg, "_8x8_mul_single");
algebra::register_benchmark<mat88_mul_d_t>(cfg, "_8x8_mul_double");

algebra::register_benchmark<mat44_vec_f_t>(cfg, "_4x4_vec_single");
algebra::register_benchmark<mat44_vec_d_t>(cfg, "_4x4_vec_double");
algebra::register_benchmark<mat66_vec_f_t>(cfg, "_6x6_vec_single");
algebra::register_benchmark<mat66_vec_d_t>(cfg, "_6x6_vec_double");
algebra::register_benchmark<mat88_vec_f_t>(cfg, "_8x8_vec_single");
algebra::register_benchmark<mat88_vec_d_t>(cfg, "_8x8_vec_double");
ALGEBRA_PLUGINS_REGISTER_MATRIX_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
12 changes: 1 addition & 11 deletions benchmarks/vc_aos/vc_aos_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// Project include(s)
#include "algebra/vc_aos.hpp"
#include "benchmark/common/benchmark_vector.hpp"
#include "benchmark/common/register_benchmark.hpp"
#include "benchmark/vc_aos/data_generator.hpp"

// Benchmark include
Expand Down Expand Up @@ -48,16 +47,7 @@ int main(int argc, char** argv) {
//
// Register all benchmarks
//
algebra::register_benchmark<add_f_t>(cfg, "_single");
algebra::register_benchmark<add_d_t>(cfg, "_double");
algebra::register_benchmark<sub_f_t>(cfg, "_single");
algebra::register_benchmark<sub_d_t>(cfg, "_double");
algebra::register_benchmark<dot_f_t>(cfg, "_single");
algebra::register_benchmark<dot_d_t>(cfg, "_double");
algebra::register_benchmark<cross_f_t>(cfg, "_single");
algebra::register_benchmark<cross_d_t>(cfg, "_double");
algebra::register_benchmark<normlz_f_t>(cfg, "_single");
algebra::register_benchmark<normlz_d_t>(cfg, "_double");
ALGEBRA_PLUGINS_REGISTER_VECTOR_BENCH(cfg)

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
2 changes: 1 addition & 1 deletion extern/vc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ target_include_directories( Vc
# Disable a warning for GCC which the Vc build turns on explicitly for that
# compiler, just to then go and trigger it... :-/
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" )
target_compile_options( Vc PRIVATE "-Wno-old-style-cast -Wdeprecated-enum-enum-conversion -Wdeprecated-declarations" )
target_compile_options( Vc PRIVATE "-Wno-old-style-cast )
endif()
# Set up an alias for the Vc target, with the same name that it will have
Expand Down
16 changes: 0 additions & 16 deletions math/vc_aos/include/algebra/math/impl/vc_aos_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,6 @@ struct actor {
const matrix_type<ROWS, COLS> &m) {
return storage::transpose(m);
}

/// Get determinant using a specific algorithm @tparam determinant_t
/*template <std::size_t N, typename determinant_t = determinant_t>
ALGEBRA_HOST_DEVICE static constexpr constexpr value_type determinant(
const matrix_type<N, N> &m) {
return determinant_t{}(m);
}
/// Get inverse using a specific algorithm @tparam inverse_t
template <std::size_t N, typename inverse_t = inverse_t>
ALGEBRA_HOST_DEVICE static constexpr constexpr matrix_type<N, N> inverse(
const matrix_type<N, N> &m) {
return inverse_t{}(m);
}*/
};

} // namespace matrix
Expand Down
2 changes: 2 additions & 0 deletions math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ using algebra::storage::operator+;
template <template <typename, std::size_t> class array_t, typename scalar_t>
struct transform3 {

private:
// How to address matrix columns
enum elem : std::size_t {
e_x = 0u,
Expand All @@ -44,6 +45,7 @@ struct transform3 {
e_t = 3u,
};

public:
/// @name Type definitions for the struct
/// @{

Expand Down
Loading

0 comments on commit a238f03

Please sign in to comment.