OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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.
 
memorygetMemory ()
 This function get the object that allocate memory.
 
void switchToDevicePtr ()
 Switch the pointer to device pointer.
 
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.
 
bool allocate (const size_t sz, bool skip_initialization=false)
 This function allocate memory and associate the representation to mem_r.
 
 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 set_mem (memory &mem)
 set the device memory interface, the object that allocate memory
 
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

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< typenameboost::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

◆ at

template<typename T , typename D >
template<typename S , unsigned int n>
using memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::at = boost::mpl::at<S,boost::mpl::int_<n> >
private

Define "at" meta function without boost::mpl.

Definition at line 367 of file memory_c.hpp.

◆ base

template<typename T , typename D >
typedef at<T,0>::type memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::base
private

Definition at line 369 of file memory_c.hpp.

◆ int_

template<typename T , typename D >
template<int S>
using memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::int_ = boost::mpl::int_<S>
private

define boost::mpl::int_ without boost::mpl

Definition at line 361 of file memory_c.hpp.

◆ size_p

template<typename T , typename D >
typedef boost::mpl::size<T> memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::size_p
private

define the template vector size it give a number at compile time

Definition at line 364 of file memory_c.hpp.

◆ size_type

template<typename T , typename D >
typedef openfpm::multi_array_ref_openfpm<base,size_p::value,Tv>::size_type memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::size_type
private

define size_type

Definition at line 372 of file memory_c.hpp.

◆ Tv

template<typename T , typename D >
typedef boost::mpl::push_front<typenameboost::mpl::pop_front<T>::type,boost::mpl::int_<-1>>::type memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::Tv
private

Remove the first element.

Definition at line 358 of file memory_c.hpp.

◆ 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.

Constructor & Destructor Documentation

◆ memory_c()

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

constructor

Definition at line 471 of file memory_c.hpp.

◆ ~memory_c()

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

destructor

Definition at line 477 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.

◆ set_mem()

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

set the device memory interface, the object that allocate memory

Definition at line 500 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.

◆ mem

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

Reference to an object to allocate memory.

Definition at line 465 of file memory_c.hpp.

◆ mem_r

template<typename T , typename D >
openfpm::multi_array_ref_openfpm<base,boost::mpl::size<T>::value,Tv> memory_c< multi_array< T >, MEMORY_C_STANDARD, D >::mem_r

object that represent the memory as a multi-dimensional array of objects T

Definition at line 468 of file memory_c.hpp.


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