ATLAS Offline Software
Classes | Static Public Member Functions | List of all members
CaloRecGPU::Helpers::MemoryManagement< T, indexer > Class Template Reference

! Handles allocation of a type T, using indexer as the integer type to indicate sizes. More...

#include <Helpers.h>

Collaboration diagram for CaloRecGPU::Helpers::MemoryManagement< T, indexer >:

Classes

struct  copy_helper
 
struct  copy_helper< MemoryContext::CPU, MemoryContext::CPU, dummy >
 
struct  copy_helper< MemoryContext::CPU, MemoryContext::CUDAGPU, dummy >
 
struct  copy_helper< MemoryContext::CPU, MemoryContext::CUDAPinnedCPU, dummy >
 
struct  copy_helper< MemoryContext::CUDAGPU, MemoryContext::CPU, dummy >
 
struct  copy_helper< MemoryContext::CUDAGPU, MemoryContext::CUDAGPU, dummy >
 
struct  copy_helper< MemoryContext::CUDAGPU, MemoryContext::CUDAPinnedCPU, dummy >
 
struct  copy_helper< MemoryContext::CUDAPinnedCPU, MemoryContext::CPU, dummy >
 
struct  copy_helper< MemoryContext::CUDAPinnedCPU, MemoryContext::CUDAGPU, dummy >
 
struct  copy_helper< MemoryContext::CUDAPinnedCPU, MemoryContext::CUDAPinnedCPU, dummy >
 
struct  move_helper
 
struct  move_helper< C, C, dummy >
 
struct  unary_helper
 
struct  unary_helper< MemoryContext::CPU, dummy >
 
struct  unary_helper< MemoryContext::CUDAGPU, dummy >
 
struct  unary_helper< MemoryContext::CUDAPinnedCPU, dummy >
 

Static Public Member Functions

template<class Context >
static T * allocate (const indexer size)
 ! More...
 
template<class Context >
static void deallocate (T *&arr)
 ! More...
 
template<class DestContext , class SourceContext >
static void copy (T *dest, const T *const source, const indexer sz)
 ! More...
 
template<class DestContext , class SourceContext >
static void move (T *&dest, T *&source, const indexer sz)
 ! More...
 

Detailed Description

template<class T, class indexer>
class CaloRecGPU::Helpers::MemoryManagement< T, indexer >

! Handles allocation of a type T, using indexer as the integer type to indicate sizes.

Definition at line 475 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

Member Function Documentation

◆ allocate()

template<class T , class indexer >
template<class Context >
static T* CaloRecGPU::Helpers::MemoryManagement< T, indexer >::allocate ( const indexer  size)
inlinestatic

!

Allocates size elements from memory context Context

Definition at line 619 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

620  {
621  T * ret = nullptr;
622  if (size > 0)
623  {
625  }
626 #if CALORECGPU_HELPERS_DEBUG
627  std::cerr << "ALLOCATED " << size << " x " << sizeof(T) << " in " << Context::name << ": " << ret << std::endl;
628 #endif
629  return ret;
630  }

◆ copy()

template<class T , class indexer >
template<class DestContext , class SourceContext >
static void CaloRecGPU::Helpers::MemoryManagement< T, indexer >::copy ( T *  dest,
const T *const  source,
const indexer  sz 
)
inlinestatic

!

Copies sz bytes from source in SourceContext to dest in DestContext

Definition at line 651 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

652  {
653  if (sz > 0 && source != nullptr)
654  {
656  }
657 #if CALORECGPU_HELPERS_DEBUG
658  std::cerr << "COPIED " << sz << " from " << SourceContext::name << " to " << DestContext::name << ": " << source << " to " << dest << std::endl;
659 #endif
660  }

◆ deallocate()

template<class T , class indexer >
template<class Context >
static void CaloRecGPU::Helpers::MemoryManagement< T, indexer >::deallocate ( T *&  arr)
inlinestatic

!

Deallocates arr from memory context Context

Definition at line 633 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

634  {
635  if (arr == nullptr)
636  //This check is to ensure the code behaves on non-CUDA enabled platforms
637  //where some destructors might still be called with nullptr.
638  {
639  return;
640  }
642 #if CALORECGPU_HELPERS_DEBUG
643  std::cerr << "DEALLOCATED in " << Context::name << ": " << arr << std::endl;
644 #endif
645  arr = nullptr;
646  }

◆ move()

template<class T , class indexer >
template<class DestContext , class SourceContext >
static void CaloRecGPU::Helpers::MemoryManagement< T, indexer >::move ( T *&  dest,
T *&  source,
const indexer  sz 
)
inlinestatic

!

Moves sz bytes from source in SourceContext to dest in DestContext (performing the necessary data transfers and deallocations when the contexts are different). source is set to null and dest may be nulled if sz is 0 or source is null too.

Definition at line 669 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

670  {
671 #if CALORECGPU_HELPERS_DEBUG
672  std::cerr << "MOVED " << sz << " from " << SourceContext::name << " to " << DestContext::name << ": " << source << " to " << dest;
673 #endif
674  if (sz > 0 && source != nullptr)
675  {
676  move_helper<DestContext, SourceContext, std::is_same<DestContext, SourceContext>>::move(dest, source, sz);
677  }
678  else
679  {
680  dest = nullptr;
681  deallocate<SourceContext>(source);
682  }
683 #if CALORECGPU_HELPERS_DEBUG
684  std::cerr << " | " << source << " to " << dest << std::endl;
685 #endif
686  }

The documentation for this class was generated from the following file:
fitman.sz
sz
Definition: fitman.py:527
perfmonmt-printer.dest
dest
Definition: perfmonmt-printer.py:189
CaloRecGPU::CUDA_Helpers::deallocate
void deallocate(void *address)
Deallocates address in GPU memory.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ret
T ret(T t)
Definition: rootspy.cxx:260
CaloRecGPU::CUDA_Helpers::allocate
void * allocate(const size_t num)
Allocates and returns the address of num bytes from GPU memory.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloRecGPU::Helpers::MemoryManagement::move
static void move(T *&dest, T *&source, const indexer sz)
!
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:669
calibdata.copy
bool copy
Definition: calibdata.py:27
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35