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

This class give a representation to a chunk or memory. More...

Detailed Description

template<typename T>
class memory_array< T >

This class give a representation to a chunk or memory.

This class give a representation to a chunk of memory as an array of T objects

Parameters
TThis is the object type

Definition at line 26 of file memory_array.hpp.

#include <memory_array.hpp>

Public Types

typedef T value_type
 type returned by this structure
 

Public Member Functions

void initialize (void *ptr, size_t sz, bool init)
 Initialize the memory array.
 
size_t size ()
 return the size of the array
 
void set_pointer (void *ptr_)
 Set the internal pointer to the indicated chunk of memory.
 
__device__ __host__ void * get_pointer () const
 Return the pointer.
 
template<typename Tbind >
void bind_ref (const memory_array< Tbind > &ref)
 Set from another memory array.
 
__host__ __device__ T & operator[] (mem_id i)
 Access element an element of the array.
 
__host__ __device__ const T & operator[] (mem_id i) const
 Access element an element of the array.
 
void swap (memory_array< T > &obj)
 swap the two objects memory
 
void deinit ()
 Deinitialize the memory.
 
 memory_array ()
 Default constructor.
 
 memory_array (void *ptr, size_t sz, bool init)
 Memory array constructor.
 
 ~memory_array ()
 Destructor.
 

Private Member Functions

get (mem_id i)
 Get the i element.
 

Private Attributes

T * ptr
 Internal pointer.
 
size_t sz
 number of elements
 

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T memory_array< T >::value_type

type returned by this structure

Definition at line 60 of file memory_array.hpp.

Constructor & Destructor Documentation

◆ memory_array() [1/2]

template<typename T >
memory_array< T >::memory_array ( )
inline

Default constructor.

Definition at line 171 of file memory_array.hpp.

◆ memory_array() [2/2]

template<typename T >
memory_array< T >::memory_array ( void *  ptr,
size_t  sz,
bool  init 
)
inline

Memory array constructor.

Parameters
ptrMemory pointer
szsize
initspecify if the pointer is initialized

Definition at line 182 of file memory_array.hpp.

◆ ~memory_array()

template<typename T >
memory_array< T >::~memory_array ( )
inline

Destructor.

Definition at line 192 of file memory_array.hpp.

Member Function Documentation

◆ bind_ref()

template<typename T >
template<typename Tbind >
void memory_array< T >::bind_ref ( const memory_array< Tbind > &  ref)
inline

Set from another memory array.

Parameters
theother memory_array

Definition at line 111 of file memory_array.hpp.

◆ deinit()

template<typename T >
void memory_array< T >::deinit ( )
inline

Deinitialize the memory.

Definition at line 161 of file memory_array.hpp.

◆ get()

template<typename T >
T memory_array< T >::get ( mem_id  i)
inlineprivate

Get the i element.

Parameters
ielement
Returns
the element i

Definition at line 51 of file memory_array.hpp.

◆ get_pointer()

template<typename T >
__device__ __host__ void * memory_array< T >::get_pointer ( ) const
inline

Return the pointer.

Definition at line 101 of file memory_array.hpp.

◆ initialize()

template<typename T >
void memory_array< T >::initialize ( void *  ptr,
size_t  sz,
bool  init 
)
inline

Initialize the memory array.

Parameters
ptrpointer
sznumber of elements in the array
initindicate if you have to initialize the memory
Returns
the element i

Definition at line 71 of file memory_array.hpp.

◆ operator[]() [1/2]

template<typename T >
__host__ __device__ T & memory_array< T >::operator[] ( mem_id  i)
inline

Access element an element of the array.

Parameters
ielement to access
Returns
a teference to the object

Definition at line 123 of file memory_array.hpp.

◆ operator[]() [2/2]

template<typename T >
__host__ __device__ const T & memory_array< T >::operator[] ( mem_id  i) const
inline

Access element an element of the array.

Parameters
ielement to access
Returns
a teference to the object

Definition at line 135 of file memory_array.hpp.

◆ set_pointer()

template<typename T >
void memory_array< T >::set_pointer ( void *  ptr_)
inline

Set the internal pointer to the indicated chunk of memory.

Parameters
ptr_pointer

Definition at line 95 of file memory_array.hpp.

◆ size()

template<typename T >
size_t memory_array< T >::size ( )
inline

return the size of the array

Definition at line 85 of file memory_array.hpp.

◆ swap()

template<typename T >
void memory_array< T >::swap ( memory_array< T > &  obj)
inline

swap the two objects memory

Parameters
objmemory to swap with

Definition at line 145 of file memory_array.hpp.

Field Documentation

◆ ptr

template<typename T >
T* memory_array< T >::ptr
private

Internal pointer.

Definition at line 37 of file memory_array.hpp.

◆ sz

template<typename T >
size_t memory_array< T >::sz
private

number of elements

Definition at line 42 of file memory_array.hpp.


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