From 132befc65bfdd7b11b1f08eb98240e6cea718aee Mon Sep 17 00:00:00 2001 From: "Seth R. Johnson" Date: Sat, 20 Jul 2024 21:04:44 -0400 Subject: [PATCH] Refactor types to reduce duplication and cyclic dependencies (#1327) * Move real2/size2 to geocel types * Refactor LDG infrastructure to reduce circular dependencies --- src/celeritas/grid/GridIdFinder.hh | 1 + src/corecel/OpaqueId.hh | 33 ++------- src/corecel/cont/Span.hh | 28 +------ src/corecel/cont/detail/SpanImpl.hh | 10 ++- src/corecel/data/LdgIterator.hh | 46 ++++++++---- src/corecel/data/detail/CollectionImpl.hh | 2 +- src/corecel/data/detail/LdgIteratorImpl.hh | 60 +++++++-------- src/corecel/data/detail/TypeTraits.hh | 74 +++++++++++++++++++ src/corecel/math/Quantity.hh | 31 +------- src/geocel/GeoParamsInterface.hh | 2 +- src/geocel/Types.hh | 9 ++- src/geocel/rasterize/ImageData.hh | 2 - src/orange/g4org/SolidConverter.cc | 14 ++-- src/orange/orangeinp/IntersectRegion.hh | 7 -- src/orange/orangeinp/PolySolid.cc | 2 - src/orange/orangeinp/PolySolid.hh | 1 - src/orange/orangeinp/detail/PolygonUtils.hh | 3 - src/orange/univ/detail/InfixEvaluator.hh | 1 + src/orange/univ/detail/LogicEvaluator.hh | 1 + src/orange/univ/detail/RaggedRightIndexer.hh | 15 ++-- test/corecel/data/LdgIterator.test.cc | 14 ++-- test/geocel/rasterize/Image.test.cc | 2 - test/orange/orangeinp/IntersectRegion.test.cc | 1 - test/orange/orangeinp/PolySolid.test.cc | 2 - 24 files changed, 187 insertions(+), 174 deletions(-) create mode 100644 src/corecel/data/detail/TypeTraits.hh diff --git a/src/celeritas/grid/GridIdFinder.hh b/src/celeritas/grid/GridIdFinder.hh index 5c1be9a6a1..fee79adfdb 100644 --- a/src/celeritas/grid/GridIdFinder.hh +++ b/src/celeritas/grid/GridIdFinder.hh @@ -10,6 +10,7 @@ #include "corecel/Assert.hh" #include "corecel/Macros.hh" #include "corecel/cont/Span.hh" +#include "corecel/data/LdgIterator.hh" #include "corecel/math/Algorithms.hh" namespace celeritas diff --git a/src/corecel/OpaqueId.hh b/src/corecel/OpaqueId.hh index 5f52241d83..e315e7a76a 100644 --- a/src/corecel/OpaqueId.hh +++ b/src/corecel/OpaqueId.hh @@ -17,12 +17,6 @@ namespace celeritas { -namespace detail -{ -template -struct LdgLoader; -} // namespace detail - //---------------------------------------------------------------------------// /*! * Type-safe index for accessing an array or collection of data. @@ -103,6 +97,9 @@ class OpaqueId //! Get the value without checking for validity (atypical) CELER_CONSTEXPR_FUNCTION size_type unchecked_get() const { return value_; } + //! Access the underlying data for more efficient loading from memory + CELER_CONSTEXPR_FUNCTION size_type const* data() const { return &value_; } + private: size_type value_; @@ -113,7 +110,6 @@ class OpaqueId { return static_cast(-1); } - friend detail::LdgLoader const, void>; }; //---------------------------------------------------------------------------// @@ -139,6 +135,7 @@ CELER_DEFINE_OPAQUEID_CMP(>=) #undef CELER_DEFINE_OPAQUEID_CMP +//---------------------------------------------------------------------------// //! Allow less-than comparison with *integer* for container comparison template CELER_CONSTEXPR_FUNCTION bool operator<(OpaqueId lhs, U rhs) @@ -147,6 +144,7 @@ CELER_CONSTEXPR_FUNCTION bool operator<(OpaqueId lhs, U rhs) return lhs && (U(lhs.unchecked_get()) < rhs); } +//---------------------------------------------------------------------------// //! Allow less-than-equal comparison with *integer* for container comparison template CELER_CONSTEXPR_FUNCTION bool operator<=(OpaqueId lhs, U rhs) @@ -155,6 +153,7 @@ CELER_CONSTEXPR_FUNCTION bool operator<=(OpaqueId lhs, U rhs) return lhs && (U(lhs.unchecked_get()) <= rhs); } +//---------------------------------------------------------------------------// //! Get the distance between two opaque IDs template inline CELER_FUNCTION S operator-(OpaqueId self, OpaqueId other) @@ -164,6 +163,7 @@ inline CELER_FUNCTION S operator-(OpaqueId self, OpaqueId other) return self.unchecked_get() - other.unchecked_get(); } +//---------------------------------------------------------------------------// //! Increment an opaque ID by an offset template inline CELER_FUNCTION OpaqueId @@ -174,6 +174,7 @@ operator+(OpaqueId id, std::make_signed_t offset) return OpaqueId{id.unchecked_get() + static_cast(offset)}; } +//---------------------------------------------------------------------------// //! Decrement an opaque ID by an offset template inline CELER_FUNCTION OpaqueId @@ -184,25 +185,7 @@ operator-(OpaqueId id, std::make_signed_t offset) return OpaqueId{id.unchecked_get() - static_cast(offset)}; } -namespace detail -{ -//! Template matching to determine if T is an OpaqueId -template -struct IsOpaqueId : std::false_type -{ -}; -template -struct IsOpaqueId> : std::true_type -{ -}; -template -struct IsOpaqueId const> : std::true_type -{ -}; -template -inline constexpr bool is_opaque_id_v = IsOpaqueId::value; //---------------------------------------------------------------------------// -} // namespace detail } // namespace celeritas //---------------------------------------------------------------------------// diff --git a/src/corecel/cont/Span.hh b/src/corecel/cont/Span.hh index 28c34f5703..7b16eca5f4 100644 --- a/src/corecel/cont/Span.hh +++ b/src/corecel/cont/Span.hh @@ -10,9 +10,8 @@ #include #include -#include "corecel/data/LdgIterator.hh" - #include "Array.hh" + #include "detail/SpanImpl.hh" namespace celeritas @@ -189,10 +188,6 @@ class Span template constexpr std::size_t Span::extent; -//! Alias for a Span iterating over values read using __ldg -template -using LdgSpan = Span, Extent>; - //---------------------------------------------------------------------------// // FREE FUNCTIONS //---------------------------------------------------------------------------// @@ -248,26 +243,5 @@ CELER_CONSTEXPR_FUNCTION auto make_array(Span const& s) return result; } -//---------------------------------------------------------------------------// -/*! - * Construct an array from a fixed-size span, removing LdgValue marker. - * - * Note: \code make_array(Span const&) \endcode is not reused because: - * 1. Using this overload reads input data using \c __ldg - * 2. \code return make_array(s) \endcode results in segfault (gcc 11.3). - * This might be a compiler bug because temporary lifetime should be - * extended until the end of the expression and we return a copy... - */ -template -CELER_CONSTEXPR_FUNCTION auto make_array(LdgSpan const& s) -{ - Array, N> result{}; - for (std::size_t i = 0; i < N; ++i) - { - result[i] = s[i]; - } - return result; -} - //---------------------------------------------------------------------------// } // namespace celeritas diff --git a/src/corecel/cont/detail/SpanImpl.hh b/src/corecel/cont/detail/SpanImpl.hh index 36dd8b2adb..23884177aa 100644 --- a/src/corecel/cont/detail/SpanImpl.hh +++ b/src/corecel/cont/detail/SpanImpl.hh @@ -13,10 +13,16 @@ #include "corecel/Assert.hh" #include "corecel/Macros.hh" #include "corecel/OpaqueId.hh" -#include "corecel/data/LdgIterator.hh" namespace celeritas { +//---------------------------------------------------------------------------// +template +struct LdgValue; +template +class LdgIterator; + +//---------------------------------------------------------------------------// namespace detail { //---------------------------------------------------------------------------// @@ -58,7 +64,7 @@ struct SpanTraits> //---------------------------------------------------------------------------// //! Sentinel value for span of dynamic type -constexpr std::size_t dynamic_extent = std::size_t(-1); +inline constexpr std::size_t dynamic_extent = std::size_t(-1); //---------------------------------------------------------------------------// //! Calculate the return type for a subspan diff --git a/src/corecel/data/LdgIterator.hh b/src/corecel/data/LdgIterator.hh index 222480b4b3..4ee0de26fe 100644 --- a/src/corecel/data/LdgIterator.hh +++ b/src/corecel/data/LdgIterator.hh @@ -13,6 +13,7 @@ #include "corecel/Macros.hh" #include "corecel/Types.hh" +#include "corecel/cont/Span.hh" #include "corecel/math/Algorithms.hh" #include "detail/LdgIteratorImpl.hh" @@ -240,19 +241,13 @@ swap(LdgIterator& lhs, LdgIterator& rhs) noexcept } //!@} -//!@{ -//! Helper -template -inline LdgIterator make_ldg_iterator(T* ptr) noexcept -{ - return LdgIterator{ptr}; -} - +//---------------------------------------------------------------------------// /*! - * Wrapper struct that containers can use to specialize on types supported by - * LdgIterator, i.e. Span> specialization can internally use + * Wrapper struct for specializing on types supported by LdgIterator. + * + * For example, Span> specialization can internally use * LdgIterator. Specializations should refer to LdgValue::value_type to - * force the template instantiation of LdgValue and type-check T + * force the template instantiation of LdgValue and type-check T . */ template struct LdgValue @@ -262,7 +257,32 @@ struct LdgValue "const arithmetic, OpaqueId or enum type " "required"); }; -//!@} //---------------------------------------------------------------------------// -} // namespace celeritas \ No newline at end of file +//! Alias for a Span iterating over values read using __ldg +template +using LdgSpan = Span, Extent>; + +//---------------------------------------------------------------------------// +/*! + * Construct an array from a fixed-size span, removing LdgValue marker. + * + * Note: \code make_array(Span const&) \endcode is not reused because: + * 1. Using this overload reads input data using \c __ldg + * 2. \code return make_array(s) \endcode results in segfault (gcc 11.3). + * This might be a compiler bug because temporary lifetime should be + * extended until the end of the expression and we return a copy... + */ +template +CELER_CONSTEXPR_FUNCTION auto make_array(LdgSpan const& s) +{ + Array, N> result{}; + for (std::size_t i = 0; i < N; ++i) + { + result[i] = s[i]; + } + return result; +} + +//---------------------------------------------------------------------------// +} // namespace celeritas diff --git a/src/corecel/data/detail/CollectionImpl.hh b/src/corecel/data/detail/CollectionImpl.hh index 263ad89d58..113c1f4ec4 100644 --- a/src/corecel/data/detail/CollectionImpl.hh +++ b/src/corecel/data/detail/CollectionImpl.hh @@ -22,7 +22,7 @@ #include "corecel/sys/Device.hh" #include "DisabledStorage.hh" -#include "LdgIteratorImpl.hh" +#include "TypeTraits.hh" #include "../Copier.hh" #include "../LdgIterator.hh" #include "../PinnedAllocator.hh" diff --git a/src/corecel/data/detail/LdgIteratorImpl.hh b/src/corecel/data/detail/LdgIteratorImpl.hh index 01d07968aa..31577005f8 100644 --- a/src/corecel/data/detail/LdgIteratorImpl.hh +++ b/src/corecel/data/detail/LdgIteratorImpl.hh @@ -14,10 +14,32 @@ #include "corecel/Types.hh" #include "corecel/math/Quantity.hh" +#include "TypeTraits.hh" + namespace celeritas { namespace detail { +//---------------------------------------------------------------------------// +/*! + * Wrap the low-level CUDA/HIP "load global memory" function. + * + * This low-level capability allows improved caching because we're \em + * promising that no other thread can modify its value while the kernel is + * active. + */ +template +CELER_CONSTEXPR_FUNCTION T ldg(T const* ptr) +{ + static_assert(std::is_arithmetic_v, + "Only const arithmetic types are supported by __ldg"); +#if CELER_DEVICE_COMPILE + return __ldg(ptr); +#else + return *ptr; +#endif +} + //---------------------------------------------------------------------------// /*! * Reads a value T using __ldg builtin and return a copy of it @@ -25,19 +47,15 @@ namespace detail template struct LdgLoader { - static_assert(std::is_arithmetic_v && std::is_const_v, - "Only const arithmetic types are supported by __ldg"); + static_assert(std::is_const_v, "Only const data are supported by __ldg"); + using value_type = std::remove_const_t; using pointer = std::add_pointer_t; using reference = value_type; CELER_CONSTEXPR_FUNCTION static reference read(pointer p) { -#if CELER_DEVICE_COMPILE - return __ldg(p); -#else - return *p; -#endif + return ldg(p); } }; @@ -48,20 +66,13 @@ struct LdgLoader template struct LdgLoader const, void> { - static_assert(std::is_arithmetic_v, - "OpaqueId needs to be indexed with a type supported by " - "__ldg"); using value_type = OpaqueId; using pointer = std::add_pointer_t; using reference = value_type; CELER_CONSTEXPR_FUNCTION static reference read(pointer p) { -#if CELER_DEVICE_COMPILE - return value_type{__ldg(&p->value_)}; -#else - return value_type{p->value_}; -#endif + return value_type{ldg(p->data())}; } }; @@ -72,20 +83,13 @@ struct LdgLoader const, void> template struct LdgLoader const, void> { - static_assert(std::is_arithmetic_v, - "Quantity needs to be represented by a type supported by " - "__ldg"); using value_type = Quantity; using pointer = std::add_pointer_t; using reference = value_type; CELER_CONSTEXPR_FUNCTION static reference read(pointer p) { -#if CELER_DEVICE_COMPILE - return value_type{__ldg(&p->value_)}; -#else - return value_type{p->value_}; -#endif + return value_type{ldg(p->data())}; } }; @@ -103,21 +107,13 @@ struct LdgLoader>> // Technically breaks aliasing rule but it's not an issue: // the compiler doesn't derive any optimization and the pointer doesn't // escape the function - return value_type{__ldg(reinterpret_cast(p))}; + return value_type{ldg(reinterpret_cast(p))}; #else return *p; #endif } }; -//---------------------------------------------------------------------------// -//! True if T is supported by a LdgLoader specialization -template -inline constexpr bool is_ldg_supported_v - = std::is_const_v - && (std::is_arithmetic_v || is_opaque_id_v || is_quantity_v - || std::is_enum_v); - //---------------------------------------------------------------------------// } // namespace detail } // namespace celeritas diff --git a/src/corecel/data/detail/TypeTraits.hh b/src/corecel/data/detail/TypeTraits.hh new file mode 100644 index 0000000000..d2115a96b8 --- /dev/null +++ b/src/corecel/data/detail/TypeTraits.hh @@ -0,0 +1,74 @@ +//----------------------------------*-C++-*----------------------------------// +// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. +// See the top-level COPYRIGHT file for details. +// SPDX-License-Identifier: (Apache-2.0 OR MIT) +//---------------------------------------------------------------------------// +//! \file corecel/data/detail/TypeTraits.hh +//---------------------------------------------------------------------------// +#pragma once + +#include + +namespace celeritas +{ +//---------------------------------------------------------------------------// +template +class OpaqueId; + +template +class Quantity; + +namespace detail +{ +//---------------------------------------------------------------------------// +//! Template matching to determine if T is an OpaqueId +template +struct IsOpaqueId : std::false_type +{ +}; + +template +struct IsOpaqueId> : std::true_type +{ +}; + +template +struct IsOpaqueId const> : std::true_type +{ +}; + +//! Template matching to determine if T is a Quantity +template +struct IsQuantity : std::false_type +{ +}; +template +struct IsQuantity> : std::true_type +{ +}; +template +struct IsQuantity const> : std::true_type +{ +}; + +//---------------------------------------------------------------------------// +//! True if T is an OpaqueID +template +inline constexpr bool is_opaque_id_v = IsOpaqueId::value; + +//---------------------------------------------------------------------------// +//! True if T is a Quantity +template +inline constexpr bool is_quantity_v = IsQuantity::value; + +//---------------------------------------------------------------------------// +//! True if T is supported by a LdgLoader specialization +template +inline constexpr bool is_ldg_supported_v + = std::is_const_v + && (std::is_arithmetic_v || is_opaque_id_v || is_quantity_v + || std::is_enum_v); + +//---------------------------------------------------------------------------// +} // namespace detail +} // namespace celeritas diff --git a/src/corecel/math/Quantity.hh b/src/corecel/math/Quantity.hh index 1fbf8a4dfa..bda07f800f 100644 --- a/src/corecel/math/Quantity.hh +++ b/src/corecel/math/Quantity.hh @@ -16,13 +16,6 @@ namespace celeritas { -//---------------------------------------------------------------------------// -namespace detail -{ -template -struct LdgLoader; -} - //---------------------------------------------------------------------------// /*! * A numerical value tagged with a unit. @@ -121,10 +114,11 @@ class Quantity #undef CELER_DEFINE_QACCESS //!@} + //! Access the underlying data for more efficient loading from memory + CELER_CONSTEXPR_FUNCTION value_type const* data() const { return &value_; } + private: value_type value_{}; - - friend detail::LdgLoader const, void>; }; //---------------------------------------------------------------------------// @@ -328,24 +322,5 @@ inline char const* accessor_unit_label() return detail::AccessorResultType::unit_type::label(); } -namespace detail -{ -//! Template matching to determine if T is a Quantity -template -struct IsQuantity : std::false_type -{ -}; -template -struct IsQuantity> : std::true_type -{ -}; -template -struct IsQuantity const> : std::true_type -{ -}; -template -inline constexpr bool is_quantity_v = IsQuantity::value; - //---------------------------------------------------------------------------// -} // namespace detail } // namespace celeritas diff --git a/src/geocel/GeoParamsInterface.hh b/src/geocel/GeoParamsInterface.hh index 979b693145..6bfe0119b1 100644 --- a/src/geocel/GeoParamsInterface.hh +++ b/src/geocel/GeoParamsInterface.hh @@ -27,7 +27,7 @@ class GeoParamsInterface public: //!@{ //! \name Type aliases - using SpanConstVolumeId = LdgSpan; + using SpanConstVolumeId = Span; //!@} public: diff --git a/src/geocel/Types.hh b/src/geocel/Types.hh index d869d3f72c..a7e8c67c80 100644 --- a/src/geocel/Types.hh +++ b/src/geocel/Types.hh @@ -18,9 +18,15 @@ namespace celeritas // TYPE ALIASES //---------------------------------------------------------------------------// -//! Fixed-size array for 3D space +//! Three-dimensional cartesian coordinates using Real3 = Array; +//! Two-dimensional cartesian coordinates +using Real2 = Array; + +//! Two-dimensional extents +using Size2 = Array; + //! Alias for a small square dense matrix template using SquareMatrix = Array, N>; @@ -31,7 +37,6 @@ using SquareMatrixReal3 = SquareMatrix; //---------------------------------------------------------------------------// //! Identifier for a material fill -// TODO: rename MaterialId, see celeritas/Types.hh using GeoMaterialId = OpaqueId; //! Identifier for a surface (for surface-based geometries) diff --git a/src/geocel/rasterize/ImageData.hh b/src/geocel/rasterize/ImageData.hh index 13abe712c8..73f17aba1a 100644 --- a/src/geocel/rasterize/ImageData.hh +++ b/src/geocel/rasterize/ImageData.hh @@ -33,8 +33,6 @@ namespace celeritas */ struct ImageParamsScalars { - using Size2 = Array; - Real3 origin{}; //!< Upper left corner Real3 down{}; //!< Downward basis vector Real3 right{}; //!< Rightward basis vector (increasing i, track movement) diff --git a/src/orange/g4org/SolidConverter.cc b/src/orange/g4org/SolidConverter.cc index 6090156191..0f1939d4bb 100644 --- a/src/orange/g4org/SolidConverter.cc +++ b/src/orange/g4org/SolidConverter.cc @@ -314,10 +314,10 @@ auto SolidConverter::cons(arg_type solid_base) -> result_type { auto const& solid = dynamic_cast(solid_base); - auto const outer_r = scale_.to(solid.GetOuterRadiusMinusZ(), - solid.GetOuterRadiusPlusZ()); - auto const inner_r = scale_.to(solid.GetInnerRadiusMinusZ(), - solid.GetInnerRadiusPlusZ()); + auto const outer_r = scale_.to(solid.GetOuterRadiusMinusZ(), + solid.GetOuterRadiusPlusZ()); + auto const inner_r = scale_.to(solid.GetInnerRadiusMinusZ(), + solid.GetInnerRadiusPlusZ()); auto hh = scale_(solid.GetZHalfLength()); std::optional inner; @@ -409,11 +409,11 @@ auto SolidConverter::generictrap(arg_type solid_base) -> result_type auto const& vtx = solid.GetVertices(); CELER_ASSERT(vtx.size() == 8); - std::vector lower(4), upper(4); + std::vector lower(4), upper(4); for (auto i : range(4)) { - lower[i] = scale_.to(vtx[i].x(), vtx[i].y()); - upper[i] = scale_.to(vtx[i + 4].x(), vtx[i + 4].y()); + lower[i] = scale_.to(vtx[i].x(), vtx[i].y()); + upper[i] = scale_.to(vtx[i + 4].x(), vtx[i + 4].y()); } real_type hh = scale_(solid.GetZHalfLength()); diff --git a/src/orange/orangeinp/IntersectRegion.hh b/src/orange/orangeinp/IntersectRegion.hh index 7a52b6bc19..8d10aec9b1 100644 --- a/src/orange/orangeinp/IntersectRegion.hh +++ b/src/orange/orangeinp/IntersectRegion.hh @@ -102,12 +102,6 @@ class Box final : public IntersectRegionInterface */ class Cone final : public IntersectRegionInterface { - public: - //!@{ - //! \name Type aliases - using Real2 = Array; - //!@} - public: // Construct with Z half-height and lo, hi radii Cone(Real2 const& radii, real_type halfheight); @@ -216,7 +210,6 @@ class GenTrap final : public IntersectRegionInterface public: //!@{ //! \name Type aliases - using Real2 = Array; using VecReal2 = std::vector; //!@} diff --git a/src/orange/orangeinp/PolySolid.cc b/src/orange/orangeinp/PolySolid.cc index 1204c16164..00b6c915c7 100644 --- a/src/orange/orangeinp/PolySolid.cc +++ b/src/orange/orangeinp/PolySolid.cc @@ -217,7 +217,6 @@ PolyCone::PolyCone(std::string&& label, */ NodeId PolyCone::build(VolumeBuilder& vb) const { - using Real2 = PolySegments::Real2; auto build_cone = [](Real2 const& radii, real_type hh) { return Cone{radii, hh}; }; @@ -324,7 +323,6 @@ PolyPrism::PolyPrism(std::string&& label, */ NodeId PolyPrism::build(VolumeBuilder& vb) const { - using Real2 = PolySegments::Real2; auto build_prism = [this](Real2 const& radii, real_type hh) { if (radii[0] != radii[1]) { diff --git a/src/orange/orangeinp/PolySolid.hh b/src/orange/orangeinp/PolySolid.hh index f64c78deb1..1b589a1a69 100644 --- a/src/orange/orangeinp/PolySolid.hh +++ b/src/orange/orangeinp/PolySolid.hh @@ -33,7 +33,6 @@ class PolySegments //!@{ //! \name Type aliases using VecReal = std::vector; - using Real2 = celeritas::Array; //!@} public: diff --git a/src/orange/orangeinp/detail/PolygonUtils.hh b/src/orange/orangeinp/detail/PolygonUtils.hh index b3357b1484..ce8cf4842b 100644 --- a/src/orange/orangeinp/detail/PolygonUtils.hh +++ b/src/orange/orangeinp/detail/PolygonUtils.hh @@ -24,9 +24,6 @@ namespace orangeinp { namespace detail { -//---------------------------------------------------------------------------// -using Real2 = Array; - //---------------------------------------------------------------------------// /*! * Polygon orientation based on ordering of vertices. diff --git a/src/orange/univ/detail/InfixEvaluator.hh b/src/orange/univ/detail/InfixEvaluator.hh index 1e4ac80cf6..30e39e3b87 100644 --- a/src/orange/univ/detail/InfixEvaluator.hh +++ b/src/orange/univ/detail/InfixEvaluator.hh @@ -9,6 +9,7 @@ #include "corecel/Assert.hh" #include "corecel/cont/Span.hh" +#include "corecel/data/LdgIterator.hh" #include "orange/OrangeTypes.hh" namespace celeritas diff --git a/src/orange/univ/detail/LogicEvaluator.hh b/src/orange/univ/detail/LogicEvaluator.hh index 0881138d6f..1790f9005a 100644 --- a/src/orange/univ/detail/LogicEvaluator.hh +++ b/src/orange/univ/detail/LogicEvaluator.hh @@ -9,6 +9,7 @@ #include "corecel/Assert.hh" #include "corecel/cont/Span.hh" +#include "corecel/data/LdgIterator.hh" #include "orange/OrangeTypes.hh" #include "LogicStack.hh" diff --git a/src/orange/univ/detail/RaggedRightIndexer.hh b/src/orange/univ/detail/RaggedRightIndexer.hh index 4005c7ae12..34465364ce 100644 --- a/src/orange/univ/detail/RaggedRightIndexer.hh +++ b/src/orange/univ/detail/RaggedRightIndexer.hh @@ -11,6 +11,7 @@ #include "corecel/Types.hh" #include "corecel/cont/Array.hh" #include "corecel/cont/Range.hh" +#include "geocel/Types.hh" #include "orange/OrangeData.hh" namespace celeritas @@ -19,7 +20,7 @@ namespace detail { //---------------------------------------------------------------------------// /*! - * Index into flattened, ragged-right, 2D data, from index to coords + * Index into flattened, ragged-right, 2D data, from index to coords. * * For example, consider three arrays of different sizes: * A = [a1, a2] @@ -38,7 +39,7 @@ class RaggedRightIndexer public: //!@{ //! \name Type aliases - using Coords = Array; + using Coords = Size2; //!@} public: @@ -59,7 +60,7 @@ class RaggedRightIndexer //---------------------------------------------------------------------------// /*! - * Index into flattened, ragged-right, 2D data, from coords to index + * Index into flattened, ragged-right, 2D data, from coords to index. * * For example, consider three arrays of different sizes: * A = [a1, a2] @@ -86,14 +87,10 @@ class RaggedRightInverseIndexer explicit inline CELER_FUNCTION RaggedRightInverseIndexer(RaggedRightIndexerData const& rrd); - //// METHODS //// - // Convert a flattened index into ragged indices inline CELER_FUNCTION Coords operator()(size_type index) const; private: - //// DATA //// - RaggedRightIndexerData const& rrd_; }; @@ -101,7 +98,7 @@ class RaggedRightInverseIndexer // INLINE DEFINITIONS //---------------------------------------------------------------------------// /*! - * Construct fom RaggedRightIndexerData + * Construct fom RaggedRightIndexerData. */ template CELER_FUNCTION @@ -126,7 +123,7 @@ CELER_FUNCTION size_type RaggedRightIndexer::operator()(Coords coords) const //---------------------------------------------------------------------------// /*! - * Construct fom RaggedRightIndexerData + * Construct fom RaggedRightIndexerData. */ template CELER_FUNCTION RaggedRightInverseIndexer::RaggedRightInverseIndexer( diff --git a/test/corecel/data/LdgIterator.test.cc b/test/corecel/data/LdgIterator.test.cc index e04fdf5e86..6e60eee140 100644 --- a/test/corecel/data/LdgIterator.test.cc +++ b/test/corecel/data/LdgIterator.test.cc @@ -37,8 +37,8 @@ TEST_F(LdgIteratorTest, arithmetic_t) auto n = some_data.size(); auto start = some_data.begin(); auto end = some_data.end(); - auto ldg_start = make_ldg_iterator(some_data.data()); - auto ldg_end = make_ldg_iterator(some_data.data() + n); + auto ldg_start = LdgIterator(some_data.data()); + auto ldg_end = LdgIterator(some_data.data() + n); LdgIterator ctad_itr{some_data.data()}; EXPECT_TRUE((std::is_same_v)); using ptr_type = typename decltype(ldg_start)::pointer; @@ -82,8 +82,8 @@ TEST_F(LdgIteratorTest, opaqueid_t) using VecId = std::vector; VecId const some_data = {TestId{1}, TestId{2}, TestId{3}, TestId{4}}; auto n = some_data.size(); - auto ldg_start = make_ldg_iterator(some_data.data()); - auto ldg_end = make_ldg_iterator(some_data.data() + n); + auto ldg_start = LdgIterator(some_data.data()); + auto ldg_end = LdgIterator(some_data.data() + n); LdgIterator ctad_itr{some_data.data()}; EXPECT_TRUE((std::is_same_v)); using ptr_type = typename decltype(ldg_start)::pointer; @@ -126,8 +126,8 @@ TEST_F(LdgIteratorTest, byte_t) VecByte const some_data = {std::byte{1}, std::byte{2}, std::byte{3}, std::byte{4}}; auto n = some_data.size(); - auto ldg_start = make_ldg_iterator(some_data.data()); - auto ldg_end = make_ldg_iterator(some_data.data() + n); + auto ldg_start = LdgIterator(some_data.data()); + auto ldg_end = LdgIterator(some_data.data() + n); LdgIterator ctad_itr{some_data.data()}; EXPECT_TRUE((std::is_same_v)); using ptr_type = typename decltype(ldg_start)::pointer; @@ -165,4 +165,4 @@ TEST_F(LdgIteratorTest, byte_t) //---------------------------------------------------------------------------// } // namespace test -} // namespace celeritas \ No newline at end of file +} // namespace celeritas diff --git a/test/geocel/rasterize/Image.test.cc b/test/geocel/rasterize/Image.test.cc index 3f1a0dac74..42f1de2b91 100644 --- a/test/geocel/rasterize/Image.test.cc +++ b/test/geocel/rasterize/Image.test.cc @@ -20,8 +20,6 @@ namespace test class ImageTest : public ::celeritas::test::Test { protected: - using Size2 = ImageParamsScalars::Size2; - void SetUp() override {} }; diff --git a/test/orange/orangeinp/IntersectRegion.test.cc b/test/orange/orangeinp/IntersectRegion.test.cc index 5313821fc8..725bb4c4c9 100644 --- a/test/orange/orangeinp/IntersectRegion.test.cc +++ b/test/orange/orangeinp/IntersectRegion.test.cc @@ -452,7 +452,6 @@ TEST_F(EllipsoidTest, standard) class GenTrapTest : public IntersectRegionTest { protected: - using Real2 = GenTrap::Real2; using VecReal = std::vector; // NOTE: this only works for trapezoids centered on the z axis (a diff --git a/test/orange/orangeinp/PolySolid.test.cc b/test/orange/orangeinp/PolySolid.test.cc index e54f98f115..73c8dc55ec 100644 --- a/test/orange/orangeinp/PolySolid.test.cc +++ b/test/orange/orangeinp/PolySolid.test.cc @@ -21,8 +21,6 @@ namespace orangeinp { namespace test { -using Real2 = PolySegments::Real2; - //---------------------------------------------------------------------------// TEST(PolySegmentsTest, errors) {