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
 
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
void zeroInitialise (TQueue &&queue)
 
 ~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 87 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 101 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 102 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 120 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 103 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 108 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 124 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 105 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 114 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 149 of file PortableDeviceCollection.h.

References bookConverter::elements.

150  : buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(device, Layout<>::computeDataSize(elements))},
151  impl_{buffer_->data(), elements} {
152  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
153  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<>::alignment == 0);
154  static_assert(members_ == 1);
155  }
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 158 of file PortableDeviceCollection.h.

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

159  : buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(queue, Layout<>::computeDataSize(elements))},
160  impl_{buffer_->data(), elements} {
161  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
162  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<>::alignment == 0);
163  static_assert(members_ == 1);
164  }
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 173 of file PortableDeviceCollection.h.

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

175  : buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(device, computeDataSize(sizes))},
176  impl_{buffer_->data(), sizes} {
177  portablecollection::constexpr_for<0, members_>(
178  [&](auto i) { assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<i>::alignment == 0); });
180  portablecollection::constexpr_for<1, members_>(
181  [&alignment](auto i) { static_assert(alignment == Layout<i>::alignment); });
182  }
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 185 of file PortableDeviceCollection.h.

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

187  : buffer_{cms::alpakatools::make_device_buffer<std::byte[]>(queue, computeDataSize(sizes))},
188  impl_{buffer_->data(), sizes} {
189  portablecollection::constexpr_for<0, members_>(
190  [&](auto i) { assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<i>::alignment == 0); });
192  portablecollection::constexpr_for<1, members_>(
193  [&alignment](auto i) { static_assert(alignment == Layout<i>::alignment); });
194  }
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 166 of file PortableDeviceCollection.h.

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

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

166  {
167  int32_t ret = 0;
168  portablecollection::constexpr_for<0, members_>(
169  [&sizes, &ret](auto i) { ret += Layout<i>::computeDataSize(sizes[i]); });
170  return ret;
171  }
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 219 of file PortableDeviceCollection.h.

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

◆ 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 255 of file PortableDeviceCollection.h.

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

◆ 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 224 of file PortableDeviceCollection.h.

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

◆ 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 229 of file PortableDeviceCollection.h.

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

◆ 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 260 of file PortableDeviceCollection.h.

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

◆ 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 265 of file PortableDeviceCollection.h.

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

◆ 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 234 of file PortableDeviceCollection.h.

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

◆ 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 239 of file PortableDeviceCollection.h.

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

◆ operator->() [3/4]

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

Definition at line 270 of file PortableDeviceCollection.h.

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

◆ 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 275 of file PortableDeviceCollection.h.

275  {
276  return &get<T>().view_;
277  }

◆ 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 291 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().

291  {
292  SizesArray ret;
293  portablecollection::constexpr_for<0, members_>([&](auto i) { ret[i] = get<i>().layout_.metadata().size(); });
294  return ret;
295  }
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 209 of file PortableDeviceCollection.h.

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

◆ 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 214 of file PortableDeviceCollection.h.

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

◆ view() [3/4]

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

Definition at line 245 of file PortableDeviceCollection.h.

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

◆ 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 250 of file PortableDeviceCollection.h.

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

◆ zeroInitialise()

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

Definition at line 286 of file PortableDeviceCollection.h.

References PortableDeviceMultiCollection< TDev, T0, Args >::buffer_, and createBeamHaloJobs::queue.

286  {
287  alpaka::memset(std::forward<TQueue>(queue), *buffer_, 0x00);
288  }

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 93 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 96 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 98 of file PortableDeviceCollection.h.