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

628  {
629  T * ret = nullptr;
630  if (size > 0)
631  {
633  }
634 #if CALORECGPU_HELPERS_DEBUG
635  std::cerr << "ALLOCATED " << size << " x " << sizeof(T) << " in " << Context::name << ": " << ret << std::endl;
636 #endif
637  return ret;
638  }

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

660  {
661  if (sz > 0 && source != nullptr)
662  {
664  }
665 #if CALORECGPU_HELPERS_DEBUG
666  std::cerr << "COPIED " << sz << " from " << SourceContext::name << " to " << DestContext::name << ": " << source << " to " << dest << std::endl;
667 #endif
668  }

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

642  {
643  if (arr == nullptr)
644  //This check is to ensure the code behaves on non-CUDA enabled platforms
645  //where some destructors might still be called with nullptr.
646  {
647  return;
648  }
650 #if CALORECGPU_HELPERS_DEBUG
651  std::cerr << "DEALLOCATED in " << Context::name << ": " << arr << std::endl;
652 #endif
653  arr = nullptr;
654  }

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

678  {
679 #if CALORECGPU_HELPERS_DEBUG
680  std::cerr << "MOVED " << sz << " from " << SourceContext::name << " to " << DestContext::name << ": " << source << " to " << dest;
681 #endif
682  if (sz > 0 && source != nullptr)
683  {
684  move_helper<DestContext, SourceContext, std::is_same<DestContext, SourceContext>>::move(dest, source, sz);
685  }
686  else
687  {
688  dest = nullptr;
689  deallocate<SourceContext>(source);
690  }
691 #if CALORECGPU_HELPERS_DEBUG
692  std::cerr << " | " << source << " to " << dest << std::endl;
693 #endif
694  }

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