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
};
};
......
This diff is collapsed.
......@@ -8,11 +8,14 @@
#ifndef SRC_PACKER_UNIT_TESTS_HPP_
#define SRC_PACKER_UNIT_TESTS_HPP_
BOOST_AUTO_TEST_SUITE( Packer )
#include "Pack_selector.hpp"
#include "Packer.hpp"
#include "Unpacker.hpp"
#include "Grid/grid_util_test.hpp"
BOOST_AUTO_TEST_SUITE( packer_unpacker )
BOOST_AUTO_TEST_CASE ( Packer_test )
BOOST_AUTO_TEST_CASE ( packer_unpacker_test )
{
//! [Pack selector usage]
......@@ -37,28 +40,37 @@ BOOST_AUTO_TEST_CASE ( Packer_test )
val = Pack_selector<double>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_PRIMITIVE);
val = Pack_selector<Point_test<float>>::value;
BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
val = Pack_selector< openfpm::vector<Point_test<float>> >::value;
BOOST_REQUIRE_EQUAL(val,PACKER_VECTOR);
val = Pack_selector< grid_cpu<3,Point_test<float>> >::value;
BOOST_REQUIRE_EQUAL(val,PACKER_GRID);
// val = Pack_selector< encapc<3,Point_test<float>, memory_traits_lin<Point_test<float>> > >::value;
// BOOST_REQUIRE_EQUAL(val,PACKER_ENCAP_OBJECTS);
val = Pack_selector< encapc<3,Point_test<float>, memory_traits_lin<Point_test<float>> > >::value;
BOOST_REQUIRE_EQUAL(val,PACKER_ENCAP_OBJECTS);
struct test_s
{
float a;
float b;
bool noPointers() {return true;}
static bool noPointers() {return true;}
};
val = Pack_selector< test_s >::value;
// BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
BOOST_REQUIRE_EQUAL(val,PACKER_OBJECTS_WITH_POINTER_CHECK);
//! [Pack selector usage]
//! [Pack into a message primitives objects vector and grids]
{
//! [Pack into a message primitives objects vectors and grids]
typedef Point_test<float> pt;
// Create all the objects we want to pack
unsigned char uc = 1;
char c = 2;
short s = 3;
......@@ -70,16 +82,183 @@ BOOST_AUTO_TEST_CASE ( Packer_test )
float f = 9;
double d = 10;
openfpm::vector<Point_test<float>> v = allocate_openfpm(1024);
Point_test<float> p;
p.fill();
size_t sz[] = {16,16,16};
grid_cpu<3,Point_test<float>> g(sz);
g.setMemory<HeapMemory>();
fill_grid<3>(g);
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;
/* Packer<unsigned char>::packRequest(pap_prp);
Packer<char>::packRequest();
Packer<short>*/
Packer<unsigned char,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(unsigned char));
Packer<char,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(char));
Packer<short,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(short));
Packer<unsigned short,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(unsigned short));
Packer<int,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(int));
Packer<unsigned int,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(unsigned int));
Packer<long int,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(long int));
Packer<long unsigned int,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(long unsigned int));
Packer<float,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(float));
Packer<double,HeapMemory>::packRequest(pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],sizeof(double));
Packer<Point_test<float>,HeapMemory>::packRequest(pap_prp);
Packer<openfpm::vector<Point_test<float>>,HeapMemory>::packRequest<pt::x,pt::v>(v,pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],(sizeof(float) + sizeof(float[3])) * v.size());
Packer<grid_cpu<3,Point_test<float>>,HeapMemory>::packRequest<pt::x,pt::v>(g,sub,pap_prp);
BOOST_REQUIRE_EQUAL(pap_prp[pap_prp.size()-1],(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;
pmem.allocate(req);
ExtPreAlloc<HeapMemory> & mem = *(new ExtPreAlloc<HeapMemory>(pap_prp,pmem));
mem.incRef();
Pack_stat sts;
// try to pack
Packer<unsigned char,HeapMemory>::pack(mem,1,sts);
Packer<char,HeapMemory>::pack(mem,2,sts);
Packer<short,HeapMemory>::pack(mem,3,sts);
Packer<unsigned short,HeapMemory>::pack(mem,4,sts);
Packer<int,HeapMemory>::pack(mem,5,sts);
Packer<unsigned int, HeapMemory>::pack(mem,6,sts);
Packer<long int,HeapMemory>::pack(mem,7,sts);
Packer<long unsigned int,HeapMemory>::pack(mem,8,sts);
Packer<float,HeapMemory>::pack(mem,9,sts);
Packer<double,HeapMemory>::pack(mem,10,sts);
Packer<Point_test<float>,HeapMemory>::pack(mem,p,sts);
Packer<openfpm::vector<Point_test<float>>,HeapMemory>::pack<pt::x,pt::v>(mem,v,sts);
Packer<grid_cpu<3,Point_test<float>>,HeapMemory>::pack<pt::x,pt::v>(mem,g,sub,sts);
//! [Pack into a message primitives objects vectors and grids]
//! [Unpack a message into primitives objects vectors and grids]
Pack_stat ps;
unsigned char uc2;
Unpacker<unsigned char,HeapMemory>::unpack(mem,uc2,ps);
char c2;
Unpacker<char,HeapMemory>::unpack(mem,c2,ps);
short s2;
Unpacker<short,HeapMemory>::unpack(mem,s2,ps);
unsigned short us2;
Unpacker<unsigned short,HeapMemory>::unpack(mem,us2,ps);
int i2;
Unpacker<int,HeapMemory>::unpack(mem,i2,ps);
unsigned int ui2;
Unpacker<unsigned int,HeapMemory>::unpack(mem,ui2,ps);
long int li2;
Unpacker<long int,HeapMemory>::unpack(mem,li2,ps);
unsigned long int uli2;
Unpacker<unsigned long int,HeapMemory>::unpack(mem,uli2,ps);
float f2;
Unpacker<float,HeapMemory>::unpack(mem,f2,ps);
double d2;
Unpacker<double,HeapMemory>::unpack(mem,d2,ps);
// Unpack the point and check
Point_test<float> p_test;
Unpacker<Point_test<float>,HeapMemory>::unpack(mem,p_test,ps);
// Unpack the vector and check
openfpm::vector<Point_test<float>> v_test;
v_test.resize(v.size());
Unpacker<openfpm::vector<Point_test<float>>,HeapMemory>::unpack<pt::x,pt::v>(mem,v_test,ps);
//! [Unpack a message into primitives objects vectors and grids]
BOOST_REQUIRE_EQUAL(uc2,uc);
BOOST_REQUIRE_EQUAL(c2,c);
BOOST_REQUIRE_EQUAL(s2,s);
BOOST_REQUIRE_EQUAL(us2,us);
BOOST_REQUIRE_EQUAL(i2,i);
BOOST_REQUIRE_EQUAL(ui2,ui);
BOOST_REQUIRE_EQUAL(li2,li);
BOOST_REQUIRE_EQUAL(uli2,uli);
BOOST_REQUIRE_EQUAL(f2,f);
BOOST_REQUIRE_EQUAL(d2,d);
bool val = (p_test == p);
BOOST_REQUIRE_EQUAL(true,val);
auto it = v_test.getIterator();
while (it.isNext())
{
float f1 = v_test.template get<pt::x>(it.get());
float f2 = v.template get<pt::x>(it.get());
BOOST_REQUIRE_EQUAL(f1,f2);
for (size_t i = 0 ; i < 3 ; i++)
{
f1 = v_test.template get<pt::v>(it.get())[i];
f2 = v.template get<pt::v>(it.get())[i];
BOOST_REQUIRE_EQUAL(f1,f2);
}
++it;
}
// Unpack the grid and check
size_t sz2[] = {16,16,16};
grid_cpu<3,Point_test<float>> g_test(sz2);
g_test.setMemory<HeapMemory>();
grid_key_dx_iterator_sub<3> sub2(g_test.getGrid(),{1,2,3},{5,6,7});
Unpacker<grid_cpu<3,Point_test<float>>,HeapMemory>::unpack<pt::x,pt::v>(mem,sub2,g_test,ps);
// Check the unpacked grid
sub2.reset();
while (sub2.isNext())
{
float f1 = g_test.template get<pt::x>(sub2.get());
float f2 = g.template get<pt::x>(sub2.get());
BOOST_REQUIRE_EQUAL(f1,f2);
for (size_t i = 0 ; i < 3 ; i++)
{
f1 = g_test.template get<pt::v>(sub2.get())[i];
f2 = g.template get<pt::v>(sub2.get())[i];
BOOST_REQUIRE_EQUAL(f1,f2);
}
++sub2;
}
// destroy the packed memory
mem.decRef();
delete &mem;
// try to pack all the primitives
//! [Unpack the object]
//! [Pack into a message primitives objects vector and grids]
}
}
BOOST_AUTO_TEST_SUITE_END()
......
......@@ -216,7 +216,7 @@ public:
{
case PNP::UNKNOWN:
{
std::cerr << "Warning: " << __FILE__ << ":" << __LINE__ << " impossible to check the type " << demangle(typeid(T).name()) << " please consider to add a static method \"void noPointers()\" \n" ;
std::cerr << "Warning: " << __FILE__ << ":" << __LINE__ << " impossible to check the type " << demangle(typeid(T).name()) << " please consider to add a static method \"static bool noPointers()\" \n" ;
break;
}
case PNP::POINTERS:
......@@ -722,7 +722,38 @@ public:
* in case you want to send data without knowledge from the other side
* consider to use sendRecvMultipleMessages
*
* \warning operation are async execute must be called to ensure they are executed
* \warning operation is asynchronous execute must be called to ensure they are executed
*
* \see sendRecvMultipleMessages
*
* \param proc processor id
* \param tag id
* \param mem buffer with the data to send
* \param sz size
*
* \return true if succeed false otherwise
*
*/
bool send(size_t proc, size_t tag, void * mem, size_t sz)
{
// send over MPI
// Create one request
req.add();
// send
MPI_IsendWB::send(proc,SEND_RECV_BASE + tag,mem,sz,req.last());
return true;
}
/*! \brief Send data to a processor
*
* \warning In order to avoid deadlock every send must be coupled with a recv
* in case you want to send data without knowledge from the other side
* consider to use sendRecvMultipleMessages
*
* \warning operation is asynchronous execute must be called to ensure they are executed
*
* \see sendRecvMultipleMessages
*
......@@ -756,13 +787,44 @@ public:
* in case you want to send data without knowledge from the other side
* consider to use sendRecvMultipleMessages
*
* \warning operation are async execute must be called to ensure they are executed
* \warning operation is asynchronous execute must be called to ensure they are executed
*
* \see sendRecvMultipleMessages
*
* \param proc processor id
* \param tag id
* \param v buffer to send
* \param sz size of the buffer
*
* \return true if succeed false otherwise
*
*/
bool recv(size_t proc, size_t tag, void * v, size_t sz)
{
// recv over MPI
// Create one request
req.add();
// receive
MPI_IrecvWB::recv(proc,SEND_RECV_BASE + tag,v,sz,req.last());
return true;
}
/*! \brief Recv data from a processor
*
* \warning In order to avoid deadlock every recv must be coupled with a send
* in case you want to send data without knowledge from the other side
* consider to use sendRecvMultipleMessages
*
* \warning operation is asynchronous execute must be called to ensure they are executed
*
* \see sendRecvMultipleMessages
*
* \param proc processor id
* \param tag id
* \param v vector to send
*
* \return true if succeed false otherwise
*
......
......@@ -489,6 +489,9 @@ template<typename T> void test_send_recv_primitives(size_t n, Vcluster & vcl)
{
openfpm::vector<T> v_send = allocate_openfpm_primitive<T>(n,vcl.getProcessUnitID());
{
//! [ Send and receive vectors data ]
// Send to 8 processors
for (size_t i = 0 ; i < 8 ; i++)
vcl.send( mod(vcl.getProcessUnitID() + i * P_STRIDE, vcl.getProcessingUnits()) ,i,v_send);
......@@ -517,6 +520,45 @@ template<typename T> void test_send_recv_primitives(size_t n, Vcluster & vcl)
BOOST_REQUIRE_EQUAL(pt,p_recv);
}
}
//! [ Send and receive vectors data ]
}
{
//! [ Send and receive plain buffer data ]
// Send to 8 processors
for (size_t i = 0 ; i < 8 ; i++)
vcl.send( mod(vcl.getProcessUnitID() + i * P_STRIDE, vcl.getProcessingUnits()) ,i,v_send.getPointer(),v_send.size()*sizeof(T));
openfpm::vector<openfpm::vector<T> > pt_buf;
pt_buf.resize(8);
// Recv from 8 processors
for (size_t i = 0 ; i < 8 ; i++)
{
pt_buf.get(i).resize(n);
vcl.recv( mod( (vcl.getProcessUnitID() - i * P_STRIDE), vcl.getProcessingUnits()) ,i,pt_buf.get(i).getPointer(),pt_buf.get(i).size()*sizeof(T));
}
vcl.execute();
// Check the received buffers (careful at negative modulo)
for (size_t i = 0 ; i < 8 ; i++)
{
for (size_t j = 0 ; j < n ; j++)
{
T pt = pt_buf.get(i).get(j);
T p_recv = mod( (vcl.getProcessUnitID() - i * P_STRIDE), vcl.getProcessingUnits());
BOOST_REQUIRE_EQUAL(pt,p_recv);
}
}
//! [ Send and receive plain buffer data ]
}
}
#endif /* VCLUSTER_UNIT_TEST_UTIL_HPP_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment