OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
memory_c< multi_array< T >, MEMORY_C_STANDARD, D > Class Template Reference

Specialization of memory_c for multi_array. More...

Detailed Description

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

Specialization of memory_c for multi_array.

Specialization of memory_c for multi_array

It is mainly used by memory_conf to create the correct layout

See also
memory_traits_inte memory_traits_lin
Template Parameters
Tis suppose to be a boost::mpl::vector specifing at position 0 the type and at position 1 to N the dimensions size of the multi_array
Dobject that allocate memory

Definition at line 336 of file memory_c.hpp.

#include <memory_c.hpp>

Data Structures

struct  ascending
 In combination with generate_array is used to produce array at compile-time. More...
 

Public Types

typedef boost::multi_array< base, size_p::value > type
 

Public Member Functions

void setMemory (memory &mem)
 This function set the object that allocate memory. More...
 
memorygetMemory ()
 This function get the object that allocate memory. More...
 
void switchToDevicePtr ()
 Switch the pointer to device pointer. More...
 
bool bind_ref (const memory_c< multi_array< T >, MEMORY_C_STANDARD, D > &ref)
 This function bind the memory_c to this memory_c as reference. More...
 
bool allocate (const size_t sz, bool skip_initialization=false)
 This function allocate memory and associate the representation to mem_r. More...
 
 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) More...
 
void set_mem (memory &mem)
 set the device memory interface, the object that allocate memory
 
void swap (memory_c &mem_obj)
 swap the memory More...
 
template<typename Mem_type >
__host__ void swap_nomode (memory_c &mem_obj)
 swap the memory More...
 

Data Fields

Dmem
 Reference to an object to allocate memory.
 
openfpm::multi_array_ref_openfpm< base, boost::mpl::size< T >::value, Tvmem_r
 object that represent the memory as a multi-dimensional array of objects T
 

Private Types

typedef boost::mpl::push_front< typename boost::mpl::pop_front< T >::type, boost::mpl::int_<-1 > >::type Tv
 Remove the first element.
 
template<int S>
using int_ = boost::mpl::int_< S >
 define boost::mpl::int_ without boost::mpl
 
typedef boost::mpl::size< T > size_p
 define the template vector size it give a number at compile time
 
template<typename S , unsigned int n>
using at = boost::mpl::at< S, boost::mpl::int_< n > >
 Define "at" meta function without boost::mpl.
 
typedef at< T, 0 >::type base
 
typedef openfpm::multi_array_ref_openfpm< base, size_p::value, Tv >::size_type size_type
 define size_type
 

Private Attributes

bool manage_memory = true
 

Member Typedef Documentation

◆ type

template<typename T , typename D >
typedef boost::multi_array<base,size_p::value> memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::type

define the type of the multi_array vector minus one of the original size basically we remove the index 0 of the multi_array

Definition at line 462 of file memory_c.hpp.

Member Function Documentation

◆ allocate()

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

This function allocate memory and associate the representation to mem_r.

This function allocate memory and associate the representation of that chunk of memory to mem_r

We create a chunk of memory

we create the representation for the memory buffer

Definition at line 443 of file memory_c.hpp.

◆ bind_ref()

template<typename T , typename D >
bool memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::bind_ref ( const memory_c< multi_array< 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 425 of file memory_c.hpp.

◆ disable_manage_memory()

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

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

Definition at line 494 of file memory_c.hpp.

◆ getMemory()

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

This function get the object that allocate memory.

Returns
memory object to allocate memory

Definition at line 404 of file memory_c.hpp.

◆ setMemory()

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

This function set the object that allocate memory.

Parameters
memthe memory object

Definition at line 382 of file memory_c.hpp.

◆ swap()

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

swap the memory

swap the memory between objects

Definition at line 510 of file memory_c.hpp.

◆ swap_nomode()

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

swap the memory

While the previous one swap the mem the swap_nomode call the swap member of the mem object

Note
calling the swap member require knowledge of the object type, we cannot work on abtsract objects

swap the memory between objects

Definition at line 532 of file memory_c.hpp.

◆ switchToDevicePtr()

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

Switch the pointer to device pointer.

Definition at line 412 of file memory_c.hpp.

Field Documentation

◆ manage_memory

template<typename T , typename D >
bool memory_c< multi_array< 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 343 of file memory_c.hpp.


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