CMS 3D CMS Logo

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

#include <PortableHostCollection.h>

Public Types

using Buffer = cms::alpakatools::host_buffer< std::byte[]>
 
using ConstBuffer = cms::alpakatools::const_host_buffer< std::byte[]>
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
using ConstView = typename Layout< Idx >::ConstView
 
using Implementation = portablecollection::CollectionImpl< 0, T0, Args... >
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
using Layout = portablecollection::TypeResolver< Idx, T0, Args... >
 
using SizesArray = std::array< int32_t, members_ >
 
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
using View = typename Layout< Idx >::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
 
PortableHostMultiCollectionoperator= (PortableHostMultiCollection const &)=delete
 
PortableHostMultiCollectionoperator= (PortableHostMultiCollection &&)=default
 
 PortableHostMultiCollection ()=default
 
 PortableHostMultiCollection (int32_t elements, alpaka_common::DevHost const &host)
 
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
 PortableHostMultiCollection (int32_t elements, TQueue const &queue)
 
 PortableHostMultiCollection (const std::array< int32_t, members_ > &sizes, alpaka_common::DevHost const &host)
 
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
 PortableHostMultiCollection (const std::array< int32_t, members_ > &sizes, TQueue const &queue)
 
 PortableHostMultiCollection (PortableHostMultiCollection const &)=delete
 
 PortableHostMultiCollection (PortableHostMultiCollection &&)=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
 
 ~PortableHostMultiCollection ()=default
 

Static Public Member Functions

static void ROOTReadStreamer (PortableHostMultiCollection *newObj, Implementation &onfileImpl)
 

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 >
portablecollection::CollectionLeaf< index_t_< T >, T > & get ()
 
template<typename T >
const portablecollection::CollectionLeaf< index_t_< T >, T > & get () const
 

Static Private Member Functions

static int32_t computeDataSize (const std::array< int32_t, members_ > &sizes)
 

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_ = portablecollection::membersCount<T0, Args...>
 

Detailed Description

template<typename T0, typename... Args>
class PortableHostMultiCollection< T0, Args >

Definition at line 92 of file PortableHostCollection.h.

Member Typedef Documentation

◆ Buffer

template<typename T0, typename... Args>
using PortableHostMultiCollection< T0, Args >::Buffer = cms::alpakatools::host_buffer<std::byte[]>

Definition at line 102 of file PortableHostCollection.h.

◆ ConstBuffer

template<typename T0, typename... Args>
using PortableHostMultiCollection< T0, Args >::ConstBuffer = cms::alpakatools::const_host_buffer<std::byte[]>

Definition at line 103 of file PortableHostCollection.h.

◆ ConstView

template<typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
using PortableHostMultiCollection< T0, Args >::ConstView = typename Layout<Idx>::ConstView

Definition at line 113 of file PortableHostCollection.h.

◆ Implementation

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

Definition at line 104 of file PortableHostCollection.h.

◆ Layout

template<typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
using PortableHostMultiCollection< T0, Args >::Layout = portablecollection::TypeResolver<Idx, T0, Args...>

Definition at line 109 of file PortableHostCollection.h.

◆ Leaf

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

Definition at line 117 of file PortableHostCollection.h.

◆ SizesArray

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

Definition at line 106 of file PortableHostCollection.h.

◆ View

template<typename T0, typename... Args>
template<std::size_t Idx = 0, typename = std::enable_if_t<(members_ > Idx>
using PortableHostMultiCollection< T0, Args >::View = typename Layout<Idx>::View

Definition at line 111 of file PortableHostCollection.h.

Constructor & Destructor Documentation

◆ PortableHostMultiCollection() [1/7]

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

◆ PortableHostMultiCollection() [2/7]

template<typename T0, typename... Args>
PortableHostMultiCollection< T0, Args >::PortableHostMultiCollection ( int32_t  elements,
alpaka_common::DevHost const &  host 
)
inline

Definition at line 149 of file PortableHostCollection.h.

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

◆ PortableHostMultiCollection() [3/7]

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

Definition at line 159 of file PortableHostCollection.h.

161  : buffer_{cms::alpakatools::make_host_buffer<std::byte[]>(queue, Layout<>::computeDataSize(elements))},
162  impl_{buffer_->data(), elements} {
163  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
164  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<>::alignment == 0);
165  static_assert(members_ == 1);
166  }
static constexpr std::size_t members_
std::optional< Buffer > buffer_
assert(be >=bs)

◆ PortableHostMultiCollection() [4/7]

template<typename T0, typename... Args>
PortableHostMultiCollection< T0, Args >::PortableHostMultiCollection ( const std::array< int32_t, members_ > &  sizes,
alpaka_common::DevHost const &  host 
)
inline

Definition at line 168 of file PortableHostCollection.h.

170  : buffer_{cms::alpakatools::make_host_buffer<std::byte[]>(computeDataSize(sizes))},
171  impl_{buffer_->data(), sizes} {
172  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
173  portablecollection::constexpr_for<0, members_>(
174  [&](auto i) { assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<i>::alignment == 0); });
176  portablecollection::constexpr_for<1, members_>(
177  [&alignment](auto i) { static_assert(alignment == Layout<i>::alignment); });
178  }
std::optional< Buffer > buffer_
assert(be >=bs)
static int32_t computeDataSize(const std::array< int32_t, members_ > &sizes)

◆ PortableHostMultiCollection() [5/7]

template<typename T0, typename... Args>
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
PortableHostMultiCollection< T0, Args >::PortableHostMultiCollection ( const std::array< int32_t, members_ > &  sizes,
TQueue const &  queue 
)
inline

Definition at line 181 of file PortableHostCollection.h.

183  : buffer_{cms::alpakatools::make_host_buffer<std::byte[]>(queue, computeDataSize(sizes))},
184  impl_{buffer_->data(), sizes} {
185  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
186  portablecollection::constexpr_for<0, members_>(
187  [&](auto i) { assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout<i>::alignment == 0); });
189  portablecollection::constexpr_for<1, members_>(
190  [&alignment](auto i) { static_assert(alignment == Layout<i>::alignment); });
191  }
std::optional< Buffer > buffer_
assert(be >=bs)
static int32_t computeDataSize(const std::array< int32_t, members_ > &sizes)

◆ PortableHostMultiCollection() [6/7]

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

◆ PortableHostMultiCollection() [7/7]

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

◆ ~PortableHostMultiCollection()

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

Member Function Documentation

◆ buffer() [1/2]

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

◆ buffer() [2/2]

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

Definition at line 278 of file PortableHostCollection.h.

278 { return *buffer_; }
std::optional< Buffer > buffer_

◆ computeDataSize()

template<typename T0, typename... Args>
static int32_t PortableHostMultiCollection< T0, Args >::computeDataSize ( const std::array< int32_t, members_ > &  sizes)
inlinestaticprivate

Definition at line 139 of file PortableHostCollection.h.

Referenced by PortableHostMultiCollection< TestSoA, TestSoA2 >::PortableHostMultiCollection().

139  {
140  int32_t ret = 0;
141  portablecollection::constexpr_for<0, members_>(
142  [&sizes, &ret](auto i) { ret += Layout<i>::computeDataSize(sizes[i]); });
143  return ret;
144  }
ret
prodAgent to be discontinued

◆ const_buffer()

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

Definition at line 279 of file PortableHostCollection.h.

279 { return *buffer_; }
std::optional< Buffer > buffer_

◆ const_view() [1/2]

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

Definition at line 216 of file PortableHostCollection.h.

Referenced by TestAlpakaAnalyzer::analyze().

216  {
217  return get<Idx>().view_;
218  }

◆ const_view() [2/2]

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

Definition at line 252 of file PortableHostCollection.h.

252  {
253  return get<T>().view_;
254  }

◆ get() [1/4]

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

◆ get() [2/4]

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

◆ get() [3/4]

template<typename T0, typename... Args>
template<typename T >
portablecollection::CollectionLeaf<index_t_<T>, T>& PortableHostMultiCollection< T0, Args >::get ( )
inlineprivate

◆ get() [4/4]

template<typename T0, typename... Args>
template<typename T >
const portablecollection::CollectionLeaf<index_t_<T>, T>& PortableHostMultiCollection< T0, Args >::get ( ) const
inlineprivate

◆ operator*() [1/4]

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

Definition at line 221 of file PortableHostCollection.h.

221  {
222  return get<Idx>().view_;
223  }

◆ operator*() [2/4]

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

Definition at line 226 of file PortableHostCollection.h.

226  {
227  return get<Idx>().view_;
228  }

◆ operator*() [3/4]

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

Definition at line 257 of file PortableHostCollection.h.

257  {
258  return get<T>().view_;
259  }

◆ operator*() [4/4]

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

Definition at line 262 of file PortableHostCollection.h.

262  {
263  return get<T>().view_;
264  }

◆ operator->() [1/4]

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

Definition at line 231 of file PortableHostCollection.h.

231  {
232  return &get<Idx>().view_;
233  }

◆ operator->() [2/4]

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

Definition at line 236 of file PortableHostCollection.h.

236  {
237  return &get<Idx>().view_;
238  }

◆ operator->() [3/4]

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

Definition at line 267 of file PortableHostCollection.h.

267  {
268  return &get<T>().view_;
269  }

◆ operator->() [4/4]

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

Definition at line 272 of file PortableHostCollection.h.

272  {
273  return &get<T>().view_;
274  }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ ROOTReadStreamer()

template<typename T0, typename... Args>
static void PortableHostMultiCollection< T0, Args >::ROOTReadStreamer ( PortableHostMultiCollection< T0, Args > *  newObj,
Implementation onfileImpl 
)
inlinestatic

Definition at line 288 of file PortableHostCollection.h.

288  {
290  // use the global "host" object returned by cms::alpakatools::host()
291  std::array<int32_t, members_> sizes;
292  portablecollection::constexpr_for<0, members_>([&sizes, &onfileImpl](auto i) {
293  sizes[i] = static_cast<Leaf<i> const&>(onfileImpl).layout_.metadata().size();
294  });
296  portablecollection::constexpr_for<0, members_>([&newObj, &onfileImpl](auto i) {
297  static_cast<Leaf<i>&>(newObj->impl_).layout_.ROOTReadStreamer(static_cast<Leaf<i> const&>(onfileImpl).layout_);
298  static_cast<Leaf<i>&>(onfileImpl).layout_.ROOTStreamerCleaner();
299  });
300  }
~PortableHostMultiCollection()=default
alpaka::DevCpu const & host()
Definition: host.h:14

◆ sizes()

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

◆ view() [1/4]

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

Definition at line 206 of file PortableHostCollection.h.

Referenced by TestAlpakaAnalyzer::analyze().

206  {
207  return get<Idx>().view_;
208  }

◆ view() [2/4]

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

Definition at line 211 of file PortableHostCollection.h.

211  {
212  return get<Idx>().view_;
213  }

◆ view() [3/4]

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

Definition at line 242 of file PortableHostCollection.h.

242  {
243  return get<T>().view_;
244  }

◆ view() [4/4]

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

Definition at line 247 of file PortableHostCollection.h.

247  {
248  return get<T>().view_;
249  }

Member Data Documentation

◆ buffer_

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

◆ count_t_

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

Definition at line 94 of file PortableHostCollection.h.

◆ impl_

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

◆ index_t_

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

Definition at line 97 of file PortableHostCollection.h.

◆ members_

template<typename T0, typename... Args>
constexpr std::size_t PortableHostMultiCollection< T0, Args >::members_ = portablecollection::membersCount<T0, Args...>
staticprivate

Definition at line 99 of file PortableHostCollection.h.