Skip to content

Commit

Permalink
Add device container specializations for the view type handling
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Oct 19, 2023
1 parent 77a8f7c commit e54fe9a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
13 changes: 13 additions & 0 deletions core/include/detray/core/detail/container_buffers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ struct has_buffer<const vecmem::vector<T>, void> : public std::true_type {
using type = vecmem::data::vector_buffer<const T>;
};

/// Specialization of the buffer getter for @c vecmem::device_vector
template <typename T>
struct has_buffer<vecmem::device_vector<T>, void> : public std::true_type {
using type = vecmem::data::vector_buffer<T>;
};

/// Specialization of the buffer getter for @c vecmem::device_vector - const
template <typename T>
struct has_buffer<const vecmem::device_vector<T>, void>
: public std::true_type {
using type = vecmem::data::vector_buffer<const T>;
};

template <class T>
inline constexpr bool has_buffer_v = has_buffer<T>::value;

Expand Down
32 changes: 30 additions & 2 deletions core/include/detray/core/detail/container_views.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,26 @@ struct detail::has_view<vecmem::vector<T>, void> : public std::true_type {
using type = dvector_view<T>;
};

/// Specialization of the view getter for @c vecmem::vector
/// Specialization of the view getter for @c vecmem::vector - const
template <typename T>
struct detail::has_view<const vecmem::vector<T>, void> : public std::true_type {
using type = dvector_view<const T>;
};

/// Specialization of the view getter for @c vecmem::device_vector
template <typename T>
struct detail::has_view<vecmem::device_vector<T>, void>
: public std::true_type {
using type = dvector_view<T>;
};

/// Specialization of the view getter for @c vecmem::device_vector - const
template <typename T>
struct detail::has_view<const vecmem::device_vector<T>, void>
: public std::true_type {
using type = dvector_view<const T>;
};

/// Specialized view for @c vecmem::jagged_vector containers
template <typename T>
using djagged_vector_view = vecmem::data::jagged_vector_view<T>;
Expand All @@ -198,13 +212,27 @@ struct detail::has_view<vecmem::jagged_vector<T>, void>
using type = djagged_vector_view<T>;
};

/// Specialization of the view getter for @c vecmem::jagged_vector
/// Specialization of the view getter for @c vecmem::jagged_vector - const
template <typename T>
struct detail::has_view<const vecmem::jagged_vector<T>, void>
: public std::true_type {
using type = djagged_vector_view<const T>;
};

/// Specialization of the view getter for @c vecmem::jagged_device_vector
template <typename T>
struct detail::has_view<vecmem::jagged_device_vector<T>, void>
: public std::true_type {
using type = djagged_vector_view<T>;
};

/// Specialization of the view getter for @c vecmem::jagged_device_vector
/// - const
template <typename T>
struct detail::has_view<const vecmem::jagged_device_vector<T>, void>
: public std::true_type {
using type = djagged_vector_view<const T>;
};
/// @}

} // namespace detray
9 changes: 9 additions & 0 deletions core/include/detray/core/detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ class detector {
typename surface_container::view_type, dvector_view<surface_type>,
typename volume_finder::view_type>;

static_assert(detail::is_device_view_v<view_type>,
"Detector view type ill-formed");

using const_view_type =
dmulti_view<dvector_view<const volume_type>,
typename transform_container::const_view_type,
Expand All @@ -140,6 +143,9 @@ class detector {
dvector_view<const surface_type>,
typename volume_finder::const_view_type>;

static_assert(detail::is_device_view_v<const_view_type>,
"Detector const view type ill-formed");

/// Detector buffer types
using buffer_type = dmulti_buffer<
dvector_buffer<volume_type>, typename transform_container::buffer_type,
Expand All @@ -148,6 +154,9 @@ class detector {
typename surface_container::buffer_type, dvector_buffer<surface_type>,
typename volume_finder::buffer_type>;

static_assert(detail::is_buffer_v<buffer_type>,
"Detector buffer type ill-formed");

detector() = delete;
// The detector holds a lot of data and should never be copied
detector(const detector &) = delete;
Expand Down

0 comments on commit e54fe9a

Please sign in to comment.