ATLAS Offline Software
Loading...
Searching...
No Matches
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)
 !
template<class Context>
static void deallocate (T *&arr)
 !
template<class DestContext, class SourceContext>
static void copy (T *dest, const T *const source, const indexer sz)
 !
template<class DestContext, class SourceContext>
static void move (T *&dest, T *&source, const indexer sz)
 !

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

Member Function Documentation

◆ allocate()

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

!

Allocates size elements from memory context Context

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

792 {
793 T * ret = nullptr;
794 if (size > 0)
795 {
797 }
798#if CALORECGPU_HELPERS_DEBUG
799 std::cerr << "ALLOCATED " << size << " x " << sizeof(T) << " in " << Context::name << ": " << ret << std::endl;
800#endif
801 return ret;
802 }
! Handles allocation of a type T, using indexer as the integer type to indicate sizes.

◆ copy()

template<class T, class indexer>
template<class DestContext, class SourceContext>
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 823 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

824 {
825 if (sz > 0 && source != nullptr)
826 {
828 }
829#if CALORECGPU_HELPERS_DEBUG
830 std::cerr << "COPIED " << sz << " from " << SourceContext::name << " to " << DestContext::name << ": " << source << " to " << dest << std::endl;
831#endif
832 }

◆ deallocate()

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

!

Deallocates arr from memory context Context

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

806 {
807 if (arr == nullptr)
808 //This check is to ensure the code behaves on non-CUDA enabled platforms
809 //where some destructors might still be called with nullptr.
810 {
811 return;
812 }
814#if CALORECGPU_HELPERS_DEBUG
815 std::cerr << "DEALLOCATED in " << Context::name << ": " << arr << std::endl;
816#endif
817 arr = nullptr;
818 }

◆ move()

template<class T, class indexer>
template<class DestContext, class SourceContext>
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 841 of file Calorimeter/CaloRecGPU/CaloRecGPU/Helpers.h.

842 {
843#if CALORECGPU_HELPERS_DEBUG
844 std::cerr << "MOVED " << sz << " from " << SourceContext::name << " to " << DestContext::name << ": " << source << " to " << dest;
845#endif
846 if (sz > 0 && source != nullptr)
847 {
849 }
850 else
851 {
852 dest = nullptr;
854 }
855#if CALORECGPU_HELPERS_DEBUG
856 std::cerr << " | " << source << " to " << dest << std::endl;
857#endif
858 }
static void move(T *&dest, T *&source, const indexer sz)
!

The documentation for this class was generated from the following file: