CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
PortableHostCollection< T > 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[]>
 
using ConstView = typename Layout::ConstView
 
using Layout = T
 
using View = typename Layout::View
 

Public Member Functions

Buffer buffer ()
 
ConstBuffer buffer () const
 
ConstBuffer const_buffer () const
 
ConstView const & const_view () const
 
Viewoperator* ()
 
ConstView const & operator* () const
 
Viewoperator-> ()
 
ConstView const * operator-> () const
 
PortableHostCollectionoperator= (PortableHostCollection const &)=delete
 
PortableHostCollectionoperator= (PortableHostCollection &&)=default
 
 PortableHostCollection ()=default
 
 PortableHostCollection (int32_t elements, alpaka_common::DevHost const &host)
 
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
 PortableHostCollection (int32_t elements, TQueue const &queue)
 
 PortableHostCollection (PortableHostCollection const &)=delete
 
 PortableHostCollection (PortableHostCollection &&)=default
 
Viewview ()
 
ConstView const & view () const
 
 ~PortableHostCollection ()=default
 

Static Public Member Functions

static void ROOTReadStreamer (PortableHostCollection *newObj, Layout &layout)
 

Private Attributes

std::optional< Bufferbuffer_
 
Layout layout_
 
View view_
 

Detailed Description

template<typename T>
class PortableHostCollection< T >

Definition at line 16 of file PortableHostCollection.h.

Member Typedef Documentation

◆ Buffer

template<typename T>
using PortableHostCollection< T >::Buffer = cms::alpakatools::host_buffer<std::byte[]>

Definition at line 21 of file PortableHostCollection.h.

◆ ConstBuffer

template<typename T>
using PortableHostCollection< T >::ConstBuffer = cms::alpakatools::const_host_buffer<std::byte[]>

Definition at line 22 of file PortableHostCollection.h.

◆ ConstView

template<typename T>
using PortableHostCollection< T >::ConstView = typename Layout::ConstView

Definition at line 20 of file PortableHostCollection.h.

◆ Layout

template<typename T>
using PortableHostCollection< T >::Layout = T

Definition at line 18 of file PortableHostCollection.h.

◆ View

template<typename T>
using PortableHostCollection< T >::View = typename Layout::View

Definition at line 19 of file PortableHostCollection.h.

Constructor & Destructor Documentation

◆ PortableHostCollection() [1/5]

template<typename T>
PortableHostCollection< T >::PortableHostCollection ( )
default

◆ PortableHostCollection() [2/5]

template<typename T>
PortableHostCollection< T >::PortableHostCollection ( int32_t  elements,
alpaka_common::DevHost const &  host 
)
inline

Definition at line 26 of file PortableHostCollection.h.

28  : buffer_{cms::alpakatools::make_host_buffer<std::byte[]>(Layout::computeDataSize(elements))},
29  layout_{buffer_->data(), elements},
30  view_{layout_} {
31  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
32  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout::alignment == 0);
33  }
assert(be >=bs)
std::optional< Buffer > buffer_

◆ PortableHostCollection() [3/5]

template<typename T>
template<typename TQueue , typename = std::enable_if_t<alpaka::isQueue<TQueue>>>
PortableHostCollection< T >::PortableHostCollection ( int32_t  elements,
TQueue const &  queue 
)
inline

Definition at line 36 of file PortableHostCollection.h.

38  : buffer_{cms::alpakatools::make_host_buffer<std::byte[]>(queue, Layout::computeDataSize(elements))},
39  layout_{buffer_->data(), elements},
40  view_{layout_} {
41  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
42  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout::alignment == 0);
43  }
assert(be >=bs)
std::optional< Buffer > buffer_

◆ PortableHostCollection() [4/5]

template<typename T>
PortableHostCollection< T >::PortableHostCollection ( PortableHostCollection< T > const &  )
delete

◆ PortableHostCollection() [5/5]

template<typename T>
PortableHostCollection< T >::PortableHostCollection ( PortableHostCollection< T > &&  )
default

◆ ~PortableHostCollection()

template<typename T>
PortableHostCollection< T >::~PortableHostCollection ( )
default

Member Function Documentation

◆ buffer() [1/2]

template<typename T>
Buffer PortableHostCollection< T >::buffer ( )
inline

◆ buffer() [2/2]

template<typename T>
ConstBuffer PortableHostCollection< T >::buffer ( ) const
inline

Definition at line 69 of file PortableHostCollection.h.

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

◆ const_buffer()

template<typename T>
ConstBuffer PortableHostCollection< T >::const_buffer ( ) const
inline

Definition at line 70 of file PortableHostCollection.h.

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

◆ const_view()

template<typename T>
ConstView const& PortableHostCollection< T >::const_view ( ) const
inline

◆ operator*() [1/2]

template<typename T>
View& PortableHostCollection< T >::operator* ( void  )
inline

Definition at line 61 of file PortableHostCollection.h.

◆ operator*() [2/2]

template<typename T>
ConstView const& PortableHostCollection< T >::operator* ( void  ) const
inline

Definition at line 62 of file PortableHostCollection.h.

◆ operator->() [1/2]

template<typename T>
View* PortableHostCollection< T >::operator-> ( )
inline

Definition at line 64 of file PortableHostCollection.h.

64 { return &view_; }

◆ operator->() [2/2]

template<typename T>
ConstView const* PortableHostCollection< T >::operator-> ( ) const
inline

Definition at line 65 of file PortableHostCollection.h.

65 { return &view_; }

◆ operator=() [1/2]

template<typename T>
PortableHostCollection& PortableHostCollection< T >::operator= ( PortableHostCollection< T > const &  )
delete

◆ operator=() [2/2]

template<typename T>
PortableHostCollection& PortableHostCollection< T >::operator= ( PortableHostCollection< T > &&  )
default

◆ ROOTReadStreamer()

template<typename T>
static void PortableHostCollection< T >::ROOTReadStreamer ( PortableHostCollection< T > *  newObj,
Layout layout 
)
inlinestatic

Definition at line 73 of file PortableHostCollection.h.

73  {
74  // destroy the default-constructed collection
75  newObj->~PortableHostCollection();
76  // construct in-place a new collection, with the known size, using the global "host" object returned by cms::alpakatools::host()
77  new (newObj) PortableHostCollection(layout.metadata().size(), cms::alpakatools::host());
78  // copy the data from the on-file layout to the new collection
79  newObj->layout_.ROOTReadStreamer(layout);
80  // free the memory allocated by ROOT
81  layout.ROOTStreamerCleaner();
82  }
PortableHostCollection()=default
~PortableHostCollection()=default
alpaka::DevCpu const & host()
Definition: host.h:14

◆ view() [1/2]

template<typename T>
View& PortableHostCollection< T >::view ( )
inline

◆ view() [2/2]

template<typename T>
ConstView const& PortableHostCollection< T >::view ( ) const
inline

Definition at line 58 of file PortableHostCollection.h.

Member Data Documentation

◆ buffer_

template<typename T>
std::optional<Buffer> PortableHostCollection< T >::buffer_
private

◆ layout_

template<typename T>
Layout PortableHostCollection< T >::layout_
private

◆ view_

template<typename T>
View PortableHostCollection< T >::view_
private