Skip to content

Commit

Permalink
Rename to vc_aos
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Jul 24, 2024
1 parent ddfb951 commit 747351d
Show file tree
Hide file tree
Showing 39 changed files with 599 additions and 831 deletions.
8 changes: 4 additions & 4 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ if( ALGEBRA_PLUGINS_INCLUDE_VC )
target_include_directories( algebra_bench_vc_aos INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/vc_aos/include>" )
target_link_libraries(algebra_bench_vc_aos INTERFACE
algebra::vc_vc
algebra::vc_aos
algebra::common_storage)
add_library( algebra::bench_vc_aos ALIAS algebra_bench_vc_aos )

algebra_add_benchmark( vc_aos_getter
"vc_aos/vc_aos_getter.cpp"
LINK_LIBRARIES benchmark::benchmark algebra::bench_common
algebra::bench_vc_aos algebra::vc_vc )
algebra::bench_vc_aos algebra::vc_aos )
algebra_add_benchmark( vc_aos_vector
"vc_aos/vc_aos_vector.cpp"
LINK_LIBRARIES benchmark::benchmark algebra::bench_common
algebra::bench_vc_aos algebra::vc_vc )
algebra::bench_vc_aos algebra::vc_aos )
algebra_add_benchmark( vc_aos_transform3
"vc_aos/vc_aos_transform3.cpp"
LINK_LIBRARIES benchmark::benchmark algebra::bench_common
algebra::bench_vc_aos algebra::vc_vc )
algebra::bench_vc_aos algebra::vc_aos )

if( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang" )
add_library( algebra_bench_vc_soa INTERFACE )
Expand Down
78 changes: 25 additions & 53 deletions benchmarks/array/array_getter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Algebra plugins library, part of the ACTS project
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand All @@ -9,6 +9,7 @@
#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 All @@ -21,71 +22,42 @@ using namespace algebra;
/// Run vector benchmarks
int main(int argc, char** argv) {

constexpr std::size_t n_samples{160000};
constexpr std::size_t n_warmup{static_cast<std::size_t>(0.1 * n_samples)};

//
// Prepare benchmarks
//
algebra::benchmark_base::configuration cfg{};
cfg.n_samples(n_samples).n_warmup(n_warmup);
cfg.do_sleep(false);
cfg.n_samples(100000);

vector_unaryOP_bm<array::vector3, float, bench_op::phi> v_phi_s{cfg};
vector_unaryOP_bm<array::vector3, float, bench_op::theta> v_theta_s{cfg};
vector_unaryOP_bm<array::vector3, float, bench_op::perp> v_perp_s{cfg};
vector_unaryOP_bm<array::vector3, float, bench_op::norm> v_norm_s{cfg};
vector_unaryOP_bm<array::vector3, float, bench_op::eta> v_eta_s{cfg};
using phi_f_t = vector_unaryOP_bm<array::vector3, float, bench_op::phi>;
using theta_f_t = vector_unaryOP_bm<array::vector3, float, bench_op::theta>;
using perp_f_t = vector_unaryOP_bm<array::vector3, float, bench_op::perp>;
using norm_f_t = vector_unaryOP_bm<array::vector3, float, bench_op::norm>;
using eta_f_t = vector_unaryOP_bm<array::vector3, float, bench_op::eta>;

vector_unaryOP_bm<array::vector3, double, bench_op::phi> v_phi_d{cfg};
vector_unaryOP_bm<array::vector3, double, bench_op::theta> v_theta_d{cfg};
vector_unaryOP_bm<array::vector3, double, bench_op::perp> v_perp_d{cfg};
vector_unaryOP_bm<array::vector3, double, bench_op::norm> v_norm_d{cfg};
vector_unaryOP_bm<array::vector3, double, bench_op::eta> v_eta_d{cfg};
using phi_d_t = vector_unaryOP_bm<array::vector3, double, bench_op::phi>;
using theta_d_t = vector_unaryOP_bm<array::vector3, double, bench_op::theta>;
using perp_d_t = vector_unaryOP_bm<array::vector3, double, bench_op::perp>;
using norm_d_t = vector_unaryOP_bm<array::vector3, double, bench_op::norm>;
using eta_d_t = vector_unaryOP_bm<array::vector3, double, bench_op::eta>;

std::cout << "Algebra-Plugins 'getter' benchmark (std::array)\n"
std::cout << "-----------------------------------------------\n"
<< "Algebra-Plugins 'getter' benchmark (std::array)\n"
<< "-----------------------------------------------\n\n"
<< cfg;

//
// Register all benchmarks
//
::benchmark::RegisterBenchmark((v_phi_s.name() + "_single").c_str(), v_phi_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_phi_d.name() + "_double").c_str(), v_phi_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_theta_s.name() + "_single").c_str(),
v_theta_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_theta_d.name() + "_double").c_str(),
v_theta_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_perp_s.name() + "_single").c_str(),
v_perp_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_perp_d.name() + "_double").c_str(),
v_perp_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_norm_s.name() + "_single").c_str(),
v_norm_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_norm_d.name() + "_double").c_str(),
v_norm_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_eta_s.name() + "_single").c_str(), v_eta_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_eta_d.name() + "_double").c_str(), v_eta_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
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");

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
26 changes: 10 additions & 16 deletions benchmarks/array/array_transform3.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Algebra plugins library, part of the ACTS project
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand All @@ -9,6 +9,7 @@
#include "algebra/array_cmath.hpp"
#include "benchmark/array/data_generator.hpp"
#include "benchmark/common/benchmark_transform3.hpp"
#include "benchmark/common/register_benchmark.hpp"

// Benchmark include
#include <benchmark/benchmark.h>
Expand All @@ -18,34 +19,27 @@ using namespace algebra;
/// Run vector benchmarks
int main(int argc, char** argv) {

constexpr std::size_t n_samples{160000};
constexpr std::size_t n_warmup{static_cast<std::size_t>(0.1 * n_samples)};

//
// Prepare benchmarks
//
algebra::benchmark_base::configuration cfg{};
cfg.n_samples(n_samples).n_warmup(n_warmup);
cfg.do_sleep(false);
cfg.n_samples(100000);

transform3_bm<array::transform3<float>> v_trf_s{cfg};
transform3_bm<array::transform3<double>> v_trf_d{cfg};
using trf_f_t = transform3_bm<array::transform3<float>>;
using trf_d_t = transform3_bm<array::transform3<double>>;

std::cout << "Algebra-Plugins 'transform3' benchmark (std::array)\n"
std::cout << "-----------------------------------------------\n"
<< "Algebra-Plugins 'transform3' benchmark (std::array)\n"
<< "---------------------------------------------------\n\n"
<< cfg;

//
// Register all benchmarks
//
::benchmark::RegisterBenchmark((v_trf_s.name() + "_single").c_str(), v_trf_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_trf_d.name() + "_double").c_str(), v_trf_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
algebra::register_benchmark<trf_f_t>(cfg, "_single");
algebra::register_benchmark<trf_d_t>(cfg, "_double");

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
::benchmark::Shutdown();
}
}
80 changes: 27 additions & 53 deletions benchmarks/array/array_vector.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** Algebra plugins library, part of the ACTS project
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2023-2024 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/
Expand All @@ -9,6 +9,7 @@
#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 All @@ -21,71 +22,44 @@ using namespace algebra;
/// Run vector benchmarks
int main(int argc, char** argv) {

constexpr std::size_t n_samples{160000};
constexpr std::size_t n_warmup{static_cast<std::size_t>(0.1 * n_samples)};

//
// Prepare benchmarks
//
algebra::benchmark_base::configuration cfg{};
cfg.n_samples(n_samples).n_warmup(n_warmup);
cfg.do_sleep(false);
cfg.n_samples(100000);

vector_binaryOP_bm<array::vector3, float, bench_op::add> v_add_s{cfg};
vector_binaryOP_bm<array::vector3, float, bench_op::sub> v_sub_s{cfg};
vector_binaryOP_bm<array::vector3, float, bench_op::dot> v_dot_s{cfg};
vector_binaryOP_bm<array::vector3, float, bench_op::cross> v_cross_s{cfg};
vector_unaryOP_bm<array::vector3, float, bench_op::normalize> v_normalize_s{
cfg};
using add_f_t = vector_binaryOP_bm<array::vector3, float, bench_op::add>;
using sub_f_t = vector_binaryOP_bm<array::vector3, float, bench_op::sub>;
using dot_f_t = vector_binaryOP_bm<array::vector3, float, bench_op::dot>;
using cross_f_t = vector_binaryOP_bm<array::vector3, float, bench_op::cross>;
using normlz_f_t =
vector_unaryOP_bm<array::vector3, float, bench_op::normalize>;

vector_binaryOP_bm<array::vector3, double, bench_op::add> v_add_d{cfg};
vector_binaryOP_bm<array::vector3, double, bench_op::sub> v_sub_d{cfg};
vector_binaryOP_bm<array::vector3, double, bench_op::dot> v_dot_d{cfg};
vector_binaryOP_bm<array::vector3, double, bench_op::cross> v_cross_d{cfg};
vector_unaryOP_bm<array::vector3, double, bench_op::normalize> v_normalize_d{
cfg};
using add_d_t = vector_binaryOP_bm<array::vector3, double, bench_op::add>;
using sub_d_t = vector_binaryOP_bm<array::vector3, double, bench_op::sub>;
using dot_d_t = vector_binaryOP_bm<array::vector3, double, bench_op::dot>;
using cross_d_t = vector_binaryOP_bm<array::vector3, double, bench_op::cross>;
using normlz_d_t =
vector_unaryOP_bm<array::vector3, double, bench_op::normalize>;

std::cout << "Algebra-Plugins 'vector' benchmark (std::array)\n"
std::cout << "-----------------------------------------------\n"
<< "Algebra-Plugins 'vector' benchmark (std::array)\n"
<< "-----------------------------------------------\n\n"
<< cfg;

//
// Register all benchmarks
//
::benchmark::RegisterBenchmark((v_add_s.name() + "_single").c_str(), v_add_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_add_d.name() + "_double").c_str(), v_add_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_sub_s.name() + "_single").c_str(), v_sub_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_sub_d.name() + "_double").c_str(), v_sub_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_dot_s.name() + "_single").c_str(), v_dot_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_dot_d.name() + "_double").c_str(), v_dot_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_cross_s.name() + "_single").c_str(),
v_cross_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_cross_d.name() + "_double").c_str(),
v_cross_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_normalize_s.name() + "_single").c_str(),
v_normalize_s)
->MeasureProcessCPUTime()
->ThreadPerCpu();
::benchmark::RegisterBenchmark((v_normalize_d.name() + "_double").c_str(),
v_normalize_d)
->MeasureProcessCPUTime()
->ThreadPerCpu();
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");

::benchmark::Initialize(&argc, argv);
::benchmark::RunSpecifiedBenchmarks();
Expand Down
22 changes: 2 additions & 20 deletions benchmarks/common/include/benchmark/common/benchmark_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ struct benchmark_base {
struct configuration {
/// Size of data sample to be used in benchmark
std::size_t m_samples{100u};
/// Run a number of operations before the benchmark
bool m_warmup = true;
// Sleep after building data sample
bool m_sleep = false;
// Size of data in warm-up round
std::size_t m_n_warmup{static_cast<std::size_t>(0.1f * m_samples)};
// Size of data in warm-up round
// Number of seconds to sleep
std::size_t m_n_sleep{1u};

/// Setters
Expand All @@ -37,15 +33,6 @@ struct benchmark_base {
m_samples = n;
return *this;
}
configuration& do_warmup(bool b) {
m_warmup = b;
return *this;
}
configuration& n_warmup(std::size_t n) {
m_n_warmup = n;
m_warmup = true;
return *this;
}
configuration& do_sleep(bool b) {
m_sleep = b;
return *this;
Expand All @@ -60,8 +47,6 @@ struct benchmark_base {
/// Getters
/// @{
std::size_t n_samples() const { return m_samples; }
constexpr bool do_warmup() const { return m_warmup; }
constexpr std::size_t n_warmup() const { return m_n_warmup; }
constexpr bool do_sleep() const { return m_sleep; }
constexpr std::size_t n_sleep() const { return m_n_sleep; }
/// @}
Expand Down Expand Up @@ -95,14 +80,11 @@ struct benchmark_base {
std::ostream& operator<<(std::ostream& os,
const benchmark_base::configuration& cfg) {
os << " -> running:\t " << cfg.n_samples() << " samples" << std::endl;
if (cfg.do_warmup()) {
os << " -> warmup: \t " << cfg.n_warmup() << " samples" << std::endl;
}
if (cfg.do_sleep()) {
os << " -> cool down:\t " << cfg.n_sleep() << "s" << std::endl;
}
os << std::endl;
return os;
}

} // namespace algebra
} // namespace algebra
Loading

0 comments on commit 747351d

Please sign in to comment.