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 476 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 620 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

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

◆ 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 652 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

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

◆ 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 634 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

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

◆ 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 670 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

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

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
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:221
CaloRecGPU::Helpers::MemoryManagement::move
static void move(T *&dest, T *&source, const indexer sz)
!
Definition: Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h:670
copySelective.source
string source
Definition: copySelective.py:32
calibdata.copy
bool copy
Definition: calibdata.py:27
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35