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 15 of file PortableHostCollection.h.

Member Typedef Documentation

◆ Buffer

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

Definition at line 20 of file PortableHostCollection.h.

◆ ConstBuffer

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

Definition at line 21 of file PortableHostCollection.h.

◆ ConstView

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

Definition at line 19 of file PortableHostCollection.h.

◆ Layout

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

Definition at line 17 of file PortableHostCollection.h.

◆ View

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

Definition at line 18 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 25 of file PortableHostCollection.h.

27  : buffer_{cms::alpakatools::make_host_buffer<std::byte[]>(Layout::computeDataSize(elements))},
28  layout_{buffer_->data(), elements},
29  view_{layout_} {
30  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
31  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout::alignment == 0);
32  }
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 35 of file PortableHostCollection.h.

37  : buffer_{cms::alpakatools::make_host_buffer<std::byte[]>(queue, Layout::computeDataSize(elements))},
38  layout_{buffer_->data(), elements},
39  view_{layout_} {
40  // Alpaka set to a default alignment of 128 bytes defining ALPAKA_DEFAULT_HOST_MEMORY_ALIGNMENT=128
41  assert(reinterpret_cast<uintptr_t>(buffer_->data()) % Layout::alignment == 0);
42  }
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 68 of file PortableHostCollection.h.

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

◆ const_buffer()

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

Definition at line 69 of file PortableHostCollection.h.

69 { 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 60 of file PortableHostCollection.h.

◆ operator*() [2/2]

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

Definition at line 61 of file PortableHostCollection.h.

◆ operator->() [1/2]

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

Definition at line 63 of file PortableHostCollection.h.

63 { return &view_; }

◆ operator->() [2/2]

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

Definition at line 64 of file PortableHostCollection.h.

64 { 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 72 of file PortableHostCollection.h.

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

◆ 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 57 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