OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
grid_cpu< dim, T, S, typename memory_traits_inte< T >::type > Class Template Reference

This is an N-dimensional grid or an N-dimensional array with memory_traits_inte layout. More...

Detailed Description

template<unsigned int dim, typename T, typename S>
class grid_cpu< dim, T, S, typename memory_traits_inte< T >::type >

This is an N-dimensional grid or an N-dimensional array with memory_traits_inte layout.

it is basically an N-dimensional Cartesian grid

Template Parameters
dimDimensionality of the grid
Ttype of object the grid store
Memmemory layout

Definition and allocation of a 3D grid on GPU memory

c3.setMemory();

Access a grid c3 of size sz on each direction

typedef Point_test<float> P;
timer t;
t.start();
for (size_t i = 0 ; i < sz ; i++)
{
for (size_t j = 0 ; j < sz ; j++)
{
for (size_t k = 0 ; k < sz ; k++)
{
kk.set(i,j,k);
c3.template get<P::x>(kk) = 1.1f;
c3.template get<P::y>(kk) = 1.2f;
c3.template get<P::z>(kk) = 1.3f;
c3.template get<P::s>(kk) = 1.0f;
c3.template get<P::v>(kk)[0] = 1.0f;
c3.template get<P::v>(kk)[1] = 2.0f;
c3.template get<P::v>(kk)[2] = 3.0f;
c3.template get<P::t>(kk)[0][0] = 1.0f;
c3.template get<P::t>(kk)[0][1] = 2.0f;
c3.template get<P::t>(kk)[0][2] = 3.0f;
c3.template get<P::t>(kk)[1][0] = 4.0f;
c3.template get<P::t>(kk)[1][1] = 5.0f;
c3.template get<P::t>(kk)[1][2] = 6.0f;
c3.template get<P::t>(kk)[2][0] = 7.0f;
c3.template get<P::t>(kk)[2][1] = 8.0f;
c3.template get<P::t>(kk)[2][2] = 9.0f;
}
}
}

Access to an N-dimensional grid with an iterator

typedef Point_test<float> P;
grid_key_dx_iterator<dim> key_it = c3.getIterator();
while (key_it.isNext())
{
grid_key_dx<dim> kk = key_it.get();
c3.template get<P::x>(kk) = 1.1f;
c3.template get<P::y>(kk) = 1.2f;
c3.template get<P::z>(kk) = 1.3f;
c3.template get<P::s>(kk) = 1.0f;
c3.template get<P::v>(kk)[0] = 1.0f;
c3.template get<P::v>(kk)[1] = 2.0f;
c3.template get<P::v>(kk)[2] = 3.0f;
c3.template get<P::t>(kk)[0][0] = 1.0f;
c3.template get<P::t>(kk)[0][1] = 2.0f;
c3.template get<P::t>(kk)[0][2] = 3.0f;
c3.template get<P::t>(kk)[1][0] = 4.0f;
c3.template get<P::t>(kk)[1][1] = 5.0f;
c3.template get<P::t>(kk)[1][2] = 6.0f;
c3.template get<P::t>(kk)[2][0] = 7.0f;
c3.template get<P::t>(kk)[2][1] = 8.0f;
c3.template get<P::t>(kk)[2][2] = 9.0f;
++key_it;
}

Definition at line 28 of file grid_gpu.hpp.

#include <grid_gpu.hpp>

+ Inheritance diagram for grid_cpu< dim, T, S, typename memory_traits_inte< T >::type >:

Public Types

typedef grid_base_impl< dim, T,
S, typename memory_traits_inte
< T >::type,
memory_traits_inte >
::container 
container
 Object container for T, it is the return type of get_o it return a object type trough.
 
- Public Types inherited from grid_base_impl< dim, T, S, memory_traits_inte< T >::type, memory_traits_inte >
typedef memory_traits_inte< T >
::type 
layout_type
 memory layout
 
typedef grid_key_dx< dim > access_key
 Access key.
 
typedef T::type T_type
 boost::vector that describe the data type
 
typedef int yes_i_am_grid
 it define that it is a grid
 
typedef memory_traits_lin
< typename T::type >::type 
memory_lin
 Definition of the layout.
 
typedef encapc< dim, T, layoutcontainer
 Object container for T, it is the return type of get_o it return a object type trough.
 
typedef T value_type
 The object type the grid is storing.
 

Public Member Functions

 grid_cpu () THROW
 Default constructor.
 
 grid_cpu (const grid_cpu &g) THROW
 create a grid from another grid More...
 
 grid_cpu (const size_t &sz) THROW
 create a grid of size sz on each direction More...
 
 grid_cpu (const size_t(&sz)[dim]) THROW
 Constructor allocate memory and give them a representation.
 
- Public Member Functions inherited from grid_base_impl< dim, T, S, memory_traits_inte< T >::type, memory_traits_inte >
void pack (ExtPreAlloc< S > &mem, Pack_stat &sts) const
 pack a grid selecting the properties to pack More...
 
void pack (ExtPreAlloc< S > &mem, grid_key_dx_iterator_sub< dims > &sub_it, Pack_stat &sts)
 Pack the object into the memory given an iterator. More...
 
void packRequest (size_t &req) const
 Insert an allocation request into the vector. More...
 
void packRequest (grid_key_dx_iterator_sub< dims > &sub, size_t &req)
 Insert an allocation request. More...
 
void unpack (ExtPreAlloc< S > &mem, Unpack_stat &ps)
 unpack a grid More...
 
void unpack (ExtPreAlloc< S > &mem, grid_key_dx_iterator_sub< dims > &sub_it, Unpack_stat &ps)
 unpack the sub-grid object More...
 
 grid_base_impl () THROW
 Default constructor.
 
 grid_base_impl (const grid_base_impl &g) THROW
 create a grid from another grid More...
 
 grid_base_impl (const size_t &sz) THROW
 create a grid of size sz on each direction More...
 
 grid_base_impl (const size_t(&sz)[dim]) THROW
 Constructor. More...
 
 ~grid_base_impl () THROW
 Destructor.
 
grid_base_impl< dim, T, S,
layout, memory_traits_inte > & 
operator= (const grid_base_impl< dim, T, S, layout, memory_traits_inte > &g)
 It copy a grid. More...
 
grid_base_impl< dim, T, S,
layout, memory_traits_inte > & 
operator= (grid_base_impl< dim, T, S, layout, memory_traits_inte > &&g)
 It copy a grid. More...
 
bool operator== (const grid_base_impl< dim, T, S, layout, memory_traits_inte > &g)
 Compare two grids. More...
 
grid_base_impl< dim, T, S,
layout, memory_traits_inte
duplicate () const THROW
 create a duplicated version of the grid More...
 
const grid_sm< dim, T > & getGrid () const
 Return the internal grid information. More...
 
void setMemory ()
 Create the object that provide memory. More...
 
void setMemory (S &m)
 Get the object that provide memory. More...
 
void * getPointer ()
 Return a plain pointer to the internal data. More...
 
const void * getPointer () const
 Return a plain pointer to the internal data. More...
 
r_type get (const grid_key_dx< dim > &v1)
 Get the reference of the selected element. More...
 
const r_type get (const grid_key_dx< dim > &v1) const
 Get the const reference of the selected element. More...
 
r_type get (const size_t lin_id)
 Get the reference of the selected element. More...
 
const r_type get (size_t lin_id) const
 Get the const reference of the selected element. More...
 
encapc< dim, T, layoutget_o (const grid_key_dx< dim > &v1)
 Get the of the selected element as a boost::fusion::vector. More...
 
const encapc< dim, T, layoutget_o (const grid_key_dx< dim > &v1) const
 Get the of the selected element as a boost::fusion::vector. More...
 
encapc< dim, T, layoutget_o (size_t v1)
 Get the of the selected element as a boost::fusion::vector. More...
 
const encapc< dim, T, layoutget_o (size_t v1) const
 Get the of the selected element as a boost::fusion::vector. More...
 
void fill (unsigned char fl)
 Fill the memory with the selected byte. More...
 
void resize (const size_t(&sz)[dim])
 Resize the space. More...
 
void remove (size_t key)
 Remove one element valid only on 1D. More...
 
void swap (grid_base_impl< dim, T, S, layout, memory_traits_inte > &grid)
 It move the allocated object from one grid to another. More...
 
void swap (grid_base_impl< dim, T, S, layout, memory_traits_inte > &&grid)
 It move the allocated object from one grid to another. More...
 
void set (grid_key_dx< dim > dx, const encapc< 1, T, Memory > &obj)
 set an element of the grid More...
 
void set (grid_key_dx< dim > dx, const T &obj)
 set an element of the grid More...
 
void set (const grid_key_dx< dim > &key1, const grid_base_impl< dim, T, S, layout, memory_traits_inte > &g, const grid_key_dx< dim > &key2)
 Set an element of the grid from another element of another grid. More...
 
void set (const size_t key1, const grid_base_impl< dim, T, S, layout, memory_traits_inte > &g, const size_t key2)
 Set an element of the grid from another element of another grid. More...
 
void set (const grid_key_dx< dim > &key1, const grid_base_impl< dim, T, Mem, layout, memory_traits_inte > &g, const grid_key_dx< dim > &key2)
 Set an element of the grid from another element of another grid. More...
 
size_t size () const
 return the size of the grid More...
 
grid_key_dx_iterator_sub< dim > getSubIterator (grid_key_dx< dim > &start, grid_key_dx< dim > &stop) const
 Return a sub-grid iterator. More...
 
grid_key_dx_iterator_sub< dim > getSubIterator (size_t m)
 Return a sub-grid iterator. More...
 
grid_key_dx_iterator< dim > getIterator () const
 Return a grid iterator. More...
 
grid_key_dx_iterator_sub< dim > getIterator (const grid_key_dx< dim > &start, const grid_key_dx< dim > &stop) const
 Return a grid iterator over all points included between start and stop point. More...
 
grid_key_dx_iterator< dim,
stencil_offset_compute< dim,
Np > > 
getIteratorStencil (const grid_key_dx< dim >(&stencil_pnt)[Np]) const
 Return a grid iterator. More...
 
long int who ()
 It return the id of structure in the allocation list. More...
 

Private Types

typedef memory_traits_inte< T >
::type 
layout
 grid layout
 

Additional Inherited Members

- Static Public Member Functions inherited from grid_base_impl< dim, T, S, memory_traits_inte< T >::type, memory_traits_inte >
static bool pack ()
 
static bool packRequest ()
 
static bool packMem ()
 
static size_t packMem (size_t n, size_t e)
 Calculate the memory size required to pack n elements. More...
 
- Static Public Attributes inherited from grid_base_impl< dim, T, S, memory_traits_inte< T >::type, memory_traits_inte >
static constexpr unsigned int dims
 expose the dimansionality as a static const
 
- Protected Attributes inherited from grid_base_impl< dim, T, S, memory_traits_inte< T >::type, memory_traits_inte >
layout data_
 Memory layout specification + memory chunk pointer.
 
grid_sm< dim, T > g1
 This is a structure that store all information related to the grid and how indexes are linearized.
 

Constructor & Destructor Documentation

template<unsigned int dim, typename T , typename S >
grid_cpu< dim, T, S, typename memory_traits_inte< T >::type >::grid_cpu ( const grid_cpu< dim, T, S, typename memory_traits_inte< T >::type > &  g)
inline

create a grid from another grid

Parameters
gthe grid to copy

Definition at line 50 of file grid_gpu.hpp.

template<unsigned int dim, typename T , typename S >
grid_cpu< dim, T, S, typename memory_traits_inte< T >::type >::grid_cpu ( const size_t &  sz)
inline

create a grid of size sz on each direction

Parameters
szgrid size in each direction

Definition at line 60 of file grid_gpu.hpp.


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