OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
Packer< T, Mem, pack_type > Class Template Reference

Packing class. More...

Detailed Description

template<typename T, typename Mem, int pack_type>
class Packer< T, Mem, pack_type >

Packing class.

This class pack objects primitives vectors and grids, the general usage is to create a vector of packing request (std::vector<size_t>) that contain the size of the required space needed to pack the information. Calculate the total size, allocating it on HeapMemory (for example), Create an ExtPreAlloc memory object giving the preallocated memory to it and finally Pack all the objects subsequently

In order to unpack the information the Unpacker class can be used

See also
typedef Point_test<float> pt;
// Create all the objects we want to pack
unsigned char uc = 1;
char c = 2;
short s = 3;
unsigned short us = 4;
int i = 5;
unsigned int ui = 6;
long int li = 7;
unsigned long int uli = 8;
float f = 9;
double d = 10;
openfpm::vector<Point_test<float>> v = allocate_openfpm<openfpm::vector<Point_test<float>>>(1024);
size_t sz[] = {16,16,16};
grid_key_dx_iterator_sub<3> sub(g.getGrid(),{1,2,3},{5,6,7});
// Here we start to push all the allocations required to pack all the data
//std::vector<size_t> pap_prp;
size_t size_total = 0;
size_t size_total_old = 0;
BOOST_REQUIRE_EQUAL(size_total,sizeof(unsigned char));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(char));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(short));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(unsigned short));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(int));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(unsigned int));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(long int));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(long unsigned int));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(float));
size_total_old = size_total;
BOOST_REQUIRE_EQUAL(size_total - size_total_old,sizeof(double));
size_total_old = size_total;
#ifndef SE_CLASS3
BOOST_REQUIRE_EQUAL(size_total - size_total_old,(sizeof(float)*4 + sizeof(float[3]) + sizeof(float[3][3])));
size_total_old = size_total;
#ifndef SE_CLASS3
BOOST_REQUIRE_EQUAL(size_total - size_total_old,(sizeof(float) + sizeof(float[3])) * v.size() + sizeof(v.size()));
size_total_old = size_total;
#ifndef SE_CLASS3
BOOST_REQUIRE_EQUAL(size_total - size_total_old,(sizeof(float) + sizeof(float[3])) * sub.getVolume());
// Calculate how much preallocated memory we need to pack all the objects
//size_t req = ExtPreAlloc<HeapMemory>::calculateMem(pap_prp);
// allocate the memory
HeapMemory pmem;
ExtPreAlloc<HeapMemory> & mem = *(new ExtPreAlloc<HeapMemory>(size_total,pmem));
Pack_stat sts;
// try to pack
Template Parameters
Tobject type to pack
MemMemory origin HeapMemory CudaMemory ...
Implementationof the packer (the Pack_selector choose the correct one)

Definition at line 49 of file Packer.hpp.

#include <Packer.hpp>

Static Public Member Functions

static void pack (ExtPreAlloc< Mem >, const T &obj)
 Error, no implementation. More...
static size_t packRequest (const T &obj, size_t &req)
 Error, no implementation. More...

Member Function Documentation

◆ pack()

template<typename T, typename Mem, int pack_type>
static void Packer< T, Mem, pack_type >::pack ( ExtPreAlloc< Mem >  ,
const T &  obj 

Error, no implementation.

Definition at line 56 of file Packer.hpp.

◆ packRequest()

template<typename T, typename Mem, int pack_type>
static size_t Packer< T, Mem, pack_type >::packRequest ( const T &  obj,
size_t &  req 

Error, no implementation.

Definition at line 66 of file Packer.hpp.

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