CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
PortableDeviceMultiCollection< TDev, T0, Args > Class Template Reference

#include <PortableDeviceCollection.h>

Public Types

using Buffer = cms::alpakatools::device_buffer< TDev, std::byte[]>
 
using ConstBuffer = cms::alpakatools::const_device_buffer< TDev, std::byte[]>
 
template<std::size_t Idx = 0UL>
using ConstView = typename std::tuple_element< Idx, std::tuple< T0, Args... > >::type::ConstView
 
using Implementation = portablecollection::CollectionImpl< 0, T0, Args... >
 
template<std::size_t Idx = 0>
using Layout = portablecollection::TypeResolver< Idx, T0, Args... >
 
using SizesArray = std::array< int32_t, members_ >
 
template<std::size_t Idx = 0UL>
using View = typename std::tuple_element< Idx, std::tuple< T0, Args... > >::type::View
 

Public Member Functions

Buffer buffer ()
 
ConstBuffer buffer () const
 
ConstBuffer const_buffer () const
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
ConstView< Idx > const & const_view () const
 
template<typename T >
T::ConstView const & const_view () const
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
View< Idx > & operator* ()
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
ConstView< Idx > const & operator* () const
 
template<typename T >
T::View & operator* ()
 
template<typename T >
T::ConstView const & operator* () const
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
View< Idx > * operator-> ()
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
ConstView< Idx > const * operator-> () const
 
template<typename T >
T::View * operator-> ()
 
template<typename T >
T::ConstView const * operator-> () const
 
PortableDeviceMultiCollectionoperator= (PortableDeviceMultiCollection const &)=delete
 
PortableDeviceMultiCollectionoperator= (PortableDeviceMultiCollection &&)=default
 
 PortableDeviceMultiCollection ()=default
 
 PortableDeviceMultiCollection (int32_t elements, TDev const &device)
 
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
 PortableDeviceMultiCollection (int32_t elements, TQueue const &queue)
 
 PortableDeviceMultiCollection (const SizesArray &sizes, TDev const &device)
 
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
 PortableDeviceMultiCollection (const SizesArray &sizes, TQueue const &queue)
 
 PortableDeviceMultiCollection (PortableDeviceMultiCollection const &)=delete
 
 PortableDeviceMultiCollection (PortableDeviceMultiCollection &&)=default
 
SizesArray sizes () const
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
View< Idx > & view ()
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
ConstView< Idx > const & view () const
 
template<typename T >
T::View & view ()
 
template<typename T >
T::ConstView const & view () const
 
 ~PortableDeviceMultiCollection ()=default
 

Static Public Member Functions

static int32_t computeDataSize (const SizesArray &sizes)
 

Private Types

template<std::size_t Idx>
using Leaf = portablecollection::CollectionLeaf< Idx, Layout< Idx > >
 

Private Member Functions

template<std::size_t Idx>
Leaf< Idx > & get ()
 
template<std::size_t Idx>
Leaf< Idx > const & get () const
 
template<typename T >
Leaf< index_t_< T > > & get ()
 
template<typename T >
Leaf< index_t_< T > > const & get () const
 

Private Attributes

std::optional< Bufferbuffer_
 
Implementation impl_
 

Static Private Attributes

template<typename T >
static constexpr std::size_t count_t_ = portablecollection::typeCount<T, T0, Args...>
 
template<typename T >
static constexpr std::size_t index_t_ = portablecollection::typeIndex<T, T0, Args...>
 
static constexpr std::size_t members_ = sizeof...(Args) + 1
 

Detailed Description

template<typename TDev, typename T0, typename... Args>
class PortableDeviceMultiCollection< TDev, T0, Args >

Definition at line 81 of file PortableDeviceCollection.h.

Member Typedef Documentation

◆ Buffer

template<typename TDev, typename T0, typename... Args>
using PortableDeviceMultiCollection< TDev, T0, Args >::Buffer = cms::alpakatools::device_buffer<TDev, std::byte[]>

Definition at line 95 of file PortableDeviceCollection.h.

◆ ConstBuffer

template<typename TDev, typename T0, typename... Args>
using PortableDeviceMultiCollection< TDev, T0, Args >::ConstBuffer = cms::alpakatools::const_device_buffer<TDev, std::byte[]>

Definition at line 96 of file PortableDeviceCollection.h.

◆ ConstView

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0UL>
using PortableDeviceMultiCollection< TDev, T0, Args >::ConstView = typename std::tuple_element<Idx, std::tuple<T0, Args...> >::type::ConstView

Definition at line 114 of file PortableDeviceCollection.h.

◆ Implementation

template<typename TDev, typename T0, typename... Args>
using PortableDeviceMultiCollection< TDev, T0, Args >::Implementation = portablecollection::CollectionImpl<0, T0, Args...>

Definition at line 97 of file PortableDeviceCollection.h.

◆ Layout

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0>
using PortableDeviceMultiCollection< TDev, T0, Args >::Layout = portablecollection::TypeResolver<Idx, T0, Args...>

Definition at line 102 of file PortableDeviceCollection.h.

◆ Leaf

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx>
using PortableDeviceMultiCollection< TDev, T0, Args >::Leaf = portablecollection::CollectionLeaf<Idx, Layout<Idx> >
private

Definition at line 118 of file PortableDeviceCollection.h.

◆ SizesArray

template<typename TDev, typename T0, typename... Args>
using PortableDeviceMultiCollection< TDev, T0, Args >::SizesArray = std::array<int32_t, members_>

Definition at line 99 of file PortableDeviceCollection.h.

◆ View

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0UL>
using PortableDeviceMultiCollection< TDev, T0, Args >::View = typename std::tuple_element<Idx, std::tuple<T0, Args...> >::type::View

Definition at line 108 of file PortableDeviceCollection.h.

Constructor & Destructor Documentation

◆ PortableDeviceMultiCollection() [1/7]

template<typename TDev, typename T0, typename... Args>
PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection ( )
default

◆ PortableDeviceMultiCollection() [2/7]

template<typename TDev, typename T0, typename... Args>
PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection ( int32_t  elements,
TDev const &  device 
)
inline

Definition at line 143 of file PortableDeviceCollection.h.

References bookConverter::elements.

144  : buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(device, Layout<>::computeDataSize(elements))},
145  impl_{buffer_->data(), elements} {
146  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
147  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<>::alignment == 0);
148  static_assert(members_ == 1);
149  }
assert(be >=bs)
static constexpr std::size_t members_

◆ PortableDeviceMultiCollection() [3/7]

template<typename TDev, typename T0, typename... Args>
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection ( int32_t  elements,
TQueue const &  queue 
)
inline

Definition at line 152 of file PortableDeviceCollection.h.

References bookConverter::elements, and createBeamHaloJobs::queue.

153  : buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(queue, Layout<>::computeDataSize(elements))},
154  impl_{buffer_->data(), elements} {
155  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
156  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<>::alignment == 0);
157  static_assert(members_ == 1);
158  }
assert(be >=bs)
static constexpr std::size_t members_

◆ PortableDeviceMultiCollection() [4/7]

template<typename TDev, typename T0, typename... Args>
PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection ( const SizesArray sizes,
TDev const &  device 
)
inline

Definition at line 167 of file PortableDeviceCollection.h.

References PortableDeviceMultiCollection< TDev, T0, Args >::computeDataSize(), and PortableDeviceMultiCollection< TDev, T0, Args >::sizes().

169  : buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(device, computeDataSize(sizes))},
170  impl_{buffer_->data(), sizes} {
171  portablecollection::constexpr_for<0, members_>(
172  [&](auto i) { assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<i>::alignment == 0); });
174  portablecollection::constexpr_for<1, members_>(
175  [&alignment](auto i) { static_assert(alignment == Layout<i>::alignment); });
176  }
static int32_t computeDataSize(const SizesArray &sizes)
assert(be >=bs)

◆ PortableDeviceMultiCollection() [5/7]

template<typename TDev, typename T0, typename... Args>
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection ( const SizesArray sizes,
TQueue const &  queue 
)
inline

Definition at line 179 of file PortableDeviceCollection.h.

References PortableDeviceMultiCollection< TDev, T0, Args >::computeDataSize(), createBeamHaloJobs::queue, and PortableDeviceMultiCollection< TDev, T0, Args >::sizes().

181  : buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(queue, computeDataSize(sizes))},
182  impl_{buffer_->data(), sizes} {
183  portablecollection::constexpr_for<0, members_>(
184  [&](auto i) { assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<i>::alignment == 0); });
186  portablecollection::constexpr_for<1, members_>(
187  [&alignment](auto i) { static_assert(alignment == Layout<i>::alignment); });
188  }
static int32_t computeDataSize(const SizesArray &sizes)
assert(be >=bs)

◆ PortableDeviceMultiCollection() [6/7]

template<typename TDev, typename T0, typename... Args>
PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection ( PortableDeviceMultiCollection< TDev, T0, Args > const &  )
delete

◆ PortableDeviceMultiCollection() [7/7]

template<typename TDev, typename T0, typename... Args>
PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection ( PortableDeviceMultiCollection< TDev, T0, Args > &&  )
default

◆ ~PortableDeviceMultiCollection()

template<typename TDev, typename T0, typename... Args>
PortableDeviceMultiCollection< TDev, T0, Args >::~PortableDeviceMultiCollection ( )
default

Member Function Documentation

◆ buffer() [1/2]

template<typename TDev, typename T0, typename... Args>
Buffer PortableDeviceMultiCollection< TDev, T0, Args >::buffer ( )
inline

◆ buffer() [2/2]

template<typename TDev, typename T0, typename... Args>
ConstBuffer PortableDeviceMultiCollection< TDev, T0, Args >::buffer ( ) const
inline

◆ computeDataSize()

template<typename TDev, typename T0, typename... Args>
static int32_t PortableDeviceMultiCollection< TDev, T0, Args >::computeDataSize ( const SizesArray sizes)
inlinestatic

Definition at line 160 of file PortableDeviceCollection.h.

References mps_fire::i, runTheMatrix::ret, and PortableDeviceMultiCollection< TDev, T0, Args >::sizes().

Referenced by PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection().

160  {
161  int32_t ret = 0;
162  portablecollection::constexpr_for<0, members_>(
163  [&sizes, &ret](auto i) { ret += Layout<i>::computeDataSize(sizes[i]); });
164  return ret;
165  }
ret
prodAgent to be discontinued

◆ const_buffer()

template<typename TDev, typename T0, typename... Args>
ConstBuffer PortableDeviceMultiCollection< TDev, T0, Args >::const_buffer ( ) const
inline

◆ const_view() [1/2]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
ConstView<Idx> const& PortableDeviceMultiCollection< TDev, T0, Args >::const_view ( ) const
inline

Definition at line 213 of file PortableDeviceCollection.h.

213  {
214  return get<Idx>().view_;
215  }

◆ const_view() [2/2]

template<typename TDev, typename T0, typename... Args>
template<typename T >
T::ConstView const& PortableDeviceMultiCollection< TDev, T0, Args >::const_view ( ) const
inline

Definition at line 249 of file PortableDeviceCollection.h.

249  {
250  return get<T>().view_;
251  }

◆ get() [1/4]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx>
Leaf<Idx>& PortableDeviceMultiCollection< TDev, T0, Args >::get ( )
inlineprivate

◆ get() [2/4]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx>
Leaf<Idx> const& PortableDeviceMultiCollection< TDev, T0, Args >::get ( ) const
inlineprivate

◆ get() [3/4]

template<typename TDev, typename T0, typename... Args>
template<typename T >
Leaf<index_t_<T> >& PortableDeviceMultiCollection< TDev, T0, Args >::get ( )
inlineprivate

◆ get() [4/4]

template<typename TDev, typename T0, typename... Args>
template<typename T >
Leaf<index_t_<T> > const& PortableDeviceMultiCollection< TDev, T0, Args >::get ( ) const
inlineprivate

◆ operator*() [1/4]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
View<Idx>& PortableDeviceMultiCollection< TDev, T0, Args >::operator* ( void  )
inline

Definition at line 218 of file PortableDeviceCollection.h.

218  {
219  return get<Idx>().view_;
220  }

◆ operator*() [2/4]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
ConstView<Idx> const& PortableDeviceMultiCollection< TDev, T0, Args >::operator* ( void  ) const
inline

Definition at line 223 of file PortableDeviceCollection.h.

223  {
224  return get<Idx>().view_;
225  }

◆ operator*() [3/4]

template<typename TDev, typename T0, typename... Args>
template<typename T >
T::View& PortableDeviceMultiCollection< TDev, T0, Args >::operator* ( void  )
inline

Definition at line 254 of file PortableDeviceCollection.h.

254  {
255  return get<T>().view_;
256  }

◆ operator*() [4/4]

template<typename TDev, typename T0, typename... Args>
template<typename T >
T::ConstView const& PortableDeviceMultiCollection< TDev, T0, Args >::operator* ( void  ) const
inline

Definition at line 259 of file PortableDeviceCollection.h.

259  {
260  return get<T>().view_;
261  }

◆ operator->() [1/4]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
View<Idx>* PortableDeviceMultiCollection< TDev, T0, Args >::operator-> ( )
inline

Definition at line 228 of file PortableDeviceCollection.h.

228  {
229  return &get<Idx>().view_;
230  }

◆ operator->() [2/4]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
ConstView<Idx> const* PortableDeviceMultiCollection< TDev, T0, Args >::operator-> ( ) const
inline

Definition at line 233 of file PortableDeviceCollection.h.

233  {
234  return &get<Idx>().view_;
235  }

◆ operator->() [3/4]

template<typename TDev, typename T0, typename... Args>
template<typename T >
T::View* PortableDeviceMultiCollection< TDev, T0, Args >::operator-> ( )
inline

Definition at line 264 of file PortableDeviceCollection.h.

264  {
265  return &get<T>().view_;
266  }

◆ operator->() [4/4]

template<typename TDev, typename T0, typename... Args>
template<typename T >
T::ConstView const* PortableDeviceMultiCollection< TDev, T0, Args >::operator-> ( ) const
inline

Definition at line 269 of file PortableDeviceCollection.h.

269  {
270  return &get<T>().view_;
271  }

◆ operator=() [1/2]

template<typename TDev, typename T0, typename... Args>
PortableDeviceMultiCollection& PortableDeviceMultiCollection< TDev, T0, Args >::operator= ( PortableDeviceMultiCollection< TDev, T0, Args > const &  )
delete

◆ operator=() [2/2]

template<typename TDev, typename T0, typename... Args>
PortableDeviceMultiCollection& PortableDeviceMultiCollection< TDev, T0, Args >::operator= ( PortableDeviceMultiCollection< TDev, T0, Args > &&  )
default

◆ sizes()

template<typename TDev, typename T0, typename... Args>
SizesArray PortableDeviceMultiCollection< TDev, T0, Args >::sizes ( ) const
inline

Definition at line 279 of file PortableDeviceCollection.h.

References mps_fire::i, and runTheMatrix::ret.

Referenced by PortableDeviceMultiCollection< TDev, T0, Args >::computeDataSize(), cms::alpakatools::CopyToHost< PortableDeviceMultiCollection< TDev, T0, Args... > >::copyAsync(), and PortableDeviceMultiCollection< TDev, T0, Args >::PortableDeviceMultiCollection().

279  {
280  SizesArray ret;
281  portablecollection::constexpr_for<0, members_>([&](auto i) { ret[i] = get<i>().layout_.metadata().size(); });
282  return ret;
283  }
ret
prodAgent to be discontinued
std::array< int32_t, members_ > SizesArray

◆ view() [1/4]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
View<Idx>& PortableDeviceMultiCollection< TDev, T0, Args >::view ( )
inline

Definition at line 203 of file PortableDeviceCollection.h.

203  {
204  return get<Idx>().view_;
205  }

◆ view() [2/4]

template<typename TDev, typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
ConstView<Idx> const& PortableDeviceMultiCollection< TDev, T0, Args >::view ( ) const
inline

Definition at line 208 of file PortableDeviceCollection.h.

208  {
209  return get<Idx>().view_;
210  }

◆ view() [3/4]

template<typename TDev, typename T0, typename... Args>
template<typename T >
T::View& PortableDeviceMultiCollection< TDev, T0, Args >::view ( )
inline

Definition at line 239 of file PortableDeviceCollection.h.

239  {
240  return get<T>().view_;
241  }

◆ view() [4/4]

template<typename TDev, typename T0, typename... Args>
template<typename T >
T::ConstView const& PortableDeviceMultiCollection< TDev, T0, Args >::view ( ) const
inline

Definition at line 244 of file PortableDeviceCollection.h.

244  {
245  return get<T>().view_;
246  }

Member Data Documentation

◆ buffer_

template<typename TDev, typename T0, typename... Args>
std::optional<Buffer> PortableDeviceMultiCollection< TDev, T0, Args >::buffer_
private

◆ count_t_

template<typename TDev, typename T0, typename... Args>
template<typename T >
constexpr std::size_t PortableDeviceMultiCollection< TDev, T0, Args >::count_t_ = portablecollection::typeCount<T, T0, Args...>
staticprivate

Definition at line 87 of file PortableDeviceCollection.h.

◆ impl_

template<typename TDev, typename T0, typename... Args>
Implementation PortableDeviceMultiCollection< TDev, T0, Args >::impl_
private

◆ index_t_

template<typename TDev, typename T0, typename... Args>
template<typename T >
constexpr std::size_t PortableDeviceMultiCollection< TDev, T0, Args >::index_t_ = portablecollection::typeIndex<T, T0, Args...>
staticprivate

Definition at line 90 of file PortableDeviceCollection.h.

◆ members_

template<typename TDev, typename T0, typename... Args>
constexpr std::size_t PortableDeviceMultiCollection< TDev, T0, Args >::members_ = sizeof...(Args) + 1
staticprivate

Definition at line 92 of file PortableDeviceCollection.h.