Commit ede7ff53 authored by Pietro Incardona's avatar Pietro Incardona

Fixing semantic communication

parent 730d7f34
......@@ -17,6 +17,7 @@
#include "util/util_debug.hpp"
#endif
#include "util/Vcluster_log.hpp"
#include "memory/BHeapMemory.hpp"
#define MSG_LENGTH 1024
#define MSG_SEND_RECV 1025
......@@ -161,7 +162,7 @@ class Vcluster
openfpm::vector<size_t> map;
// Receive buffers
openfpm::vector<HeapMemory> recv_buf;
openfpm::vector<BHeapMemory> recv_buf;
// barrier request
MPI_Request bar_req;
......
......@@ -32,7 +32,7 @@ void reset_recv_buf()
*/
static void * msg_alloc(size_t msg_i ,size_t total_msg, size_t total_p, size_t i, size_t ri, void * ptr)
{
openfpm::vector<HeapMemory> * recv_buf = (openfpm::vector<HeapMemory> *)ptr;
openfpm::vector<BHeapMemory> * recv_buf = (openfpm::vector<BHeapMemory> *)ptr;
if (recv_buf == NULL)
std::cerr << __FILE__ << ":" << __LINE__ << " Internal error this processor is not suppose to receive\n";
......@@ -69,7 +69,7 @@ static void * msg_alloc(size_t msg_i ,size_t total_msg, size_t total_p, size_t i
* \return true if the function completed succefully
*
*/
template<typename T, typename S> bool SGather(T & send, S & recv,size_t root)
template<typename T, typename S> bool SGather(T & send, S & recv,size_t root, int debug = 0)
{
// Reset the receive buffer
reset_recv_buf();
......@@ -89,7 +89,7 @@ template<typename T, typename S> bool SGather(T & send, S & recv,size_t root)
// for each received buffer create a memory reppresentation
// calculate the number of received elements
size_t n_ele = recv_buf.get(i).size() / sizeof(typename T::value_type);
// add the received particles to the vector
PtrMemory * ptr1 = new PtrMemory(recv_buf.get(i).getPointer(),recv_buf.get(i).size());
......
......@@ -20,38 +20,7 @@ BOOST_AUTO_TEST_SUITE( VCluster_semantic_test )
BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather)
{
{
Vcluster & vcl = *global_v_cluster;
if (vcl.getProcessingUnits() >= 32)
return;
//! [Gather the data on master]
openfpm::vector<size_t> v1;
v1.resize(vcl.getProcessUnitID());
for(size_t i = 0 ; i < vcl.getProcessUnitID() ; i++)
v1.get(i) = 5;
openfpm::vector<size_t> v2;
vcl.SGather(v1,v2,0);
//! [Gather the data on master]
if (vcl.getProcessUnitID() == 0)
{
size_t n = vcl.getProcessingUnits();
BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
bool is_five = true;
for (size_t i = 0 ; i < v2.size() ; i++)
is_five &= (v2.get(i) == 5);
BOOST_REQUIRE_EQUAL(is_five,true);
}
}
for (size_t i = 0 ; i < 100 ; i++)
{
Vcluster & vcl = *global_v_cluster;
......@@ -66,9 +35,9 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather)
openfpm::vector<size_t> v2;
vcl.SGather(v1,v2,1);
vcl.SGather(v1,v2,(i%vcl.getProcessingUnits()));
if (vcl.getProcessUnitID() == 1)
if (vcl.getProcessUnitID() == (i%vcl.getProcessingUnits()))
{
size_t n = vcl.getProcessingUnits();
BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
......@@ -85,46 +54,7 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_gather)
BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_gather)
{
{
Vcluster & vcl = *global_v_cluster;
if (vcl.getProcessingUnits() >= 32)
return;
//! [Gather the data on master complex]
openfpm::vector<A> v1;
v1.resize(vcl.getProcessUnitID());
for(size_t i = 0 ; i < vcl.getProcessUnitID() ; i++)
{
v1.get(i).a = 5;
v1.get(i).b = 10.0;
v1.get(i).c = 11.0;
}
openfpm::vector<A> v2;
vcl.SGather(v1,v2,0);
//! [Gather the data on master complex]
if (vcl.getProcessUnitID() == 0)
{
size_t n = vcl.getProcessingUnits();
BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
bool is_correct = true;
for (size_t i = 0 ; i < v2.size() ; i++)
{
is_correct &= (v2.get(i).a == 5);
is_correct &= (v2.get(i).b == 10.0);
is_correct &= (v2.get(i).c == 11.0);
}
BOOST_REQUIRE_EQUAL(is_correct,true);
}
}
for (size_t i = 0 ; i < 100 ; i++)
{
Vcluster & vcl = *global_v_cluster;
......@@ -143,9 +73,9 @@ BOOST_AUTO_TEST_CASE (Vcluster_semantic_struct_gather)
openfpm::vector<A> v2;
vcl.SGather(v1,v2,1);
vcl.SGather(v1,v2,(i%vcl.getProcessingUnits()));
if (vcl.getProcessUnitID() == 1)
if (vcl.getProcessUnitID() == (i%vcl.getProcessingUnits()))
{
size_t n = vcl.getProcessingUnits();
BOOST_REQUIRE_EQUAL(v2.size(),n*(n-1)/2);
......
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