Commit 0cf7d6e3 authored by incardon's avatar incardon

Returning to taurus phase 1

parent e680968c
......@@ -77,15 +77,15 @@ then
make
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=1 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 16 src/vcluster"
salloc --nodes=1 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy bash -c "ulimit -s unlimited && mpirun -np 16 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=2 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=haswell bach -c "ulimit -s unlimited && mpirun -np 32 src/vcluster"
salloc --nodes=2 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy bach -c "ulimit -s unlimited && mpirun -np 32 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=4 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 64 src/vcluster"
salloc --nodes=4 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy bash -c "ulimit -s unlimited && mpirun -np 64 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=8 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 128 src/vcluster"
salloc --nodes=8 --ntasks-per-node=16 --time=00:05:00 --mem-per-cpu=1900 --partition=sandy bash -c "ulimit -s unlimited && mpirun -np 128 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
salloc --nodes=16 --ntasks-per-node=16 --time=00:5:00 --mem-per-cpu=1900 --partition=haswell bash -c "ulimit -s unlimited && mpirun -np 256 src/vcluster"
salloc --nodes=16 --ntasks-per-node=16 --time=00:5:00 --mem-per-cpu=1900 --partition=sandy bash -c "ulimit -s unlimited && mpirun -np 256 src/vcluster"
if [ $? -ne 0 ]; then exit 1 ; fi
else
......
......@@ -4,14 +4,32 @@
#include <mpi.h>
/*! \brief Set of wrapping classing for MPI_Iallreduce
/*! \brief Set of wrapping classing for MPI_Irecv
*
* The purpose of these classes is to correctly choose the right call based on the type we want to reduce
* The purpose of these classes is to correctly choose the right call based on the type we want to receive
*
*/
/*! \brief General recv for general buffer
*
* \param proc processor from which to receive
* \param tag
* \param buf buffer where to store the data
* \param sz size to receive
* \param req MPI request
*
*/
class MPI_IrecvWB
{
public:
static inline void recv(size_t proc , size_t tag ,void * buf, size_t sz, MPI_Request & req)
{
MPI_SAFE_CALL(MPI_Irecv(buf,sz,MPI_BYTE, proc, tag , MPI_COMM_WORLD,&req));
}
};
/*! \brief General send
/*! \brief General recv for vector of
*
* \tparam any type
*
......
......@@ -4,14 +4,25 @@
#include <mpi.h>
/*! \brief Set of wrapping classing for MPI_Iallreduce
/*! \brief Set of wrapping classing for MPI_Isend
*
* The purpose of these classes is to correctly choose the right call based on the type we want to reduce
* The purpose of these classes is to correctly choose the right call based on the type we want to send
*
*/
/*! \brief General send for a buffer
*
*/
class MPI_IsendWB
{
public:
static inline void send(size_t proc , size_t tag ,void * buf, size_t sz, MPI_Request & req)
{
MPI_Isend(buf, sz,MPI_BYTE, proc, tag , MPI_COMM_WORLD,&req);
}
};
/*! \brief General send
/*! \brief General send for a vector of any type
*
* \tparam any type
*
......
# Makefile.in generated by automake 1.13.4 from Makefile.am.
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# src/Makefile. Generated from Makefile.in by configure.
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
......@@ -97,7 +97,8 @@ CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_vcluster_OBJECTS = vcluster-main.$(OBJEXT) \
vcluster-VCluster.$(OBJEXT) vcluster-HeapMemory.$(OBJEXT)
vcluster-VCluster.$(OBJEXT) vcluster-HeapMemory.$(OBJEXT) \
vcluster-PtrMemory.$(OBJEXT)
vcluster_OBJECTS = $(am_vcluster_OBJECTS)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
......@@ -164,12 +165,12 @@ am__define_uniq_tagged_files = \
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_vcluster/missing aclocal-1.13
ACLOCAL = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_vcluster/missing aclocal-1.14
AMTAR = $${TAR-tar}
AM_DEFAULT_VERBOSITY = 1
AUTOCONF = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_vcluster/missing autoconf
AUTOHEADER = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_vcluster/missing autoheader
AUTOMAKE = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_vcluster/missing automake-1.13
AUTOMAKE = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_vcluster/missing automake-1.14
AWK = gawk
BOOST_CPPFLAGS = -pthread -I/usr/include
BOOST_DATE_TIME_LIB = -lboost_date_time
......@@ -191,7 +192,7 @@ CUDA_CFLAGS = -I -I -I/usr/local/cuda/include
CUDA_LIBS = -L -L -L/usr/local/cuda/lib64 -lcuda -lcudart
CXX = mpic++
CXXDEPMODE = depmode=gcc3
CXXFLAGS = --std=c++11 -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-unused-parameter -Wall -O3 -g3 -funroll-loops
CXXFLAGS = --std=c++11 -march=native -mtune=native -Wno-unused-local-typedefs -Wextra -Wno-unused-parameter -g3 -Wall -O0
CYGPATH_W = echo
DEFAULT_LIB = -lrt
DEFS = -DHAVE_CONFIG_H
......@@ -213,7 +214,7 @@ LTLIBOBJS =
MAKEINFO = ${SHELL} /home/i-bird/Desktop/MOSAIC/OpenFPM_project/OpenFPM_vcluster/missing makeinfo
MKDIR_P = /usr/bin/mkdir -p
NVCC = /usr/local/cuda/bin/nvcc
NVCCFLAGS = -O3
NVCCFLAGS = -g -O0
NVCC_EXIST = yes
OBJEXT = o
PACKAGE = full-package-name
......@@ -284,7 +285,7 @@ top_build_prefix = ../
top_builddir = ..
top_srcdir = ..
LINKLIBS = $(DEFAULT_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS)
vcluster_SOURCES = main.cpp VCluster.cpp ../../OpenFPM_devices/src/memory/HeapMemory.cpp
vcluster_SOURCES = main.cpp VCluster.cpp ../../OpenFPM_devices/src/memory/HeapMemory.cpp ../../OpenFPM_devices/src/memory/PtrMemory.cpp
vcluster_CXXFLAGS = $(INCLUDES_PATH) $(BOOST_CPPFLAGS)
vcluster_CFLAGS = $(CUDA_CFLAGS)
vcluster_LDADD = $(LINKLIBS)
......@@ -376,6 +377,7 @@ distclean-compile:
-rm -f *.tab.c
include ./$(DEPDIR)/vcluster-HeapMemory.Po
include ./$(DEPDIR)/vcluster-PtrMemory.Po
include ./$(DEPDIR)/vcluster-VCluster.Po
include ./$(DEPDIR)/vcluster-main.Po
......@@ -435,6 +437,20 @@ vcluster-HeapMemory.obj: ../../OpenFPM_devices/src/memory/HeapMemory.cpp
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcluster_CXXFLAGS) $(CXXFLAGS) -c -o vcluster-HeapMemory.obj `if test -f '../../OpenFPM_devices/src/memory/HeapMemory.cpp'; then $(CYGPATH_W) '../../OpenFPM_devices/src/memory/HeapMemory.cpp'; else $(CYGPATH_W) '$(srcdir)/../../OpenFPM_devices/src/memory/HeapMemory.cpp'; fi`
vcluster-PtrMemory.o: ../../OpenFPM_devices/src/memory/PtrMemory.cpp
$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcluster_CXXFLAGS) $(CXXFLAGS) -MT vcluster-PtrMemory.o -MD -MP -MF $(DEPDIR)/vcluster-PtrMemory.Tpo -c -o vcluster-PtrMemory.o `test -f '../../OpenFPM_devices/src/memory/PtrMemory.cpp' || echo '$(srcdir)/'`../../OpenFPM_devices/src/memory/PtrMemory.cpp
$(AM_V_at)$(am__mv) $(DEPDIR)/vcluster-PtrMemory.Tpo $(DEPDIR)/vcluster-PtrMemory.Po
# $(AM_V_CXX)source='../../OpenFPM_devices/src/memory/PtrMemory.cpp' object='vcluster-PtrMemory.o' libtool=no \
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcluster_CXXFLAGS) $(CXXFLAGS) -c -o vcluster-PtrMemory.o `test -f '../../OpenFPM_devices/src/memory/PtrMemory.cpp' || echo '$(srcdir)/'`../../OpenFPM_devices/src/memory/PtrMemory.cpp
vcluster-PtrMemory.obj: ../../OpenFPM_devices/src/memory/PtrMemory.cpp
$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcluster_CXXFLAGS) $(CXXFLAGS) -MT vcluster-PtrMemory.obj -MD -MP -MF $(DEPDIR)/vcluster-PtrMemory.Tpo -c -o vcluster-PtrMemory.obj `if test -f '../../OpenFPM_devices/src/memory/PtrMemory.cpp'; then $(CYGPATH_W) '../../OpenFPM_devices/src/memory/PtrMemory.cpp'; else $(CYGPATH_W) '$(srcdir)/../../OpenFPM_devices/src/memory/PtrMemory.cpp'; fi`
$(AM_V_at)$(am__mv) $(DEPDIR)/vcluster-PtrMemory.Tpo $(DEPDIR)/vcluster-PtrMemory.Po
# $(AM_V_CXX)source='../../OpenFPM_devices/src/memory/PtrMemory.cpp' object='vcluster-PtrMemory.obj' libtool=no \
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcluster_CXXFLAGS) $(CXXFLAGS) -c -o vcluster-PtrMemory.obj `if test -f '../../OpenFPM_devices/src/memory/PtrMemory.cpp'; then $(CYGPATH_W) '../../OpenFPM_devices/src/memory/PtrMemory.cpp'; else $(CYGPATH_W) '$(srcdir)/../../OpenFPM_devices/src/memory/PtrMemory.cpp'; fi`
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
......
......@@ -2,7 +2,7 @@
LINKLIBS = $(DEFAULT_LIB) $(PTHREAD_LIBS) $(OPT_LIBS) $(BOOST_LDFLAGS)
bin_PROGRAMS = vcluster
vcluster_SOURCES = main.cpp VCluster.cpp ../../OpenFPM_devices/src/memory/HeapMemory.cpp
vcluster_SOURCES = main.cpp VCluster.cpp ../../OpenFPM_devices/src/memory/HeapMemory.cpp ../../OpenFPM_devices/src/memory/PtrMemory.cpp
vcluster_CXXFLAGS = $(INCLUDES_PATH) $(BOOST_CPPFLAGS)
vcluster_CFLAGS = $(CUDA_CFLAGS)
vcluster_LDADD = $(LINKLIBS)
......
......@@ -9,8 +9,6 @@
//! Primitive packing
#define PACKER_PRIMITIVE 1
//! Object packing
#define PACKER_OBJECTS 2
//! Encapsulated Object packing
#define PACKER_ENCAP_OBJECTS 3
//! Vector of objects packing
......@@ -101,7 +99,7 @@ struct Pack_selector_impl
{
enum
{
value = Pack_selector_known_type_impl< T, is_grid<T>::value * 2 + is_vector<T>::value >::value
value = Pack_selector_known_type_impl< T, 4*is_encap<T>::value + is_grid<T>::value * 2 + is_vector<T>::value >::value
};
};
......
......@@ -11,17 +11,31 @@
#include "util/object_util.hpp"
#include "Grid/util.hpp"
#include "Vector/util.hpp"
#include "memory/ExtPreAlloc.hpp"
#include "util/util_debug.hpp"
#include "Pack_stat.hpp"
#include "Pack_selector.hpp"
/*! \brief Packing class
*
* This class is going to pack objects
* 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
*
* \tparam T base type
* \tparam Mem Memory type
* \tparam pack_type type of packing
* In order to unpack the information the Unpacker class can be used
*
* \see Unpacker
*
* \snippet Packer_unit_tests.hpp Pack into a message primitives objects vectors and grids
*
* \tparam T object type to pack
* \tparam Mem Memory origin HeapMemory CudaMemory ...
* \tparam Implementation of the packer (the Pack_selector choose the correct one)
*
*/
template<typename T, typename Mem, int pack_type>
template<typename T, typename Mem, int pack_type=Pack_selector<T>::value >
class Packer
{
public:
......@@ -29,7 +43,7 @@ public:
/*! \brief Error, no implementation
*
*/
void pack(ExtPreAlloc<Mem> , T & obj)
static void pack(ExtPreAlloc<Mem> , const T & obj)
{
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " packing for the type " << demangle(typeid(T).name()) << " is not implemented\n";
}
......@@ -37,18 +51,17 @@ public:
/*! \brief Error, no implementation
*
*/
size_t packRequest(std::vector<size_t> & req)
static size_t packRequest(std::vector<size_t> & req)
{
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " packing for the type " << demangle(typeid(T).name()) << " is not implemented\n";
return 0;
}
};
/*! \brief Packer class for primitives
/*! \brief Packer for primitives
*
* \tparam T base type
* \tparam Mem Memory type
* \tparam pack_type type of packing
* \tparam T object type to pack
* \tparam Mem Memory origin HeapMemory CudaMemory ...
*
*/
template<typename T, typename Mem>
......@@ -56,61 +69,132 @@ class Packer<T,Mem,PACKER_PRIMITIVE>
{
public:
/*! \brief
/*! \brief It pack any C++ primitives
*
* It pack any C++ primitives
* \param ext preallocated memory where to pack the object
* \param obj object to pack
* \param sts pack-stat info
*
*/
void pack(ExtPreAlloc<Mem> & ext, T & obj)
inline static void pack(ExtPreAlloc<Mem> & ext, const T & obj, Pack_stat & sts)
{
#ifdef DEBUG
if (ext.ref() == 0)
std::cerr << "Error : " << __FILE__ << ":" << __LINE__ << " the reference counter of mem should never be zero when packing \n";
#endif
ext.allocate(sizeof(T));
*(T *)ext.getPointer() = obj;
// update statistic
sts.incReq();
}
/*! \brief
/*! \brief It add a request to pack a C++ primitive
*
* \param req requests vector
*
*/
size_t packRequest(std::vector<size_t> & req)
static void packRequest(std::vector<size_t> & req)
{
return req.push_back(sizeof(T));
req.push_back(sizeof(T));
}
};
/*! \brief Packer for objects, with impossibility to check for internal pointers
*
* \tparam T object type to pack
* \tparam Mem Memory origin HeapMemory CudaMemory ...
*
*/
template<typename T, typename Mem>
class Packer<T,Mem,PACKER_OBJECTS_WITH_WARNING_POINTERS>
{
public:
/*! \brief It pack an object
*
* \param ext preallocated memory where to pack the objects
* \param obj object to pack
* \param sts pack-stat info
*
*/
static void pack(ExtPreAlloc<Mem> & ext, T & obj, Pack_stat & sts)
{
#ifdef DEBUG
if (ext.ref() == 0)
std::cerr << "Error : " << __FILE__ << ":" << __LINE__ << " the reference counter of mem should never be zero when packing \n";
std::cerr << "Warning: " << __FILE__ << ":" << __LINE__ << " impossible to check the type " << demangle(typeid(T).name()) << " please consider to add a static method \"void noPointers()\" \n" ;
#endif
ext.allocate(sizeof(T));
memcpy((T *)ext.getPointer(),&obj,sizeof(T));
// update statistic
sts.incReq();
}
/*! \brief it add a request to pack an object
*
* \param req requests vector
*
*/
static void packRequest(std::vector<size_t> & req)
{
req.push_back(sizeof(T));
}
};
/*! \brief Packer class for objects
*
* \tparam T Type of Memory
* \tparam T object type to pack
* \tparam Mem Memory origin HeapMemory CudaMemory ...
*
*/
template<typename T, typename Mem>
class Packer<T,Mem,PACKER_OBJECTS>
class Packer<T,Mem,PACKER_OBJECTS_WITH_POINTER_CHECK>
{
public:
/*! \brief
/*! \brief It pack any object checking that the object does not have pointers inside
*
* \param ext preallocated memory where to pack the objects
* \param obj object to pack
* \param sts pack-stat info
*
*/
void pack(ExtPreAlloc<Mem> & ext, T & obj)
static void pack(ExtPreAlloc<Mem> & ext, T & obj, Pack_stat & sts)
{
#ifdef DEBUG
if (ext.ref() == 0)
std::cerr << "Error : " << __FILE__ << ":" << __LINE__ << " the reference counter of mem should never be zero when packing \n";
if (obj.noPointers() == false)
std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " the type " << demangle(typeid(T).name()) << " has pointers inside, sending pointers values has no sense\n";
#endif
ext.allocate(sizeof(T));
memcpy((T *)ext.getPointer(),&obj,sizeof(T));
// Update statistic
sts.incReq();
}
/*! \brief
/*! \brief it add a request to pack an object
*
* \param req requests vector
*
*/
size_t packRequest(std::vector<size_t> & req)
static void packRequest(std::vector<size_t> & req)
{
return req.push_back(sizeof(T));
req.push_back(sizeof(T));
}
};
/*! \brief Packer class for vectors
*
* \tparam T Type of Memory
* \tparam T vector type to pack
* \tparam Mem Memory origin HeapMemory CudaMemory ...
*
*/
template<typename T, typename Mem>
......@@ -118,61 +202,110 @@ class Packer<T,Mem,PACKER_VECTOR>
{
public:
/*! \brief pack a vector of objects selecting the properties to pack
/*! \brief pack a vector selecting the properties to pack
*
* \param mem preallocated memory where to pack the vector
* \param obj object to pack
* \param sts pack-stat info
*
*/
template<unsigned int ... prp> void pack(ExtPreAlloc<Mem> & mem, T & obj)
template<int ... prp> static void pack(ExtPreAlloc<Mem> & mem, T & obj, Pack_stat & sts)
{
#ifdef DEBUG
if (mem.ref() == 0)
std::cerr << "Error : " << __FILE__ << ":" << __LINE__ << " the reference counter of mem should never be zero when packing \n";
#endif
// if no properties should be packed return
if (sizeof...(prp) == 0)
return;
// Sending property object
typedef object<typename object_creator<typename T::value_type::type,prp...>::type> prp_object;
typedef openfpm::vector<prp_object,openfpm::device_cpu<prp_object>,ExtPreAlloc<Mem>,openfpm::grow_policy_identity> dtype;
// Create an object over the preallocated memory (No allocation is produced)
dtype dest;
dest.setMemory(mem);
dest.resize(obj.size());
auto obj_it = obj.getIterator();
while (obj_it.isNext())
{
// copy all the object in the send buffer
typedef encapc<1,typename T::value_type,typename T::memory_conf > encap_src;
// destination object type
typedef encapc<1,prp_object,typename dtype::memory_conf > encap_dst;
// Copy only the selected properties
object_si_d<encap_src,encap_dst,ENCAP,prp...>(obj.get(obj_it.get()),dest.get(obj_it.get()));
++obj_it;
}
// Update statistic
sts.incReq();
}
/*! \brief Insert an allocation request into the vector
*
* \param vector of request
* \param obj vector object to pack
* \param requests vector
*
*/
template<unsigned int ... prp> void packRequest(T & obj, std::vector<size_t> & v)
template<int ... prp> static void packRequest(T & obj, std::vector<size_t> & v)
{
typedef object<typename object_creator<typename T::value_type::type,prp...>::type> prp_object;
// Calculate the required memory for packing
size_t alloc_ele = openfpm::vector<prp>::calculateMem(obj.size(),0);
size_t alloc_ele = openfpm::vector<prp_object>::calculateMem(obj.size(),0);
v.push_back(alloc_ele);
}
};
/*! \brief Packer class for grids
/*! \brief Packer for grids and sub-grids
*
* \tparam T Type of Memory
* \tparam T grid type to pack
* \tparam Mem Memory origin HeapMemory CudaMemory ...
*
*/
template<typename T, typename Mem>
class Packer<T,Mem,PACKER_GRID>
{
/*! \brief Pack the object into the memory given an iterator
/*! \brief Pack an N-dimensional grid into a vector like structure B given an iterator of the grid
*
* \tparam it Type of iterator
* \tparam it type of iterator of the grid-structure
* \tparam dtype type of the structure B
* \tparam dim Dimensionality of the grid
* \tparam properties to pack
*
* \param it Grid iterator
* \param obj object to pack
* \param dest where to pack
*
*/
template <typename it,unsigned int dim, unsigned int ... prp> static void pack_with_iterator(ExtPreAlloc<Mem> & mem, it & sub_it, T & obj)
template <typename it, typename dtype, int ... prp> static void pack_with_iterator(it & sub_it, T & obj, dtype & dest)
{
// Sending property object
typedef object<typename object_creator<typename T::type,prp...>::type> prp_object;
typedef object<typename object_creator<typename T::type::type,prp...>::type> prp_object;
size_t id = 0;
// Packing the information
while (sub_it.isNext())
{
// copy all the object in the send buffer
typedef encapc<dim,T,typename grid_cpu<dim,T>::memory_conf > encap_src;
typedef encapc<T::dims,typename T::type,typename T::memory_conf > encap_src;
// destination object type
typedef encapc<1,prp_object,typename grid_cpu<dim,prp_object>::memory_conf > encap_dst;
typedef encapc<1,prp_object,typename dtype::memory_conf > encap_dst;
// Copy only the selected properties
object_si_d<encap_src,encap_dst,ENCAP,prp...>(obj.get_o(sub_it.get()),dest.get(sub_it.getLoc()));
object_si_d<encap_src,encap_dst,ENCAP,prp...>(obj.get_o(sub_it.get()),dest.get(id));
++id;
++sub_it;
}
}
......@@ -184,69 +317,104 @@ public:
* \tparam dim Dimensionality of the grid
* \tparam prp properties to pack
*
* \param mem Memory type
* \param mem preallocated memory where to pack the objects
* \param obj object to pack
* \param sts pack statistic
*
*/
template<unsigned int dim, unsigned int ... prp> void pack(ExtPreAlloc<Mem> & mem, T & obj)
template<int ... prp> static void pack(ExtPreAlloc<Mem> & mem, T & obj, Pack_stat & sts)
{
// Calculate the required memory for packing
size_t alloc_ele = openfpm::vector<prp>::calculateMem(obj.size(),0);
// Allocate memory
mem.allocate(alloc_ele);
#ifdef DEBUG
if (mem.ref() == 0)
std::cerr << "Error : " << __FILE__ << ":" << __LINE__ << " the reference counter of mem should never be zero when packing \n";
#endif
// Sending property object
// Sending property object and vector
typedef object<typename object_creator<typename T::type,prp...>::type> prp_object;
typedef openfpm::vector<prp_object,openfpm::device_cpu<prp_object>,ExtPreAlloc<Mem>> dtype;
// Calculate the required memory for packing
size_t alloc_ele = dtype::calculateMem(obj.size(),0);
// Create an object over the preallocated memory (No allocation is produced)
openfpm::vector<prp_object,openfpm::device_cpu<prp_object>,ExtPreAlloc<Mem>> dest;
dtype dest;
dest.setMemory(mem);
dest.resize(obj.size());
auto it = obj.getIterator();
pack_with_iterator(mem,it,obj);
pack_with_iterator<decltype(it),dtype,prp...>(mem,it,obj,dest);
// Update statistic
sts.incReq();
}
/*! \brief Pack the object into the memory given an iterator
*
* \tparam dim Dimensionality of the grid
* \tparam prp properties to pack
*
* \param mem Memory type
* \param sub_it sub grid iterator ( or the element in the grid to pack )
* \param mem preallocated memory where to pack the objects
* \param sub_it sub grid iterator ( or the elements in the grid to pack )
* \param obj object to pack
* \param sts pack statistic
*
*/
template<unsigned int dim, unsigned int ... prp> void pack(ExtPreAlloc<Mem> & mem, grid_key_dx_iterator_sub<dim> & sub_it, T & obj)
template<int ... prp> static void pack(ExtPreAlloc<Mem> & mem, T & obj, grid_key_dx_iterator_sub<T::dims> & sub_it, Pack_stat & sts)
{
// Calculate the required memory for packing
size_t alloc_ele = openfpm::vector<prp>::calculateMem(sub_it.getVolume(),0);
// Allocate memory
mem.allocate(alloc_ele);
#ifdef DEBUG
if (mem.ref() == 0)
std::cerr << "Error : " << __FILE__ << ":" << __LINE__ << " the reference counter of mem should never be zero when packing \n";
#endif
// Sending property object
typedef object<typename object_creator<typename T::type,prp...>::type> prp_object;
typedef object<typename object_creator<typename T::type::type,prp...>::type> prp_object;
typedef openfpm::vector<prp_object,openfpm::device_cpu<prp_object>,ExtPreAlloc<Mem>,openfpm::grow_policy_identity> dtype;
// Create an object over the preallocated memory (No allocation is produced)
openfpm::vector<prp_object,openfpm::device_cpu<prp_object>,ExtPreAlloc<Mem>> dest;
dtype dest;
dest.setMemory(mem);