Commit 92096731 authored by incardon's avatar incardon
Browse files

Fixing ghost get

parent 0a999575
......@@ -848,7 +848,7 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
/usr/include/c++/4.8.3/bits/stl_numeric.h \
/usr/include/c++/4.8.3/functional /usr/include/c++/4.8.3/typeinfo \
/usr/include/c++/4.8.3/cstring ../../OpenFPM_data/src/memory_conf.hpp \
../../OpenFPM_data/src/to_variadic.hpp \
../../OpenFPM_data/src/util/variadic_to_vmpl.hpp \
/usr/include/boost/mpl/reverse.hpp /usr/include/boost/mpl/vector.hpp \
/usr/include/boost/mpl/limits/vector.hpp \
/usr/include/boost/mpl/vector/vector20.hpp \
......@@ -942,9 +942,9 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
../../OpenFPM_data/src/ct_array.hpp \
../../OpenFPM_data/src/memory_array.hpp \
../../OpenFPM_data/src/memory.hpp ../../OpenFPM_data/src/memory.hpp \
../../OpenFPM_data/src/meta_copy.hpp \
../../OpenFPM_data/src/util/meta_copy.hpp \
../../OpenFPM_data/src/Memleak_check.hpp \
../../OpenFPM_data/src/for_each_ref.hpp \
../../OpenFPM_data/src/util/for_each_ref.hpp \
../../OpenFPM_data/src/Grid/grid_sm.hpp \
/usr/include/boost/shared_array.hpp \
/usr/include/boost/smart_ptr/shared_array.hpp \
......@@ -2828,7 +2828,7 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
../../OpenFPM_data/src/memory_conf.hpp:
../../OpenFPM_data/src/to_variadic.hpp:
../../OpenFPM_data/src/util/variadic_to_vmpl.hpp:
/usr/include/boost/mpl/reverse.hpp:
......@@ -3032,11 +3032,11 @@ pdata-VCluster.o: ../../OpenFPM_vcluster/src/VCluster.cpp \
../../OpenFPM_data/src/memory.hpp:
../../OpenFPM_data/src/meta_copy.hpp:
../../OpenFPM_data/src/util/meta_copy.hpp:
../../OpenFPM_data/src/Memleak_check.hpp:
../../OpenFPM_data/src/for_each_ref.hpp:
../../OpenFPM_data/src/util/for_each_ref.hpp:
../../OpenFPM_data/src/Grid/grid_sm.hpp:
......
......@@ -810,7 +810,7 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
/usr/include/c++/4.8.3/bits/uses_allocator.h \
/usr/include/c++/4.8.3/cstring /usr/include/string.h \
../../OpenFPM_data/src/memory_conf.hpp \
../../OpenFPM_data/src/to_variadic.hpp \
../../OpenFPM_data/src/util/variadic_to_vmpl.hpp \
/usr/include/boost/mpl/reverse.hpp /usr/include/boost/mpl/vector.hpp \
/usr/include/boost/mpl/limits/vector.hpp \
/usr/include/boost/mpl/vector/vector20.hpp \
......@@ -904,12 +904,12 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
../../OpenFPM_data/src/ct_array.hpp \
../../OpenFPM_data/src/memory_array.hpp \
../../OpenFPM_data/src/memory.hpp ../../OpenFPM_data/src/memory.hpp \
../../OpenFPM_data/src/meta_copy.hpp \
../../OpenFPM_data/src/util/meta_copy.hpp \
../../OpenFPM_data/src/Memleak_check.hpp /usr/include/c++/4.8.3/map \
/usr/include/c++/4.8.3/bits/stl_tree.h \
/usr/include/c++/4.8.3/bits/stl_map.h \
/usr/include/c++/4.8.3/bits/stl_multimap.h \
../../OpenFPM_data/src/for_each_ref.hpp \
../../OpenFPM_data/src/util/for_each_ref.hpp \
../../OpenFPM_data/src/Grid/grid_sm.hpp \
/usr/include/boost/shared_array.hpp \
/usr/include/boost/smart_ptr/shared_array.hpp \
......@@ -1385,6 +1385,12 @@ pdata-main.o: main.cpp /usr/include/stdc-predef.h \
../../OpenFPM_devices/src/memory/PreAllocHeapMemory.hpp \
../../OpenFPM_devices/src/memory/HeapMemory.hpp \
../../OpenFPM_devices/src/memory/PtrMemory.hpp \
../../OpenFPM_data/src/util/object_util.hpp \
../../OpenFPM_data/src/util/object_creator.hpp \
../../OpenFPM_data/src/util/object_copy.hpp \
../../OpenFPM_data/src/util/for_each_ref.hpp \
/usr/include/boost/fusion/include/size.hpp \
../../OpenFPM_devices/src/memory/ExtPreAlloc.hpp \
Decomposition/CartDecomposition_unit_test.hpp \
Decomposition/CartDecomposition.hpp
......@@ -3170,7 +3176,7 @@ Graph/CartesianGraphFactory.hpp:
../../OpenFPM_data/src/memory_conf.hpp:
../../OpenFPM_data/src/to_variadic.hpp:
../../OpenFPM_data/src/util/variadic_to_vmpl.hpp:
/usr/include/boost/mpl/reverse.hpp:
......@@ -3374,7 +3380,7 @@ Graph/CartesianGraphFactory.hpp:
../../OpenFPM_data/src/memory.hpp:
../../OpenFPM_data/src/meta_copy.hpp:
../../OpenFPM_data/src/util/meta_copy.hpp:
../../OpenFPM_data/src/Memleak_check.hpp:
......@@ -3386,7 +3392,7 @@ Graph/CartesianGraphFactory.hpp:
/usr/include/c++/4.8.3/bits/stl_multimap.h:
../../OpenFPM_data/src/for_each_ref.hpp:
../../OpenFPM_data/src/util/for_each_ref.hpp:
../../OpenFPM_data/src/Grid/grid_sm.hpp:
......@@ -4456,6 +4462,18 @@ Vector/vector_dist_key.hpp:
../../OpenFPM_devices/src/memory/PtrMemory.hpp:
../../OpenFPM_data/src/util/object_util.hpp:
../../OpenFPM_data/src/util/object_creator.hpp:
../../OpenFPM_data/src/util/object_copy.hpp:
../../OpenFPM_data/src/util/for_each_ref.hpp:
/usr/include/boost/fusion/include/size.hpp:
../../OpenFPM_devices/src/memory/ExtPreAlloc.hpp:
Decomposition/CartDecomposition_unit_test.hpp:
Decomposition/CartDecomposition.hpp:
......@@ -462,7 +462,7 @@ public:
// Check with geo-cell if a particle is inside one Cell containing boxes
auto cell_it = geo_cell.getCellIterator(p);
auto cell_it = geo_cell.getIterator(geo_cell.getCell(p));
// For each element in the cell, check if the point is inside the box
// if it is, store the processor id
......@@ -479,9 +479,16 @@ public:
return ids;
}
// It store all the boxes of the near processors in a linear array
struct p_box
{
::Box<dim,T> box;
size_t proc;
};
// Internal boxes for this processor domain, indicated with B8_0 B9_0 ..... in the figure
// below as a linear vector
openfpm::vector<::Box<dim,T>> vb_int;
openfpm::vector<p_box> vb_int;
/*! It calculate the internal ghost boxes
*
......@@ -697,20 +704,20 @@ p1[0]<-----+ +----> p2[0]
// Intersect with the local sub-domain
::Box<dim,T> b_int;
bool intersect = n_sub.Intersect(l_sub,b_int);
p_box b_int;
bool intersect = n_sub.Intersect(l_sub,b_int.box);
// store if it intersect
if (intersect == true)
{
p_box_int.add(b_int);
p_box_int.add(b_int.box);
vb_int.add(b_int);
// update the geo_cell list
// get the boxes this box span
const grid_key_dx<dim> p1 = geo_cell.getCellGrid(b_int.getP1());
const grid_key_dx<dim> p2 = geo_cell.getCellGrid(b_int.getP2());
const grid_key_dx<dim> p1 = geo_cell.getCellGrid(b_int.box.getP1());
const grid_key_dx<dim> p2 = geo_cell.getCellGrid(b_int.box.getP2());
// Get the grid and the sub-iterator
auto & gi = geo_cell.getGrid();
......@@ -1052,6 +1059,17 @@ p1[0]<-----+ +----> p2[0]
return vb_int.get(b_id).proc;
}
/*! \brief Convert the near processor ID to processor number
*
* \param id
*
* \return return the processor number
*
*/
inline size_t IDtoProc(size_t id)
{
return nn_processors.get(id);
}
};
......
......@@ -69,8 +69,6 @@ public:
vector_dist(size_t np, Box box)
:dec(Decomposition(*global_v_cluster)),v_cl(*global_v_cluster)
{
typedef ::Box<point::dims,typename point::coord_type> b;
// Allocate unassigned particles vectors
v_pos = v_cl.template allocate<openfpm::vector<point>>(1);
v_prp = v_cl.template allocate<openfpm::vector<prop>>(1);
......@@ -121,7 +119,7 @@ public:
*/
size_t size_local()
{
v_pos.get(0).size();
return v_pos.get(0).size();
}
/*! \brief Get position of an object
......@@ -359,7 +357,7 @@ public:
// Memory for the ghost sending buffer
Memory g_prp_mem;
// Memory for the ghost
// Memory for the ghost position sending buffer
Memory g_pos_mem;
......@@ -404,45 +402,56 @@ public:
++it;
}
// Total number of elements
size_t n_ele = 0;
// Sending property object
typedef object<typename object_creator<typename prop::type,prp...>::type> prp_object;
// Send buffer size in byte ( one buffer for all processors )
size_t size_byte_prp = 0;
size_t size_byte_pos = 0;
// sequence of pre-allocation pattern
std::vector<size_t> pap;
// sequence of pre-allocation pattern for property and position send buffer
std::vector<size_t> pap_prp;
std::vector<size_t> pap_pos;
// Calculate the total size required for the sending buffer
for ( size_t i = 0 ; i < ghost_prc_sz.size() ; i++ )
{
pap.push_back(ghost_prc_sz.get(i)*sizeof(typename object_creator<Point_test<float>::type,prp...>::type));
n_ele += ghost_prc_sz.get(i);
size_t alloc_ele = openfpm::vector<prp_object>::calculateMem(ghost_prc_sz.get(i),0);
pap_prp.push_back(alloc_ele);
size_byte_prp += alloc_ele;
alloc_ele = openfpm::vector<point>::calculateMem(ghost_prc_sz.get(i),0);
pap_pos.push_back(alloc_ele);
size_byte_pos += alloc_ele;
}
// resize the property buffer memory
g_prp_mem.resize(n_ele * sizeof(typename object_creator<Point_test<float>::type,prp...>::type));
g_prp_mem.resize(size_byte_prp);
// resize the position buffer memory
if (opt != NO_POSITION) g_pos_mem.resize(n_ele * sizeof(point));
if (opt != NO_POSITION) g_pos_mem.resize(size_byte_pos);
// Create an object of preallocated memory
ExtPreAlloc<Memory> prAlloc(pap,g_prp_mem);
// Create an object of preallocated memory for properties
ExtPreAlloc<Memory> * prAlloc_prp = new ExtPreAlloc<Memory>(pap_prp,g_prp_mem);
// definition of a property object based on the property selected
typedef typename object_creator<Point_test<float>::type,prp...>::type property_object;
ExtPreAlloc<Memory> * prAlloc_pos;
// Create an object of preallocated memory for position
if (opt != NO_POSITION) prAlloc_pos = new ExtPreAlloc<Memory>(pap_pos,g_pos_mem);
// definition of the send vector for each processor
typedef openfpm::vector<::object<property_object>,openfpm::device_cpu<object<property_object>>,ExtPreAlloc<Memory>> send_vector;
typedef openfpm::vector<prp_object,openfpm::device_cpu<prp_object>,ExtPreAlloc<Memory>> send_vector;
// create a vector of send vector (ExtPreAlloc warrant that all the created vector are contiguous)
openfpm::vector<send_vector> g_send;
openfpm::vector<send_vector> g_send_prp;
// create a number of send buffer equal to the near processors
g_send.resize(ghost_prc_sz.size());
for (size_t i = 0 ; i < g_send.size() ; i++)
g_send_prp.resize(ghost_prc_sz.size());
for (size_t i = 0 ; i < g_send_prp.size() ; i++)
{
// set the preallocated memory to ensure contiguity
g_send.get(i).setMemory(prAlloc);
g_send_prp.get(i).setMemory(*prAlloc_prp);
// resize the sending vector (No allocation is produced)
g_send.get(i).resize(ghost_prc_sz.get(i));
g_send_prp.get(i).resize(ghost_prc_sz.get(i));
}
// Fill the send buffer
......@@ -453,10 +462,10 @@ public:
// source object type
typedef encapc<1,prop,typename openfpm::vector<prop>::memory_t> encap_src;
// destination object type
typedef encapc<1,::object<property_object>,typename openfpm::vector<::object<property_object>>::memory_t> encap_dst;
typedef encapc<1,prp_object,typename openfpm::vector<prp_object>::memory_t> encap_dst;
// Copy only the selected properties
object_copy<encap_src,encap_dst,ENCAP,prp...>(v_prp.get(INTERNAL).get(opart.get(i).get(j)),g_send.get(i).get(j));
object_copy<encap_src,encap_dst,ENCAP,prp...>(v_prp.get(INTERNAL).get(opart.get(i).get(j)),g_send_prp.get(i).get(j));
}
}
......@@ -473,7 +482,7 @@ public:
for (size_t i = 0 ; i < g_pos_send.size() ; i++)
{
// set the preallocated memory to ensure contiguity
g_pos_send.get(i).setMemory(prAlloc);
g_pos_send.get(i).setMemory(*prAlloc_pos);
// resize the sending vector (No allocation is produced)
g_pos_send.get(i).resize(ghost_prc_sz.get(i));
......
......@@ -15,6 +15,7 @@ BOOST_AUTO_TEST_SUITE( vector_dist_test )
BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use )
{
typedef Point_test<float> p;
typedef Point<2,float> s;
// set the seed
......@@ -63,7 +64,6 @@ BOOST_AUTO_TEST_CASE( vector_dist_iterator_test_use )
// do a ghost get
typedef Point_test<float> p;
vd.template ghost_get<p::s,p::v>();
}
......
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