OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
grid_gpu< dim, T, S, Mem > 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 = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
class grid_gpu< dim, T, S, Mem >

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

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>

Public Types

typedef int yes_i_am_grid
 it define that it is a grid
 
typedef memory_traits_inte
< typename T::type >::type 
memory_int
 Definition of the layout.
 
typedef Mem memory_conf
 Memory traits.
 
typedef encapg< dim, T, Mem > container
 Object container for T, it is the return type of get_o it return a object type trough.
 
typedef T type
 

Public Member Functions

 grid_gpu () THROW
 Default constructor.
 
void setDimensions (std::vector< size_t > &sz)
 Set the grid dimensions.
 
 grid_gpu (std::vector< size_t > &sz) THROW
 Constructor it initialize the memory and give representation.
 
const grid_sm< dim, void > & getGrid () const
 Return the internal grid information. More...
 
void setMemory ()
 Create the object that provide memory. More...
 
template<unsigned int p>
type_gpu_prop< p, memory_int >
::type::reference 
get (grid_key_d< dim, p > &v1)
 
template<unsigned int p>
type_gpu_prop< p, memory_int >
::type::reference 
get (grid_key_dx< dim > &v1)
 
encapg< dim, T, Mem > get_o (grid_key_dx< dim > &v1)
 Get the of the selected element as a boost::fusion::vector. More...
 
const encapg< dim, T, Mem > get_o (grid_key_dx< dim > &v1) const
 Get the of the selected element as a boost::fusion::vector. More...
 
size_t size ()
 
void set_memory (memory &mem)
 
grid_key_dx_iterator< dim > getIterator ()
 Return a grid iterator. More...
 
grid_key_dx_iterator_sub< dim > getSubIterator (grid_key_dx< dim > &start, grid_key_dx< dim > &stop)
 Return a sub-grid iterator. More...
 
void swap (grid_gpu< dim, T, S, Mem > &obj)
 Swap the memory of another grid. More...
 

Private Types

typedef grid_key_dx< dim > access_key
 Access the key.
 

Private Attributes

bool is_mem_init = false
 
grid_sm< dim, void > g1
 It store all the information regarding the grid.
 
Mem data_
 

Member Function Documentation

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
encapg<dim,T,Mem> grid_gpu< dim, T, S, Mem >::get_o ( grid_key_dx< dim > &  v1)
inline

Get the of the selected element as a boost::fusion::vector.

Get the selected element as a boost::fusion::vector

Parameters
v1grid_key that identify the element in the grid

Definition at line 123 of file grid_gpu.hpp.

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
const encapg<dim,T,Mem> grid_gpu< dim, T, S, Mem >::get_o ( grid_key_dx< dim > &  v1) const
inline

Get the of the selected element as a boost::fusion::vector.

Get the selected element as a boost::fusion::vector

Parameters
v1grid_key that identify the element in the grid

Definition at line 135 of file grid_gpu.hpp.

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
const grid_sm<dim,void>& grid_gpu< dim, T, S, Mem >::getGrid ( ) const
inline

Return the internal grid information.

Returns
the internal grid information

Definition at line 84 of file grid_gpu.hpp.

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
grid_key_dx_iterator<dim> grid_gpu< dim, T, S, Mem >::getIterator ( )
inline

Return a grid iterator.

Return a grid iterator, to iterate through the grid

Definition at line 159 of file grid_gpu.hpp.

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
grid_key_dx_iterator_sub<dim> grid_gpu< dim, T, S, Mem >::getSubIterator ( grid_key_dx< dim > &  start,
grid_key_dx< dim > &  stop 
)
inline

Return a sub-grid iterator.

Return a sub-grid iterator, to iterate through the grid

Definition at line 171 of file grid_gpu.hpp.

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
void grid_gpu< dim, T, S, Mem >::set_memory ( memory &  mem)
inline

this function set the memory interface if required this operation is required when we define a void memory allocator

Definition at line 148 of file grid_gpu.hpp.

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
void grid_gpu< dim, T, S, Mem >::setMemory ( )
inline

Create the object that provide memory.

Template Parameters
Smemory object type

Create an allocate object

for each element in the vector allocate the buffer

Definition at line 95 of file grid_gpu.hpp.

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
void grid_gpu< dim, T, S, Mem >::swap ( grid_gpu< dim, T, S, Mem > &  obj)
inline

Swap the memory of another grid.

Swap the memory of another grid

Parameters
objMemory to swap with

Definition at line 183 of file grid_gpu.hpp.

Field Documentation

template<unsigned int dim, typename T, typename S = CudaMemory, typename Mem = typename memory_traits_inte< typename T::type >::type>
Mem grid_gpu< dim, T, S, Mem >::data_
private

This is the interface to allocate,resize ... memory and give also a representation to the allocated memory

Definition at line 41 of file grid_gpu.hpp.


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