-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR is based on the previous development for an SoA Vc-based alge…
…bra plugin and adds the transform3 implementation, including a test and benchmarks. Like the current vc_vc plugin, it uses the vector3 type as column vectors in the 4x4 matrix type that is used by the transform3. Elements that are known to be equal to zero or one are optimized away in the inversion and determinant calculations.
- Loading branch information
1 parent
c21dddd
commit 5b0bd48
Showing
18 changed files
with
855 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** Algebra plugins library, part of the ACTS project | ||
* | ||
* (c) 2023 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
// Project include(s) | ||
#include "algebra/array_cmath.hpp" | ||
#include "benchmark/array/data_generator.hpp" | ||
#include "benchmark/common/benchmark_transform3.hpp" | ||
|
||
// Benchmark include | ||
#include <benchmark/benchmark.h> | ||
|
||
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); | ||
|
||
transform3_bm<array::transform3<float>> v_trf_s{cfg}; | ||
transform3_bm<array::transform3<double>> v_trf_d{cfg}; | ||
|
||
std::cout << "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(); | ||
|
||
::benchmark::Initialize(&argc, argv); | ||
::benchmark::RunSpecifiedBenchmarks(); | ||
::benchmark::Shutdown(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
benchmarks/common/include/benchmark/common/benchmark_transform3.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** Algebra plugins library, part of the ACTS project | ||
* | ||
* (c) 2023 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
// Project include(s) | ||
#include "benchmark_vector.hpp" | ||
|
||
// System include(s) | ||
#include <chrono> | ||
#include <iostream> | ||
#include <string> | ||
#include <thread> | ||
#include <vector> | ||
|
||
namespace algebra { | ||
|
||
template <typename transform3_t> | ||
void fill_random_trf(std::vector<transform3_t> &); | ||
|
||
/// Benchmark for vector operations | ||
template <typename transform3_t> | ||
struct transform3_bm : public vector_bm<typename transform3_t::vector3> { | ||
private: | ||
using base_type = vector_bm<typename transform3_t::vector3>; | ||
|
||
public: | ||
/// Prefix for the benchmark name | ||
inline static const std::string bm_name{"transform3"}; | ||
|
||
std::vector<transform3_t> trfs; | ||
|
||
/// No default construction: Cannot prepare data | ||
transform3_bm() = delete; | ||
std::string name() const override { return base_type::name + "_" + bm_name; } | ||
|
||
/// Construct from an externally provided configuration @param cfg | ||
transform3_bm(benchmark_base::configuration cfg) : base_type{cfg} { | ||
|
||
const std::size_t n_data{this->m_cfg.n_samples() + this->m_cfg.n_warmup()}; | ||
|
||
trfs.reserve(n_data); | ||
|
||
fill_random_trf(trfs); | ||
} | ||
|
||
/// Clear state | ||
virtual ~transform3_bm() { trfs.clear(); } | ||
|
||
/// Benchmark case | ||
void operator()(::benchmark::State &state) override { | ||
|
||
const std::size_t n_samples{this->m_cfg.n_samples()}; | ||
const std::size_t n_warmup{this->m_cfg.n_warmup()}; | ||
|
||
// Spin down before benchmark (Thread zero is counting the clock) | ||
if (state.thread_index() == 0 && this->m_cfg.do_sleep()) { | ||
std::this_thread::sleep_for(std::chrono::seconds(this->m_cfg.n_sleep())); | ||
} | ||
|
||
// Run the benchmark | ||
for (auto _ : state) { | ||
// Warm-up | ||
state.PauseTiming(); | ||
if (this->m_cfg.do_warmup()) { | ||
for (std::size_t i{0u}; i < n_warmup; ++i) { | ||
::benchmark::DoNotOptimize( | ||
this->trfs[i].vector_to_global(this->a[i])); | ||
benchmark::ClobberMemory(); | ||
} | ||
} | ||
state.ResumeTiming(); | ||
|
||
for (std::size_t i{n_warmup}; i < n_samples + n_warmup; ++i) { | ||
::benchmark::DoNotOptimize(this->trfs[i].vector_to_global(this->a[i])); | ||
benchmark::ClobberMemory(); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
} // namespace algebra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** Algebra plugins library, part of the ACTS project | ||
* | ||
* (c) 2023 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
// Project include(s) | ||
#include "algebra/eigen_eigen.hpp" | ||
#include "benchmark/common/benchmark_transform3.hpp" | ||
#include "benchmark/eigen/data_generator.hpp" | ||
|
||
// Benchmark include | ||
#include <benchmark/benchmark.h> | ||
|
||
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); | ||
|
||
transform3_bm<eigen::transform3<float>> v_trf_s{cfg}; | ||
transform3_bm<eigen::transform3<double>> v_trf_d{cfg}; | ||
|
||
std::cout << "Algebra-Plugins 'transform3' benchmark (Eigen3)\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(); | ||
|
||
::benchmark::Initialize(&argc, argv); | ||
::benchmark::RunSpecifiedBenchmarks(); | ||
::benchmark::Shutdown(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.