OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
memory_c< T, MEMORY_C_STANDARD, D > Class Template Reference

This class is a container for the memory interface like HeapMemory CudaMemory. More...

Detailed Description

template<typename T, typename D>
class memory_c< T, MEMORY_C_STANDARD, D >

This class is a container for the memory interface like HeapMemory CudaMemory.

It store the object used to allocate memory and a representation of this memory as an array of objects T

It is mainly used by memory_conf to create the correct memory layout

See also
memory_traits_inte memory_traits_lin

Definition at line 45 of file memory_c.hpp.

#include <memory_c.hpp>

Public Types

typedef memory_c< T > type
 define T
 
typedef T & reference
 define a reference to T
 
typedef T vtype
 define T
 

Public Member Functions

void setMemory (memory &mem)
 This function set the object that allocate memory.
 
bool bind_ref (const memory_c< T, MEMORY_C_STANDARD, D > &ref)
 This function bind the memory_c to this memory_c as reference.
 
memorygetMemory ()
 This function get the object that allocate memory.
 
void switchToDevicePtr ()
 Switch the pointer to device pointer (if the memory has been already set)
 
const memorygetMemory () const
 This function get the object that allocate memory.
 
bool allocate (const size_t sz, bool skip_initialization=false)
 This function allocate memory.
 
 memory_c (bool manage_memory=true)
 constructor
 
 ~memory_c ()
 destructor
 
void disable_manage_memory ()
 Disable the management of memory (it is used for toKernel views)
 
void swap (memory_c &mem_obj)
 swap the memory
 
template<typename Mem_type >
__host__ void swap_nomode (memory_c &mem_obj)
 swap the memory
 

Data Fields

memorymem
 object that allocate memory like HeapMemory or CudaMemory
 
memory_array< T > mem_r
 object that represent the memory as an array of objects T
 

Private Attributes

bool manage_memory = true
 

Member Typedef Documentation

◆ reference

template<typename T , typename D >
typedef T& memory_c< T, MEMORY_C_STANDARD, D >::reference

define a reference to T

Definition at line 60 of file memory_c.hpp.

◆ type

template<typename T , typename D >
typedef memory_c<T> memory_c< T, MEMORY_C_STANDARD, D >::type

define T

Definition at line 57 of file memory_c.hpp.

◆ vtype

template<typename T , typename D >
typedef T memory_c< T, MEMORY_C_STANDARD, D >::vtype

define T

Definition at line 63 of file memory_c.hpp.

Constructor & Destructor Documentation

◆ memory_c()

template<typename T , typename D >
memory_c< T, MEMORY_C_STANDARD, D >::memory_c ( bool  manage_memory = true)
inline

constructor

Definition at line 159 of file memory_c.hpp.

◆ ~memory_c()

template<typename T , typename D >
memory_c< T, MEMORY_C_STANDARD, D >::~memory_c ( )
inline

destructor

Definition at line 163 of file memory_c.hpp.

Member Function Documentation

◆ allocate()

template<typename T , typename D >
bool memory_c< T, MEMORY_C_STANDARD, D >::allocate ( const size_t  sz,
bool  skip_initialization = false 
)
inline

This function allocate memory.

We create a chunk of memory

we create the representation for this buffer

Definition at line 145 of file memory_c.hpp.

◆ bind_ref()

template<typename T , typename D >
bool memory_c< T, MEMORY_C_STANDARD, D >::bind_ref ( const memory_c< T, MEMORY_C_STANDARD, D > &  ref)
inline

This function bind the memory_c to this memory_c as reference.

Bind ad reference it mean this this object does not create new memory but use the one from ref as a reference.

we create the representation for the memory buffer

Definition at line 98 of file memory_c.hpp.

◆ disable_manage_memory()

template<typename T , typename D >
void memory_c< T, MEMORY_C_STANDARD, D >::disable_manage_memory ( )
inline

Disable the management of memory (it is used for toKernel views)

Definition at line 182 of file memory_c.hpp.

◆ getMemory() [1/2]

template<typename T , typename D >
memory & memory_c< T, MEMORY_C_STANDARD, D >::getMemory ( )
inline

This function get the object that allocate memory.

Returns
memory object to allocate memory

Definition at line 117 of file memory_c.hpp.

◆ getMemory() [2/2]

template<typename T , typename D >
const memory & memory_c< T, MEMORY_C_STANDARD, D >::getMemory ( ) const
inline

This function get the object that allocate memory.

Returns
memory object to allocate memory

Definition at line 137 of file memory_c.hpp.

◆ setMemory()

template<typename T , typename D >
void memory_c< T, MEMORY_C_STANDARD, D >::setMemory ( memory mem)
inline

This function set the object that allocate memory.

Parameters
memthe memory object

Definition at line 76 of file memory_c.hpp.

◆ swap()

template<typename T , typename D >
void memory_c< T, MEMORY_C_STANDARD, D >::swap ( memory_c< T, MEMORY_C_STANDARD, D > &  mem_obj)
inline

swap the memory

swap the memory between objects

Definition at line 192 of file memory_c.hpp.

◆ swap_nomode()

template<typename T , typename D >
template<typename Mem_type >
__host__ void memory_c< T, MEMORY_C_STANDARD, D >::swap_nomode ( memory_c< T, MEMORY_C_STANDARD, D > &  mem_obj)
inline

swap the memory

swap the memory between objects

Definition at line 209 of file memory_c.hpp.

◆ switchToDevicePtr()

template<typename T , typename D >
void memory_c< T, MEMORY_C_STANDARD, D >::switchToDevicePtr ( )
inline

Switch the pointer to device pointer (if the memory has been already set)

Definition at line 125 of file memory_c.hpp.

Field Documentation

◆ manage_memory

template<typename T , typename D >
bool memory_c< T, MEMORY_C_STANDARD, D >::manage_memory = true
private

indicate this object manage the memory. Call to functions like toKernels create views of the main data-structure. Views use memory_c create different ways to access the same sata. We have mainly have two options. Either views manage memory, either they do not. When a view manage the memory if the main-data structure get destroyed the view is still valid, the memory retained and the last view destroy the memory. When a view does not manage the memory, if the main-data structure get destroyed the view become invalid.

Definition at line 52 of file memory_c.hpp.

◆ mem

template<typename T , typename D >
memory* memory_c< T, MEMORY_C_STANDARD, D >::mem

object that allocate memory like HeapMemory or CudaMemory

Definition at line 66 of file memory_c.hpp.

◆ mem_r

template<typename T , typename D >
memory_array<T> memory_c< T, MEMORY_C_STANDARD, D >::mem_r

object that represent the memory as an array of objects T

Definition at line 69 of file memory_c.hpp.


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