1 #include "Grid/grid_dist_id.hpp" 
    2 #include "data_type/aggregate.hpp" 
    3 #include "Decomposition/CartDecomposition.hpp" 
    4 #include "VCluster/VCluster.hpp" 
   27 int main(
int argc, 
char* argv[])
 
   44     openfpm_init(&argc,&argv);
 
   97         std::cout << 
"Maximum processor rank: " << 
id << 
"\n";
 
  122         std::cout << 
"Sum of all processors rank: " << id2 << 
"\n";
 
  148         std::cout << 
"Collected ids: ";
 
  149         for(
size_t i = 0 ; i < v.
size() ; i++)
 
  150             std::cout << 
" " << v.get(i) << 
" ";
 
  175     std::stringstream ss_message_1;
 
  176     std::stringstream ss_message_2;
 
  177     ss_message_1 << 
"Hello from " << std::setw(8) << v_cl.
getProcessUnitID() << 
"\n";
 
  178     ss_message_2 << 
"Hello from " << std::setw(8) << v_cl.
getProcessUnitID() << 
"\n";
 
  179     std::string message_1 = ss_message_1.str();
 
  180     std::string message_2 = ss_message_2.str();
 
  181     size_t msg_size = message_1.size();
 
  186     v_cl.
send(((id3+1)%N_prc + N_prc)%N_prc,0,message_1.c_str(),msg_size);
 
  187     v_cl.
send(((id3+2)%N_prc + N_prc)%N_prc,0,message_2.c_str(),msg_size);
 
  191     v_one.resize(msg_size);
 
  193     v_two.resize(msg_size);
 
  197     v_cl.
recv(((id3-1)%N_prc + N_prc)%N_prc,0,(
void *)v_one.getPointer(),msg_size);
 
  198     v_cl.
recv(((id3-2)%N_prc + N_prc)%N_prc,0,(
void *)v_two.getPointer(),msg_size);
 
  204         for (
size_t i = 0 ; i < msg_size ; i++)
 
  205             std::cout << v_one.get(i);
 
  207         for (
size_t i = 0 ; i < msg_size ; i++)
 
  208             std::cout << v_two.get(i);
 
  238     for (
size_t i = 0 ; i < msg_size ; i++)
 
  239         message_1_v.get(i) = message_1[i];
 
  241     for (
size_t i = 0 ; i < msg_size ; i++)
 
  242         message_2_v.get(i) = message_2[i];
 
  252     v_cl.
send(((
id+1)%N_prc + N_prc)%N_prc,0,message_1_v);
 
  253     v_cl.
send(((
id+2)%N_prc + N_prc)%N_prc,0,message_2_v);
 
  254     v_cl.
recv(((
id-1)%N_prc + N_prc)%N_prc,0,v_one);
 
  255     v_cl.
recv(((
id-2)%N_prc + N_prc)%N_prc,0,v_two);
 
  261         std::cout << 
"Maximum processor rank: " << 
id << 
"\n";
 
  262         std::cout << 
"Sum of all processors rank: " << 
id << 
"\n";
 
  264         std::cout << 
"Collected ids: ";
 
  265         for(
size_t i = 0 ; i < v.
size() ; i++)
 
  266             std::cout << 
" " << v.get(i) << 
" ";
 
  270         for (
size_t i = 0 ; i < msg_size ; i++)
 
  271             std::cout << v_one.get(i);
 
  273         for (
size_t i = 0 ; i < msg_size ; i++)
 
  274             std::cout << v_two.get(i);
 
void sum(T &num)
Sum the numbers across all processors and get the result. 
 
size_t getProcessUnitID()
Get the process unit id. 
 
void execute()
Execute all the requests. 
 
void max(T &num)
Get the maximum number across all processors (or reduction with infinity norm) 
 
bool send(size_t proc, size_t tag, const void *mem, size_t sz)
Send data to a processor. 
 
Implementation of VCluster class. 
 
bool recv(size_t proc, size_t tag, void *v, size_t sz)
Recv data from a processor. 
 
size_t getProcessingUnits()
Get the total number of processors. 
 
bool allGather(T &send, openfpm::vector< T, Mem, gr > &v)
Gather the data from all processors.