Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
O
openfpm_vcluster
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openfpm
openfpm_vcluster
Commits
2ad41280
Commit
2ad41280
authored
Jan 05, 2016
by
Yaroslav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Packer/Unpacker smarter and refactor
parent
5f770f98
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
129 additions
and
162 deletions
+129
-162
configure.ac
configure.ac
+1
-1
src/Makefile
src/Makefile
+18
-18
src/Makefile.am
src/Makefile.am
+1
-1
src/Pack_selector.hpp
src/Pack_selector.hpp
+10
-4
src/Pack_stat.hpp
src/Pack_stat.hpp
+0
-123
src/Packer.hpp
src/Packer.hpp
+60
-6
src/Packer_unit_tests.hpp
src/Packer_unit_tests.hpp
+1
-2
src/Unpacker.hpp
src/Unpacker.hpp
+32
-4
src/VCluster_unit_tests.hpp
src/VCluster_unit_tests.hpp
+1
-2
src/main.cpp
src/main.cpp
+5
-1
No files found.
configure.ac
View file @
2ad41280
...
...
@@ -71,7 +71,7 @@ fi
####### include OpenFPM_devices include path
INCLUDES_PATH+=" -I/usr/local/include -I. -Iconfig -I../../
OpenFPM
_devices/src -I../../OpenFPM_data/src"
INCLUDES_PATH+=" -I/usr/local/include -I. -Iconfig -I../../
openfpm
_devices/src -I../../OpenFPM_data/src"
###### Check for memleak check compilation
...
...
src/Makefile
View file @
2ad41280
...
...
@@ -201,7 +201,7 @@ ECHO_C =
ECHO_N
=
-n
ECHO_T
=
EXEEXT
=
INCLUDES_PATH
=
-I
/usr/local/include
-I
.
-Iconfig
-I
../../
OpenFPM
_devices/src
-I
../../OpenFPM_data/src
INCLUDES_PATH
=
-I
/usr/local/include
-I
.
-Iconfig
-I
../../
openfpm
_devices/src
-I
../../OpenFPM_data/src
INSTALL
=
/usr/bin/install
-c
INSTALL_DATA
=
${INSTALL}
-m
644
INSTALL_PROGRAM
=
${INSTALL}
...
...
@@ -285,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 ../../OpenFPM
_devices/src/memory/PtrMemory.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)
...
...
@@ -423,33 +423,33 @@ vcluster-VCluster.obj: VCluster.cpp
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcluster_CXXFLAGS) $(CXXFLAGS) -c -o vcluster-VCluster.obj `if test -f 'VCluster.cpp'; then $(CYGPATH_W) 'VCluster.cpp'; else $(CYGPATH_W) '$(srcdir)/VCluster.cpp'; fi`
vcluster-HeapMemory.o
:
../../
OpenFPM
_devices/src/memory/HeapMemory.cpp
$(AM_V_CXX)$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(AM_CPPFLAGS)
$(CPPFLAGS)
$(vcluster_CXXFLAGS)
$(CXXFLAGS)
-MT
vcluster-HeapMemory.o
-MD
-MP
-MF
$(DEPDIR)
/vcluster-HeapMemory.Tpo
-c
-o
vcluster-HeapMemory.o
`
test
-f
'../../
OpenFPM_devices/src/memory/HeapMemory.cpp'
||
echo
'
$(srcdir)
/'
`
../../OpenFPM
_devices/src/memory/HeapMemory.cpp
vcluster-HeapMemory.o
:
../../
openfpm
_devices/src/memory/HeapMemory.cpp
$(AM_V_CXX)$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(AM_CPPFLAGS)
$(CPPFLAGS)
$(vcluster_CXXFLAGS)
$(CXXFLAGS)
-MT
vcluster-HeapMemory.o
-MD
-MP
-MF
$(DEPDIR)
/vcluster-HeapMemory.Tpo
-c
-o
vcluster-HeapMemory.o
`
test
-f
'../../
openfpm_devices/src/memory/HeapMemory.cpp'
||
echo
'
$(srcdir)
/'
`
../../openfpm
_devices/src/memory/HeapMemory.cpp
$(AM_V_at)$(am__mv)
$(DEPDIR)
/vcluster-HeapMemory.Tpo
$(DEPDIR)
/vcluster-HeapMemory.Po
# $(AM_V_CXX)source='../../
OpenFPM
_devices/src/memory/HeapMemory.cpp' object='vcluster-HeapMemory.o' libtool=no \
# $(AM_V_CXX)source='../../
openfpm
_devices/src/memory/HeapMemory.cpp' object='vcluster-HeapMemory.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-HeapMemory.o `test -f '../../
OpenFPM_devices/src/memory/HeapMemory.cpp' || echo '$(srcdir)/'`../../OpenFPM
_devices/src/memory/HeapMemory.cpp
# $(AM_V_CXX_no)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(vcluster_CXXFLAGS) $(CXXFLAGS) -c -o vcluster-HeapMemory.o `test -f '../../
openfpm_devices/src/memory/HeapMemory.cpp' || echo '$(srcdir)/'`../../openfpm
_devices/src/memory/HeapMemory.cpp
vcluster-HeapMemory.obj
:
../../
OpenFPM
_devices/src/memory/HeapMemory.cpp
$(AM_V_CXX)$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(AM_CPPFLAGS)
$(CPPFLAGS)
$(vcluster_CXXFLAGS)
$(CXXFLAGS)
-MT
vcluster-HeapMemory.obj
-MD
-MP
-MF
$(DEPDIR)
/vcluster-HeapMemory.Tpo
-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-HeapMemory.obj
:
../../
openfpm
_devices/src/memory/HeapMemory.cpp
$(AM_V_CXX)$(CXX)
$(DEFS)
$(DEFAULT_INCLUDES)
$(INCLUDES)
$(AM_CPPFLAGS)
$(CPPFLAGS)
$(vcluster_CXXFLAGS)
$(CXXFLAGS)
-MT
vcluster-HeapMemory.obj
-MD
-MP
-MF
$(DEPDIR)
/vcluster-HeapMemory.Tpo
-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
`
$(AM_V_at)$(am__mv)
$(DEPDIR)
/vcluster-HeapMemory.Tpo
$(DEPDIR)
/vcluster-HeapMemory.Po
# $(AM_V_CXX)source='../../
OpenFPM
_devices/src/memory/HeapMemory.cpp' object='vcluster-HeapMemory.obj' libtool=no \
# $(AM_V_CXX)source='../../
openfpm
_devices/src/memory/HeapMemory.cpp' object='vcluster-HeapMemory.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-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`
# $(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
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 \
# $(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
# $(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
`
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 \
# $(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`
# $(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
...
...
src/Makefile.am
View file @
2ad41280
...
...
@@ -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 ../../OpenFPM
_devices/src/memory/PtrMemory.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)
...
...
src/Pack_selector.hpp
View file @
2ad41280
...
...
@@ -5,10 +5,20 @@
* Author: Pietro Incardona
*/
#ifndef SRC_PACK_AAA_SELECTOR_HPP_
#define SRC_PACK_AAA_SELECTOR_HPP_
#include <type_traits>
#include "util/common.hpp"
#include "Grid/Encap.hpp"
#include "Grid/util.hpp"
#include "Vector/util.hpp"
//! Primitive packing
#define PACKER_PRIMITIVE 1
//! Array of primitives packing
#define PACKER_ARRAY_PRIMITIVE 2
//! Encapsulated Object packing
#define PACKER_ENCAP_OBJECTS 3
//! Vector of objects packing
...
...
@@ -20,10 +30,6 @@
//! Packer error structure has pointers
#define PACKER_OBJECTS_WITH_POINTER_CHECK 7
#ifndef SRC_PACK_SELECTOR_HPP_
#define SRC_PACK_SELECTOR_HPP_
#define IS_ENCAP 4
#define IS_GRID 2
#define IS_VECTOR 1
...
...
src/Pack_stat.hpp
deleted
100644 → 0
View file @
5f770f98
/*
* Pack_stat.hpp
*
* Created on: Jul 17, 2015
* Author: i-bird
*/
#ifndef SRC_PACK_STAT_HPP_
#define SRC_PACK_STAT_HPP_
/*! \brief Unpacking status object
*
*
*/
class
Unpack_stat
{
size_t
cnt
;
public:
inline
Unpack_stat
()
:
cnt
(
0
)
{}
/*! \brief Increment the request pointer
*
* \param cnt counter
*
*/
inline
void
addOffset
(
size_t
off
)
{
cnt
+=
off
;
}
/*! \brief Return the actual counter
*
*
*/
inline
size_t
getOffset
()
{
return
cnt
;
}
};
/*! \brief Packing status object
*
*
*/
class
Pack_stat
{
size_t
p_mark
;
size_t
un_ele
;
public:
inline
Pack_stat
()
:
p_mark
(
0
),
un_ele
(
0
)
{}
/*! \brief Increment the request pointer
*
*
*/
inline
void
incReq
()
{
un_ele
++
;
}
/*! \brief return the actual request for packing
*
* \return the actual request for packing
*
*/
inline
size_t
reqPack
()
{
return
un_ele
;
}
/*! \brief Mark
*
*
*
*/
inline
void
mark
()
{
p_mark
=
un_ele
;
}
/*! \brief Return the mark
*
* \return the mark
*
*/
inline
size_t
getMark
()
{
return
p_mark
;
}
/*! \brief Return the memory pointer at the mark place
*
* \tparam T memory object
*
* \return memory pointer at mark place
*
*/
template
<
typename
T
>
inline
void
*
getMarkPointer
(
T
&
mem
)
{
return
mem
.
getPointer
(
p_mark
);
}
/*! \brief Get the memory size from the mark point
*
* \tparam T memory object
*
*/
template
<
typename
T
>
size_t
getMarkSize
(
T
&
mem
)
{
return
(
char
*
)
mem
.
getPointer
(
un_ele
)
-
(
char
*
)
mem
.
getPointer
(
p_mark
);
}
};
#endif
/* SRC_PACK_STAT_HPP_ */
src/Packer.hpp
View file @
2ad41280
...
...
@@ -9,13 +9,19 @@
#define SRC_PACKER_HPP_
#include "util/object_util.hpp"
#include "Grid/util.hpp"
//
#include "Grid/util.hpp"
#include "Vector/util.hpp"
#include "memory/ExtPreAlloc.hpp"
#include "util/util_debug.hpp"
#include "Pack_stat.hpp"
#ifdef SRC_PACK_SELECTOR_HPP_
#error blabla
#endif
#include "Grid/grid_sm.hpp"
#include "util/Pack_stat.hpp"
#include "Pack_selector.hpp"
#include "Vector/map_vector.hpp"
//
#include "Vector/map_vector.hpp"
/*! \brief Packing class
*
...
...
@@ -83,7 +89,6 @@ public:
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
;
...
...
@@ -102,6 +107,52 @@ public:
}
};
/*! \brief Packer for primitives
*
* \tparam T object type to pack
* \tparam Mem Memory origin HeapMemory CudaMemory ...
*
*/
template
<
typename
T
,
typename
Mem
>
class
Packer
<
T
,
Mem
,
PACKER_ARRAY_PRIMITIVE
>
{
public:
/*! \brief It packs arrays of C++ primitives
*
* \param ext preallocated memory where to pack the object
* \param obj object to pack
* \param sts pack-stat info
*
*/
inline
static
void
pack
(
ExtPreAlloc
<
Mem
>
&
ext
,
const
T
&
obj
,
Pack_stat
&
sts
,
size_t
n
)
{
#ifdef DEBUG
if
(
ext
.
ref
()
==
0
)
std
::
cerr
<<
"Error : "
<<
__FILE__
<<
":"
<<
__LINE__
<<
" the reference counter of mem should never be zero when packing
\n
"
;
#endif
//Pack the size of a vector
Packer
<
size_t
,
Mem
>::
pack
(
ext
,
obj
.
size
(),
sts
);
//Pack a vector
ext
.
allocate
(
sizeof
(
typename
T
::
value_type
)
*
n
);
memcpy
(
ext
.
getPointer
(),
obj
.
getPointer
(),
sizeof
(
typename
T
::
value_type
)
*
n
);
// update statistic
sts
.
incReq
();
}
/*! \brief It add a request to pack a C++ primitive
*
* \param req requests vector
*
*/
static
void
packRequestDummy
(
std
::
vector
<
size_t
>
&
req
)
{
req
.
push_back
(
sizeof
(
T
));
}
};
/*! \brief Packer for objects, with impossibility to check for internal pointers
*
...
...
@@ -205,12 +256,15 @@ public:
template
<
int
...
prp
>
static
void
packRequest
(
T
&
obj
,
std
::
vector
<
size_t
>
&
v
)
{
obj
.
packRequest
<
prp
...
>
(
obj
,
v
);
obj
.
packRequest
<
prp
...
>
(
v
);
};
template
<
int
...
prp
>
static
void
pack
(
ExtPreAlloc
<
Mem
>
&
mem
,
T
&
obj
,
Pack_stat
&
sts
)
{
obj
.
pack
<
prp
...
>
(
mem
,
obj
,
sts
);
#ifdef DEBUG
std
::
cout
<<
"Inside vector pack() function! (packer.hpp)"
<<
std
::
endl
;
#endif
obj
.
pack
<
prp
...
>
(
mem
,
sts
);
};
};
...
...
src/Packer_unit_tests.hpp
View file @
2ad41280
...
...
@@ -125,8 +125,7 @@ BOOST_AUTO_TEST_CASE ( packer_unpacker_test )
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
ExtPreAlloc
<
HeapMemory
>
preall
;
size_t
req
=
preall
.
calculateMem
(
pap_prp
);
size_t
req
=
ExtPreAlloc
<
HeapMemory
>::
calculateMem
(
pap_prp
);
// allocate the memory
HeapMemory
pmem
;
...
...
src/Unpacker.hpp
View file @
2ad41280
...
...
@@ -9,12 +9,12 @@
#define SRC_UNPACKER_HPP_
#include "util/object_util.hpp"
#include "Grid/util.hpp"
#include "Vector/util.hpp"
//
#include "Grid/util.hpp"
//
#include "Vector/util.hpp"
#include "memory/ExtPreAlloc.hpp"
#include "util/util_debug.hpp"
#include "Pack_selector.hpp"
#include "Pack_stat.hpp"
#include "
util/
Pack_stat.hpp"
#include "memory/PtrMemory.hpp"
/*! \brief Unpacker class
...
...
@@ -65,6 +65,34 @@ public:
}
};
template
<
typename
T
,
typename
Mem
>
class
Unpacker
<
T
,
Mem
,
PACKER_ARRAY_PRIMITIVE
>
{
public:
/*! \brief It unpack C++ primitives
*
* \param ext preallocated memory from where to unpack the object
* \param obj object where to unpack
*
*/
static
void
unpack
(
ExtPreAlloc
<
Mem
>
&
ext
,
T
&
obj
,
Unpack_stat
&
ps
)
{
//Unpacking a size of a source vector
size_t
u2
=
0
;
Unpacker
<
size_t
,
Mem
>::
unpack
(
ext
,
u2
,
ps
);
//Resize a destination vector
obj
.
resize
(
u2
);
memcpy
(
obj
.
getPointer
(),
ext
.
getPointerOffset
(
ps
.
getOffset
()),
sizeof
(
typename
T
::
value_type
)
*
obj
.
size
());
ps
.
addOffset
(
sizeof
(
typename
T
::
value_type
)
*
obj
.
size
());
}
};
/*! \brief Unpacker for objects with no possibility to check for internal pointers
*
...
...
@@ -136,7 +164,7 @@ public:
template
<
unsigned
int
...
prp
>
void
static
unpack
(
ExtPreAlloc
<
Mem
>
&
mem
,
T
&
obj
,
Unpack_stat
&
ps
)
{
obj
.
unpack
<
prp
...
>
(
mem
,
obj
,
ps
);
obj
.
unpack
<
prp
...
>
(
mem
,
ps
);
};
};
...
...
src/VCluster_unit_tests.hpp
View file @
2ad41280
...
...
@@ -15,6 +15,7 @@
#include <random>
#include "VCluster_unit_test_util.hpp"
#include "Point_test.hpp"
#include "Vector/vector_test_util.hpp"
BOOST_AUTO_TEST_SUITE
(
VCluster_test
)
...
...
@@ -109,8 +110,6 @@ BOOST_AUTO_TEST_CASE( VCluster_use_reductions)
#define N_V_ELEMENTS 16
#include "Vector/vector_test_util.hpp"
BOOST_AUTO_TEST_CASE
(
VCluster_send_recv
)
{
Vcluster
&
vcl
=
*
global_v_cluster
;
...
...
src/main.cpp
View file @
2ad41280
#include "config.h"
#define BOOST_TEST_MODULE "C++ test module for OpenFPM_vcluster project"
#include <boost/test/included/unit_test.hpp>
/*#include "Packer.hpp"
#include "Unpacker.hpp"
#include "Pack_selector.hpp"*/
#include "VCluster.hpp"
#include "unit_test_init_cleanup.hpp"
#include "VCluster_unit_tests.hpp"
#include "Packer_unit_tests.hpp"
//
#include "Packer_unit_tests.hpp"
#include "Packer_nested_tests.hpp"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment