diff --git a/benchmarks/CMakeLists.txt b/benchmarks/CMakeLists.txt index d3002c92..f701a3ba 100644 --- a/benchmarks/CMakeLists.txt +++ b/benchmarks/CMakeLists.txt @@ -23,20 +23,18 @@ target_include_directories( algebra_bench_array INTERFACE "$" ) target_link_libraries(algebra_bench_array INTERFACE algebra::array_cmath algebra::common_storage) -add_library( algebra::bench_array ALIAS algebra_bench_array ) - algebra_add_benchmark( array_getter "array/array_getter.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_array algebra::array_cmath ) + algebra_bench_array algebra::array_cmath ) algebra_add_benchmark( array_vector "array/array_vector.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_array algebra::array_cmath ) + algebra_bench_array algebra::array_cmath ) algebra_add_benchmark( array_transform3 "array/array_transform3.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_array algebra::array_cmath ) + algebra_bench_array algebra::array_cmath ) if( ALGEBRA_PLUGINS_INCLUDE_EIGEN ) add_library( algebra_bench_eigen INTERFACE ) @@ -44,20 +42,18 @@ if( ALGEBRA_PLUGINS_INCLUDE_EIGEN ) "$" ) target_link_libraries(algebra_bench_eigen INTERFACE algebra::eigen_eigen algebra::common_storage) - add_library( algebra::bench_eigen ALIAS algebra_bench_eigen ) - algebra_add_benchmark( eigen_getter "eigen/eigen_getter.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_eigen algebra::eigen_eigen ) + algebra_bench_eigen algebra::eigen_eigen ) algebra_add_benchmark( eigen_vector "eigen/eigen_vector.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_eigen algebra::eigen_eigen ) + algebra_bench_eigen algebra::eigen_eigen ) algebra_add_benchmark( eigen_transform3 "eigen/eigen_transform3.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_eigen algebra::eigen_eigen ) + algebra_bench_eigen algebra::eigen_eigen ) endif() if( ALGEBRA_PLUGINS_INCLUDE_VC ) @@ -67,20 +63,18 @@ if( ALGEBRA_PLUGINS_INCLUDE_VC ) target_link_libraries(algebra_bench_vc_aos INTERFACE 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_aos ) + 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_aos ) + 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_aos ) + algebra_bench_vc_aos algebra::vc_aos ) if( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang" ) add_library( algebra_bench_vc_soa INTERFACE ) @@ -89,19 +83,17 @@ if( ALGEBRA_PLUGINS_INCLUDE_VC ) target_link_libraries(algebra_bench_vc_soa INTERFACE algebra::vc_soa algebra::common_storage) - add_library( algebra::bench_vc_soa ALIAS algebra_bench_vc_soa ) - algebra_add_benchmark( vc_soa_getter "vc_soa/vc_soa_getter.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_vc_soa algebra::vc_soa ) + algebra_bench_vc_soa algebra::vc_soa ) algebra_add_benchmark( vc_soa_vector "vc_soa/vc_soa_vector.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_vc_soa algebra::vc_soa ) + algebra_bench_vc_soa algebra::vc_soa ) algebra_add_benchmark( vc_soa_transform3 "vc_soa/vc_soa_transform3.cpp" LINK_LIBRARIES benchmark::benchmark algebra::bench_common - algebra::bench_vc_soa algebra::vc_soa ) + algebra_bench_vc_soa algebra::vc_soa ) endif() endif() diff --git a/frontend/vc_aos/CMakeLists.txt b/frontend/vc_aos/CMakeLists.txt index 83a2b053..e00cddff 100644 --- a/frontend/vc_aos/CMakeLists.txt +++ b/frontend/vc_aos/CMakeLists.txt @@ -8,7 +8,7 @@ algebra_add_library( algebra_vc_aos vc_aos "include/algebra/vc_aos.hpp" ) target_link_libraries( algebra_vc_aos - INTERFACE algebra::common algebra::vc_storage algebra::cmath_math + INTERFACE algebra::common algebra::vc_aos_storage algebra::cmath_math algebra::vc_aos_math ) algebra_test_public_headers( algebra_vc_aos "algebra/vc_aos.hpp" ) diff --git a/frontend/vc_aos/include/algebra/vc_aos.hpp b/frontend/vc_aos/include/algebra/vc_aos.hpp index 4245f9d1..a32c3926 100644 --- a/frontend/vc_aos/include/algebra/vc_aos.hpp +++ b/frontend/vc_aos/include/algebra/vc_aos.hpp @@ -23,7 +23,7 @@ namespace vc_aos { /// @{ template -using transform3 = math::transform3, point2>; +using transform3 = math::transform3; /// @} @@ -42,11 +42,17 @@ using vc_aos::math::theta; /// @} -/// Function extracting a slice from the matrix used by -/// @c algebra::vc_aos::transform3 -template = true> -ALGEBRA_HOST_DEVICE inline vc_aos::vector3 vector( - const vc_aos::transform3::matrix44& m, +/// @name Getter functions on @c algebra::vc_aos::matrix_type +/// @{ + +using cmath::element; + +/// Function extracting a slice from matrix44 - const +template class array_t, + typename value_t, std::size_t N, + std::enable_if_t = true> +ALGEBRA_HOST_DEVICE inline const auto& vector( + const storage::matrix44& m, std::size_t #ifndef NDEBUG row @@ -66,15 +72,20 @@ ALGEBRA_HOST_DEVICE inline vc_aos::vector3 vector( case 3: return m.t; default: +#ifndef _MSC_VER + __builtin_unreachable(); +#else return m.x; +#endif } } -/// Function extracting a slice from the matrix used by -/// @c algebra::vc_aos::transform3 -template = true> -ALGEBRA_HOST_DEVICE inline vc_aos::vector3 vector( - const vc_aos::transform3::matrix44& m, +/// Function extracting a slice from matrix44 - non-const +template class array_t, + typename value_t, std::size_t N, + std::enable_if_t = true> +ALGEBRA_HOST_DEVICE inline auto& vector( + storage::matrix44& m, std::size_t #ifndef NDEBUG row @@ -94,15 +105,14 @@ ALGEBRA_HOST_DEVICE inline vc_aos::vector3 vector( case 3: return m.t; default: +#ifndef _MSC_VER + __builtin_unreachable(); +#else return m.x; +#endif } } -/// @name Getter functions on @c algebra::vc_aos::matrix_type -/// @{ - -using cmath::element; - /// @} } // namespace getter diff --git a/frontend/vc_cmath/CMakeLists.txt b/frontend/vc_cmath/CMakeLists.txt index 9c0245af..a20065a1 100644 --- a/frontend/vc_cmath/CMakeLists.txt +++ b/frontend/vc_cmath/CMakeLists.txt @@ -8,7 +8,7 @@ algebra_add_library( algebra_vc_cmath vc_cmath "include/algebra/vc_cmath.hpp" ) target_link_libraries( algebra_vc_cmath - INTERFACE algebra::common algebra::vc_storage algebra::cmath_math + INTERFACE algebra::common algebra::vc_aos_storage algebra::cmath_math algebra::vc_aos_math ) algebra_test_public_headers( algebra_vc_cmath "algebra/vc_cmath.hpp" ) diff --git a/frontend/vc_soa/CMakeLists.txt b/frontend/vc_soa/CMakeLists.txt index b6344424..d4980cca 100644 --- a/frontend/vc_soa/CMakeLists.txt +++ b/frontend/vc_soa/CMakeLists.txt @@ -9,6 +9,6 @@ algebra_add_library( algebra_vc_soa vc_soa "include/algebra/vc_soa.hpp" ) target_link_libraries( algebra_vc_soa INTERFACE algebra::common algebra::vc_soa_storage algebra::cmath_math - algebra::vc_soa_math ) + algebra::vc_soa_math algebra::vc_aos_math ) algebra_test_public_headers( algebra_vc_soa "algebra/vc_soa.hpp" ) diff --git a/frontend/vc_soa/include/algebra/vc_soa.hpp b/frontend/vc_soa/include/algebra/vc_soa.hpp index e89eb8aa..89a15ab6 100644 --- a/frontend/vc_soa/include/algebra/vc_soa.hpp +++ b/frontend/vc_soa/include/algebra/vc_soa.hpp @@ -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 */ @@ -8,6 +8,7 @@ #pragma once // Project include(s). +#include "algebra/math/impl/vc_aos_transform3.hpp" #include "algebra/math/vc_soa.hpp" #include "algebra/storage/vc_soa.hpp" @@ -32,7 +33,7 @@ namespace vc_soa { /// @{ template -using transform3 = math::transform3; +using transform3 = algebra::vc_aos::math::transform3; /// @} @@ -66,7 +67,8 @@ using vc_soa::math::normalize; } // namespace vector -namespace matrix { +// Produces clash with matrix typedefs in other plugins +/*namespace matrix { using size_type = vc_soa::size_type; @@ -76,6 +78,6 @@ using array_type = vc_soa::storage_type; template using matrix_type = vc_soa::matrix_type; -} // namespace matrix +}*/ // namespace matrix } // namespace algebra diff --git a/math/cmath/include/algebra/math/impl/cmath_getter.hpp b/math/cmath/include/algebra/math/impl/cmath_getter.hpp index 6d7b2199..ef0c31b5 100644 --- a/math/cmath/include/algebra/math/impl/cmath_getter.hpp +++ b/math/cmath/include/algebra/math/impl/cmath_getter.hpp @@ -23,7 +23,8 @@ namespace algebra::cmath { * @param v the input vector **/ template class array_t, - typename scalar_t, size_type N, std::enable_if_t= 2, bool> = true> + typename scalar_t, size_type N, + std::enable_if_t<(N >= 2) && std::is_scalar_v, bool> = true> ALGEBRA_HOST_DEVICE inline scalar_t phi( const array_t &v) noexcept { @@ -35,7 +36,8 @@ ALGEBRA_HOST_DEVICE inline scalar_t phi( * @param v the input vector **/ template class array_t, - typename scalar_t, size_type N, std::enable_if_t= 3, bool> = true> + typename scalar_t, size_type N, + std::enable_if_t<(N >= 3) && std::is_scalar_v, bool> = true> ALGEBRA_HOST_DEVICE inline scalar_t theta( const array_t &v) noexcept { @@ -48,7 +50,8 @@ ALGEBRA_HOST_DEVICE inline scalar_t theta( * @param v the input vector **/ template class array_t, - typename scalar_t, size_type N, std::enable_if_t= 2, bool> = true> + typename scalar_t, size_type N, + std::enable_if_t<(N >= 2) && std::is_scalar_v, bool> = true> ALGEBRA_HOST_DEVICE inline scalar_t perp( const array_t &v) noexcept { @@ -60,7 +63,8 @@ ALGEBRA_HOST_DEVICE inline scalar_t perp( * @param v the input vector **/ template class array_t, - typename scalar_t, size_type N, std::enable_if_t = true> + typename scalar_t, size_type N, + std::enable_if_t<(N == 2) && std::is_scalar_v, bool> = true> ALGEBRA_HOST_DEVICE inline scalar_t norm(const array_t &v) { return perp(v); @@ -71,7 +75,8 @@ ALGEBRA_HOST_DEVICE inline scalar_t norm(const array_t &v) { * @param v the input vector **/ template class array_t, - typename scalar_t, size_type N, std::enable_if_t= 3, bool> = true> + typename scalar_t, size_type N, + std::enable_if_t<(N >= 3) && std::is_scalar_v, bool> = true> ALGEBRA_HOST_DEVICE inline scalar_t norm(const array_t &v) { return algebra::math::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); @@ -83,7 +88,8 @@ ALGEBRA_HOST_DEVICE inline scalar_t norm(const array_t &v) { * @param v the input vector **/ template class array_t, - typename scalar_t, size_type N, std::enable_if_t= 3, bool> = true> + typename scalar_t, size_type N, + std::enable_if_t<(N >= 3) && std::is_scalar_v, bool> = true> ALGEBRA_HOST_DEVICE inline scalar_t eta( const array_t &v) noexcept { diff --git a/math/vc_aos/CMakeLists.txt b/math/vc_aos/CMakeLists.txt index 64a723c7..dbec5856 100644 --- a/math/vc_aos/CMakeLists.txt +++ b/math/vc_aos/CMakeLists.txt @@ -11,7 +11,7 @@ algebra_add_library( algebra_vc_aos_math vc_aos_math "include/algebra/math/impl/vc_aos_transform3.hpp" "include/algebra/math/impl/vc_aos_vector.hpp" ) target_link_libraries( algebra_vc_aos_math - INTERFACE Vc::Vc algebra::common algebra::common_math algebra::vc_storage - algebra::cmath_math ) + INTERFACE Vc::Vc algebra::common algebra::common_math + algebra::vc_aos_storage ) algebra_test_public_headers( algebra_vc_aos_math "algebra/math/vc_aos.hpp" ) diff --git a/math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp b/math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp index d40f8ff8..2da7e37f 100644 --- a/math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp +++ b/math/vc_aos/include/algebra/math/impl/vc_aos_transform3.hpp @@ -8,9 +8,10 @@ #pragma once // Project include(s). -#include "algebra/math/cmath.hpp" -#include "algebra/math/impl/vc_aos_vector.hpp" +#include "algebra/math/common.hpp" #include "algebra/qualifiers.hpp" +#include "algebra/storage/matrix44.hpp" +#include "algebra/storage/vector.hpp" // Vc include(s). #ifdef _MSC_VER @@ -26,95 +27,46 @@ namespace algebra::vc_aos::math { -namespace internal { - -/// 4x4 matrix type used by @c algebra::vc_aos::math::transform3 -template -struct matrix44 { - - /// Equality operator between two matrices - bool operator==(const matrix44 &rhs) const { - return ((x == rhs.x).isFull() && (y == rhs.y).isFull() && - (z == rhs.z).isFull() && (t == rhs.t).isFull()); - } - - /// Data variables - Vc::SimdArray x, y, z, t; - -}; // struct matrix44 - -/// Functor used to access elements of Vc matrices -template