Skip to content

Commit

Permalink
This adds a new vector wrapper class that allows for an SoA layout, i…
Browse files Browse the repository at this point in the history
…n particular, to enable us to use the Vc::Vector type efficiently. The new storage/vector keeps an array-like data structure, that holds the vector elements (say, x, y, z). Both the array type, as well as the value type of the elements are templated (storage/vector< algebraic vector dim, aos/soa value type (scalar vs e.g SIMD vector), array-like storage for the algebraic vector elements >), so that combinations like these are possible:

    3-dim AoS std::array based vector (not necessary, since this would essentially duplicate the array plugin, while begin more complicated): storage::vector<3, scalar_t, std::array>
    3-dim AoS vertical vectorized (Not there, yet, but would re-implement the current vc_vc plugin, while making the extra vc_array4 wrapper superfluous): storage::vector<3, scalar_t, Vc::SimdArray>
    3-dim SoA of size N, std::array based: storage::vector<3, std::array<scalar_t, N>, std::array>
    3-dim vetorized SoA (in this PR): storage::vector<3, Vc::Vector<scalar_t>, std::array>

Also adds benchmarks to compare to the std::array and Eigen AoS plugins.
  • Loading branch information
niermann999 committed Sep 21, 2023
1 parent c0b49af commit c21dddd
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct vector_binaryOP_bm : public vector_bm<vector_t<scalar_t>> {
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) and this->m_cfg.do_sleep()) {
if (state.thread_index() == 0 and this->m_cfg.do_sleep()) {
std::this_thread::sleep_for(std::chrono::seconds(this->m_cfg.n_sleep()));
}

Expand Down
2 changes: 0 additions & 2 deletions frontend/vc_soa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ algebra_add_library( algebra_vc_soa vc_soa
target_link_libraries( algebra_vc_soa
INTERFACE algebra::common algebra::vc_soa_storage algebra::cmath_math
algebra::vc_soa_math )
algebra_test_public_headers( algebra_vc_soa
"algebra/vc_soa.hpp" )
1 change: 1 addition & 0 deletions math/cmath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ algebra_add_library(algebra_cmath_math cmath_math
"include/algebra/math/impl/cmath_operators.hpp"
"include/algebra/math/impl/cmath_transform3.hpp"
"include/algebra/math/impl/cmath_vector.hpp"
"include/algebra/math/impl/cmath_vector_soa.hpp"
# algorithms include
"include/algebra/math/algorithms/matrix/decomposition/partial_pivot_lud.hpp"
"include/algebra/math/algorithms/matrix/determinant/cofactor.hpp"
Expand Down
2 changes: 0 additions & 2 deletions math/vc_soa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ algebra_add_library( algebra_vc_soa_math vc_soa_math
"include/algebra/math/impl/vc_soa_vector.hpp" )
target_link_libraries( algebra_vc_soa_math
INTERFACE algebra::common algebra::common_math algebra::common_storage Vc::Vc )
algebra_test_public_headers( algebra_vc_soa_math
"algebra/math/vc_soa.hpp" )
3 changes: 1 addition & 2 deletions math/vc_soa/include/algebra/math/impl/vc_soa_getter.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/** Algebra plugins library, part of the ACTS project
*
* (c) 2023 CERN for the benefit of the ACTS project
* (c) 2022-2023 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

// Project include(s).
#include "algebra/math/impl/vc_soa_vector.hpp"
#include "algebra/qualifiers.hpp"
#include "algebra/storage/vector.hpp"

Expand Down
5 changes: 4 additions & 1 deletion math/vc_soa/include/algebra/math/impl/vc_soa_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#pragma warning(pop)
#endif // MSVC

// System include(s)
#include <cmath>

namespace algebra::vc_soa::math {

/// Cross product between two input vectors - 3 Dim
Expand Down Expand Up @@ -87,4 +90,4 @@ normalize(const storage::vector<N, Vc::Vector<scalar_t>, array_t> &v) {
// return Vc::rsqrt(dot(v, v)) * v;
}

} // namespace algebra::vc_soa::math
} // namespace algebra::vc_soa::math
4 changes: 3 additions & 1 deletion math/vc_soa/include/algebra/math/vc_soa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
#pragma once

// Project include(s).
// clang-format off
#include "algebra/math/impl/vc_soa_vector.hpp"
#include "algebra/math/impl/vc_soa_getter.hpp"
#include "algebra/math/impl/vc_soa_vector.hpp"
// clang-format on
2 changes: 0 additions & 2 deletions storage/vc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ algebra_add_library( algebra_vc_storage vc_storage
"include/algebra/storage/impl/vc_array4_wrapper.hpp" )
target_link_libraries( algebra_vc_storage
INTERFACE algebra::common algebra::common_storage Vc::Vc )
algebra_test_public_headers( algebra_vc_storage
"algebra/storage/vc.hpp" )
2 changes: 0 additions & 2 deletions storage/vc_soa/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ algebra_add_library( algebra_vc_soa_storage vc_soa_storage
"include/algebra/storage/vc_soa.hpp" )
target_link_libraries( algebra_vc_soa_storage
INTERFACE algebra::common algebra::common_storage Vc::Vc )
algebra_test_public_headers( algebra_vc_soa_storage
"algebra/storage/vc_soa.hpp" )

0 comments on commit c21dddd

Please sign in to comment.