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 Apr 13, 2024
1 parent d4e78a6 commit b246871
Show file tree
Hide file tree
Showing 27 changed files with 133 additions and 102 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
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,21 @@ struct transform3_bm : public vector_bm<typename transform3_t::vector3> {
state.PauseTiming();
if (this->m_cfg.do_warmup()) {
for (std::size_t i{0u}; i < n_warmup; ++i) {
::benchmark::DoNotOptimize(this->trfs[i].point_to_global(this->a[i]));
::benchmark::DoNotOptimize(this->trfs[i].point_to_local(this->a[i]));
::benchmark::DoNotOptimize(
this->trfs[i].vector_to_global(this->a[i]));
::benchmark::DoNotOptimize(this->trfs[i].vector_to_local(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].point_to_global(this->a[i]));
::benchmark::DoNotOptimize(this->trfs[i].point_to_local(this->a[i]));
::benchmark::DoNotOptimize(this->trfs[i].vector_to_global(this->a[i]));
::benchmark::DoNotOptimize(this->trfs[i].vector_to_local(this->a[i]));
benchmark::ClobberMemory();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#pragma once

// Project include(s)
#include "algebra/vc_vc.hpp"
#include "algebra/vc_aos.hpp"

// System include(s)
#include <algorithm>
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/vc_aos/vc_aos_getter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Project include(s)
#include "algebra/vc_vc.hpp"
#include "algebra/vc_aos.hpp"
#include "benchmark/common/benchmark_getter.hpp"
#include "benchmark/vc_aos/data_generator.hpp"

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/vc_aos/vc_aos_transform3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Project include(s)
#include "algebra/vc_vc.hpp"
#include "algebra/vc_aos.hpp"
#include "benchmark/common/benchmark_transform3.hpp"
#include "benchmark/vc_aos/data_generator.hpp"

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/vc_aos/vc_aos_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Project include(s)
#include "algebra/vc_vc.hpp"
#include "algebra/vc_aos.hpp"
#include "benchmark/common/benchmark_vector.hpp"
#include "benchmark/vc_aos/data_generator.hpp"

Expand Down
2 changes: 1 addition & 1 deletion frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ if( ALGEBRA_PLUGINS_INCLUDE_SMATRIX )
endif()

if( ALGEBRA_PLUGINS_INCLUDE_VC )
add_subdirectory( vc_aos )
add_subdirectory( vc_cmath )
add_subdirectory( vc_vc )
if( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang" )
add_subdirectory( vc_soa )
endif()
Expand Down
2 changes: 2 additions & 0 deletions frontend/array_cmath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ algebra_add_library( algebra_array_cmath array_cmath
"include/algebra/array_cmath.hpp" )
target_link_libraries( algebra_array_cmath
INTERFACE algebra::common algebra::array_storage algebra::cmath_math )
target_compile_options(algebra_array_cmath INTERFACE
"-ftree-vectorize" "-mavx2")
algebra_test_public_headers( algebra_array_cmath
"algebra/array_cmath.hpp" )
12 changes: 6 additions & 6 deletions frontend/vc_vc/CMakeLists.txt → frontend/vc_aos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# Mozilla Public License Version 2.0

# Set up the library.
algebra_add_library( algebra_vc_vc vc_vc
"include/algebra/vc_vc.hpp" )
target_link_libraries( algebra_vc_vc
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
algebra::vc_math )
algebra_test_public_headers( algebra_vc_vc
"algebra/vc_vc.hpp" )
algebra::vc_aos_math )
algebra_test_public_headers( algebra_vc_aos
"algebra/vc_aos.hpp" )
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

// Project include(s).
#include "algebra/math/cmath.hpp"
#include "algebra/math/vc.hpp"
#include "algebra/storage/vc.hpp"
#include "algebra/math/vc_aos.hpp"
#include "algebra/storage/vc_aos.hpp"

// System include(s).
#include <cassert>
Expand Down Expand Up @@ -58,15 +58,15 @@ ALGEBRA_HOST_DEVICE inline vc::vector3<float> vector(
assert(col < 4);
switch (col) {
case 0:
return {m.x[0], m.x[1], m.x[2]};
return m.x;
case 1:
return {m.y[0], m.y[1], m.y[2]};
return m.y;
case 2:
return {m.z[0], m.z[1], m.z[2]};
return m.z;
case 3:
return {m.t[0], m.t[1], m.t[2]};
return m.t;
default:
return {m.x[0], m.x[1], m.x[2]};
return m.x;
}
}

Expand All @@ -86,15 +86,15 @@ ALGEBRA_HOST_DEVICE inline vc::vector3<double> vector(
assert(col < 4);
switch (col) {
case 0:
return {m.x[0], m.x[1], m.x[2]};
return m.x;
case 1:
return {m.y[0], m.y[1], m.y[2]};
return m.y;
case 2:
return {m.z[0], m.z[1], m.z[2]};
return m.z;
case 3:
return {m.t[0], m.t[1], m.t[2]};
return m.t;
default:
return {m.x[0], m.x[1], m.x[2]};
return m.x;
}
}

Expand All @@ -120,15 +120,4 @@ using vc::math::normalize;

} // namespace vector

namespace matrix {

using size_type = vc::size_type;

template <typename T, size_type N>
using array_type = vc::storage_type<T, N>;

template <typename T, size_type ROWS, size_type COLS>
using matrix_type = vc::matrix_type<T, ROWS, COLS>;

} // namespace matrix
} // namespace algebra
2 changes: 1 addition & 1 deletion frontend/vc_cmath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ 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
algebra::vc_math )
algebra::vc_aos_math )
algebra_test_public_headers( algebra_vc_cmath
"algebra/vc_cmath.hpp" )
4 changes: 2 additions & 2 deletions frontend/vc_cmath/include/algebra/vc_cmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

// Project include(s).
#include "algebra/math/cmath.hpp"
#include "algebra/math/vc.hpp"
#include "algebra/storage/vc.hpp"
#include "algebra/math/vc_aos.hpp"
#include "algebra/storage/vc_aos.hpp"

/// @name Operators on @c algebra::vc types
/// @{
Expand Down
2 changes: 1 addition & 1 deletion math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if( ALGEBRA_PLUGINS_INCLUDE_SMATRIX )
add_subdirectory( smatrix )
endif()
if( ALGEBRA_PLUGINS_INCLUDE_VC )
add_subdirectory( vc )
add_subdirectory( vc_aos )
if( NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang" )
add_subdirectory( vc_soa )
endif()
Expand Down
17 changes: 0 additions & 17 deletions math/vc/CMakeLists.txt

This file was deleted.

17 changes: 17 additions & 0 deletions math/vc_aos/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Algebra plugins library, part of the ACTS project (R&D line)
#
# (c) 2021-2023 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

# Set up the library.
algebra_add_library( algebra_vc_aos_math vc_aos_math
"include/algebra/math/vc_aos.hpp"
"include/algebra/math/impl/vc_aos_getter.hpp"
"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 )
algebra_test_public_headers( algebra_vc_aos_math
"algebra/math/vc_aos.hpp" )
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

// Project include(s).
#include "algebra/math/cmath.hpp"
#include "algebra/math/impl/vc_vector.hpp"
#include "algebra/math/impl/vc_aos_vector.hpp"
#include "algebra/qualifiers.hpp"

// Vc include(s).
Expand Down Expand Up @@ -135,10 +135,14 @@ struct transform3 {
ALGEBRA_HOST_DEVICE
transform3(const vector3 &t, const vector3 &x, const vector3 &y,
const vector3 &z, bool get_inverse = true) {
_data.x = {x[0], x[1], x[2], 0.f};
_data.y = {y[0], y[1], y[2], 0.f};
_data.z = {z[0], z[1], z[2], 0.f};
_data.t = {t[0], t[1], t[2], 1.f};
_data.x = x;
_data.y = y;
_data.z = z;
_data.t = t;
_data.x[3] = 0.f;
_data.y[3] = 0.f;
_data.z[3] = 0.f;
_data.t[3] = 1.f;

if (get_inverse) {
_data_inv = invert(_data);
Expand Down Expand Up @@ -166,7 +170,8 @@ struct transform3 {
_data.x = {1.f, 0.f, 0.f, 0.f};
_data.y = {0.f, 1.f, 0.f, 0.f};
_data.z = {0.f, 0.f, 1.f, 0.f};
_data.t = {t[0], t[1], t[2], 1.f};
_data.t = t;
_data.t[3] = 1.f;

_data_inv = invert(_data);
}
Expand Down Expand Up @@ -320,8 +325,9 @@ struct transform3 {
///
/// @param m is the rotation matrix
/// @param v is the vector to be rotated
ALGEBRA_HOST_DEVICE
static inline auto rotate(const matrix44 &m, const vector3 &v) {
template <typename vector3_type>
ALGEBRA_HOST_DEVICE static inline auto rotate(const matrix44 &m,
const vector3_type &v) {

return m.x * v[0] + m.y * v[1] + m.z * v[2];
}
Expand All @@ -339,9 +345,21 @@ struct transform3 {
return submatrix;
}

/// This method retrieves the translation of a transform
/// This method retrieves x axis
ALGEBRA_HOST_DEVICE
inline const auto &x() const { return _data.x; }

/// This method retrieves y axis
ALGEBRA_HOST_DEVICE
inline const auto &y() const { return _data.y; }

/// This method retrieves z axis
ALGEBRA_HOST_DEVICE
inline const auto &z() const { return _data.z; }

/// This method retrieves the translation
ALGEBRA_HOST_DEVICE
inline point3 translation() const { return _data.t; }
inline const auto &translation() const { return _data.t; }

/// This method retrieves the 4x4 matrix of a transform
ALGEBRA_HOST_DEVICE
Expand All @@ -359,7 +377,8 @@ struct transform3 {
/// @param v is the point to be transformed
///
/// @return a global point
ALGEBRA_HOST_DEVICE inline auto point_to_global(const point3 &p) const {
template <typename point3_type>
ALGEBRA_HOST_DEVICE inline auto point_to_global(const point3_type &p) const {

return _data.x * p[0] + _data.y * p[1] + _data.z * p[2] + _data.t;
}
Expand All @@ -372,7 +391,8 @@ struct transform3 {
/// @param v is the point to be transformed
///
/// @return a local point
ALGEBRA_HOST_DEVICE inline auto point_to_local(const point3 &p) const {
template <typename point3_type>
ALGEBRA_HOST_DEVICE inline auto point_to_local(const point3_type &p) const {

return _data_inv.x * p[0] + _data_inv.y * p[1] + _data_inv.z * p[2] +
_data_inv.t;
Expand All @@ -381,25 +401,28 @@ struct transform3 {
/// This method transform from a vector from the local 3D cartesian frame
/// to the global 3D cartesian frame
///
/// @tparam vector_type 3D vector
/// @tparam vector3_type 3D vector
///
/// @param v is the vector to be transformed
///
/// @return a vector in global coordinates
ALGEBRA_HOST_DEVICE inline auto vector_to_global(const vector3 &v) const {
template <typename vector3_type>
ALGEBRA_HOST_DEVICE inline auto vector_to_global(
const vector3_type &v) const {

return rotate(_data, v);
}

/// This method transform from a vector from the global 3D cartesian frame
/// into the local 3D cartesian frame
///
/// @tparam vector_type 3D vector
/// @tparam vector3_type 3D vector
///
/// @param v is the vector to be transformed
///
/// @return a vector in global coordinates
ALGEBRA_HOST_DEVICE inline auto vector_to_local(const vector3 &v) const {
template <typename vector3_type>
ALGEBRA_HOST_DEVICE inline auto vector_to_local(const vector3_type &v) const {

return rotate(_data_inv, v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
#pragma once

// Project include(s).
#include "algebra/math/impl/vc_getter.hpp"
#include "algebra/math/impl/vc_transform3.hpp"
#include "algebra/math/impl/vc_vector.hpp"
#include "algebra/math/impl/vc_aos_getter.hpp"
#include "algebra/math/impl/vc_aos_transform3.hpp"
#include "algebra/math/impl/vc_aos_vector.hpp"
Loading

0 comments on commit b246871

Please sign in to comment.