Skip to content

Commit

Permalink
Merge pull request #883 from niermann999/feat-refactored-algebra
Browse files Browse the repository at this point in the history
ref: streamline algebra-plugins interface
  • Loading branch information
stephenswat authored Dec 7, 2024
2 parents 17d9b55 + 8864767 commit 033b4fc
Show file tree
Hide file tree
Showing 110 changed files with 853 additions and 1,283 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
run: |
cd build
source ${GITHUB_WORKSPACE}/.github/ci_setup.sh ${{ matrix.PLATFORM.NAME }}
ctest -R detray_unit_test_. -E ._eigen --output-on-failure
ctest -R detray_unit_test_. -E "._eigen|._vc_aos" --output-on-failure
# Containerised build jobs.
device-container:
Expand Down
18 changes: 10 additions & 8 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Detray library, part of the ACTS project (R&D line)
#
# (c) 2021-2023 CERN for the benefit of the ACTS project
# (c) 2021-2024 CERN for the benefit of the ACTS project
#
# Mozilla Public License Version 2.0

Expand All @@ -11,21 +11,23 @@ message(STATUS "Building 'detray::core' component")
file(
GLOB _detray_core_public_headers
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"include/detray/coordinates/*.hpp"
"include/detray/builders/*.hpp"
"include/detray/core/*.hpp"
"include/detray/definitions/*.hpp"
"include/detray/geometry/coordinates/*.hpp"
"include/detray/geometry/shapes/*.hpp"
"include/detray/geometry/*.hpp"
"include/detray/grids/*.hpp"
"include/detray/intersection/bounding_box/*.hpp"
"include/detray/intersection/*.hpp"
"include/detray/masks/*.hpp"
"include/detray/materials/*.hpp"
"include/detray/navigation/accelerators/*.hpp"
"include/detray/navigation/intersection/bounding_box/*.hpp"
"include/detray/navigation/intersection/soa/*.hpp"
"include/detray/navigation/intersection/*.hpp"
"include/detray/navigation/*.hpp"
"include/detray/propagator/actors/*.hpp"
"include/detray/propagator/*.hpp"
"include/detray/surface_finders/grid/*.hpp"
"include/detray/surface_finders/*.hpp"
"include/detray/tools/*.hpp"
"include/detray/tracks/*.hpp"
"include/detray/utils/grid/*.hpp"
"include/detray/utils/ranges/*.hpp"
"include/detray/utils/*.hpp"
)
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/builders/cylinder_portal_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class cylinder_portal_generator final

for (const auto &sf_desc : surfaces) {
const auto &trf = transforms.at(sf_desc.transform());
mean += getter::perp(trf.translation());
mean += vector::perp(trf.translation());
}

return static_cast<scalar_t>(mean /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#include "detray/definitions/detail/indexing.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/materials/material.hpp"
#include "detray/materials/material_rod.hpp"
#include "detray/materials/predefined_materials.hpp"
#include "detray/utils/ranges.hpp"

// System include(s)
#include <sstream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "detray/builders/volume_builder_interface.hpp"
#include "detray/materials/material.hpp"
#include "detray/materials/predefined_materials.hpp"
#include "detray/utils/ranges.hpp"

// System include(s)
#include <iostream>
Expand Down
2 changes: 2 additions & 0 deletions core/include/detray/builders/material_map_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#include "detray/geometry/shapes/cylinder2D.hpp"
#include "detray/geometry/shapes/ring2D.hpp"
#include "detray/materials/material.hpp"
#include "detray/materials/material_rod.hpp"
#include "detray/materials/material_slab.hpp"
#include "detray/materials/predefined_materials.hpp"
#include "detray/utils/grid/detail/axis.hpp"
#include "detray/utils/ranges.hpp"

// System include(s)
Expand Down
2 changes: 1 addition & 1 deletion core/include/detray/builders/volume_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class volume_builder : public volume_builder_interface<detector_t> {
const typename detector_t::point3_type& t,
const typename detector_t::vector3_type& x,
const typename detector_t::vector3_type& z) override {
m_trf = typename detector_t::transform3_type{t, z, x, true};
m_trf = typename detector_t::transform3_type{t, z, x};
}

/// Add data for (a) new surface(s) to the builder
Expand Down
95 changes: 20 additions & 75 deletions core/include/detray/definitions/detail/algebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,103 +21,48 @@
#error "No algebra plugin selected! Please link to one of the algebra plugins."
#endif

// Project include(s)
#include "detray/utils/concepts.hpp"

// System include(s)
#include <type_traits>
// Algebra-plugins include(s)
#include "algebra/utils/print.hpp"

namespace detray {

namespace detail {
/// The detray scalar types (can be SIMD)
/// @{
template <typename T>
struct get_scalar {};

// TODO replace by scalar concept from algebra-plugins
template <concepts::arithmetic T>
struct get_scalar<T> {
using scalar = T;
};

template <typename T>
requires(!std::same_as<typename T::scalar, void>) struct get_scalar<T> {
using scalar = typename T::scalar;
};
/// @}

/// The detray algebra types (can be SIMD)
/// @{
template <typename T>
struct get_algebra {};

template <typename T>
requires(!std::same_as<typename T::point3D, void>) struct get_algebra<T> {
using point2D = typename T::point2D;
using point3D = typename T::point3D;
using vector3D = typename T::vector3D;
using transform3D = typename T::transform3D;
};
/// @}

/// The detray matrix types
/// @{
template <typename T>
struct get_matrix {};

template <typename T>
requires(
!std::same_as<typename T::matrix_operator, void>) struct get_matrix<T> {
using matrix_operator = typename T::matrix_operator;
using size_type = typename matrix_operator::size_ty;

template <std::size_t ROWS, std::size_t COLS>
using matrix = typename matrix_operator::template matrix_type<
static_cast<size_type>(ROWS), static_cast<size_type>(COLS)>;
};
/// @}
// Pull in the print operator definitions for the algebra types
using algebra::operator<<;

} // namespace detail
template <typename A>
using dvalue = typename algebra::get_value_t<A>;

template <template <typename> class A, typename T>
using dsimd = typename A<float>::template simd<T>;
template <typename A>
using dbool = typename algebra::get_boolean_t<A>;

template <typename A = detray::scalar>
using dscalar = typename detail::get_scalar<A>::scalar;
template <typename A, typename T>
using dsimd = algebra::get_simd_t<A, T>;

template <typename A>
using dpoint2D = typename detail::get_algebra<A>::point2D;
using dsize_type = algebra::get_size_t<A>;

template <typename A>
using dpoint3D = typename detail::get_algebra<A>::point3D;
using dscalar = algebra::get_scalar_t<A>;

template <typename A>
using dvector3D = typename detail::get_algebra<A>::vector3D;
using dpoint2D = algebra::get_point2D_t<A>;

template <typename A>
using dtransform3D = typename detail::get_algebra<A>::transform3D;
using dpoint3D = algebra::get_point3D_t<A>;

template <typename A>
using dmatrix_operator = typename detail::get_matrix<A>::matrix_operator;
using dvector3D = algebra::get_vector3D_t<A>;

template <typename A>
using dsize_type = typename detail::get_matrix<A>::size_type;
using dtransform3D = algebra::get_transform3D_t<A>;

template <typename A, std::size_t R, std::size_t C>
using dmatrix = typename detail::get_matrix<A>::template matrix<R, C>;
using dmatrix = algebra::get_matrix_t<A, R, C>;

namespace concepts {
namespace detail {

/// Check if an algebra has soa layout
/// @{
template <typename A>
concept soa_algebra = (!concepts::arithmetic<dscalar<A>>);
using namespace ::algebra::boolean;

template <typename A>
concept aos_algebra = (!concepts::soa_algebra<A>);
/// @}

} // namespace concepts
} // namespace detail

} // namespace detray
76 changes: 0 additions & 76 deletions core/include/detray/definitions/detail/boolean.hpp

This file was deleted.

Loading

0 comments on commit 033b4fc

Please sign in to comment.