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 f41dedd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
27 changes: 27 additions & 0 deletions core/include/detray/core/detail/container_views.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,20 @@ 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
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 Down Expand Up @@ -205,6 +219,19 @@ struct detail::has_view<const vecmem::jagged_vector<T>, void>
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
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 f41dedd

Please sign in to comment.