PaCO++  0.05
PC/ServerSide.cc File Reference
#include <stdio.h>
#include "Schedule.h"
#include "DistributionBloc.h"
#include "Internal.h"
Include dependency graph for PC/ServerSide.cc:

Go to the source code of this file.

Macros

#define DEBUG_INTERNAL
 

Functions

bool computeReceiveDataBlock1D (vAbstrait *vdarray, const PaCO::distLoc_t &mode, const unsigned dtotal, const unsigned drank, Abstrait *varray, void *comm)
 
void computeReceiveDataBlock1DServer (vAbstrait *vdarray, const Topology_t &dtopo, Abstrait *varray, void *comm)
 varray must contain the rank of the caller More...
 
unsigned nbofPart (const PaCO::distLoc_t &mode, const unsigned stotal, const unsigned dtotal, const unsigned drank)
 
unsigned posofPart (const PaCO::distLoc_t &mode, const unsigned dtotal, const unsigned srank)
 

Macro Definition Documentation

◆ DEBUG_INTERNAL

#define DEBUG_INTERNAL

Definition at line 11 of file PC/ServerSide.cc.

Function Documentation

◆ computeReceiveDataBlock1D()

bool computeReceiveDataBlock1D ( vAbstrait *  vdarray,
const PaCO::distLoc_t mode,
const unsigned  dtotal,
const unsigned  drank,
Abstrait *  varray,
void *  comm 
)

Definition at line 135 of file PC/ServerSide.cc.

References PaCO::ClientSide, PaCO::CommSide, computeReceiveDataBlock1DServer(), PaCO::none, and PaCO::ServerSide.

137  {
138 
139  cerr << "In computeReceiveDataBlock1D...\n";
140 
141  switch(mode) {
142  case PaCO::none:
143  cerr << "INTERNAL ERROR: " << __FILE__ << " " << __FUNCTION__ << endl;
144  break;
145  case PaCO::ClientSide:
146  cerr << "Client Side case" <<endl;
147  varray->CopyAndGetSequenceOwner((*vdarray)[0]);
148  cerr << "Return true" << endl;
149  return true;
150  break;
151 
152  case PaCO::ServerSide: {
153  // data has been sent from source i to dest i % dtopo.total
154  // so dest j has : j, j + dtopo.total, j+2*dtopo.total
155  // so it may be 1 (at least activation) or more
156  cerr << " vdaray size: " << vdarray->size() << endl;
157 
158 // unsigned stotal = (*vdarray)[0]->topo().total;
159 // unsigned int nvdarray = stotal/dtotal;
160 // unsigned int remaining = (nvdarray*dtotal + drank < stotal)?1:0;
161 // nvdarray += remaining;
162 // if ( nvdarray == 0 ) nvdarray=1; // alway at least one
163 
164 // fprintf(stderr, "computeReceiveDataBlock1D: Node %d : got %d of %d data\n", drank, vdarray->size(), nvdarray);
165 
166 // if (vdarray->size() == nvdarray) {
167 
168  cerr << "DOING LOCAL REDISTRIBUTION width drank: "<< drank << endl;
169  Topology_t dtopo;
170  dtopo.total = dtotal;
171 
172  varray->topo() = (*vdarray)[0]->topo();
173  varray->gd() = (*vdarray)[0]->gd();
174  varray->dist().length(1);
175  varray->dist()[0].rank = drank;
176 
177  computeReceiveDataBlock1DServer(vdarray, dtopo, varray, comm);
178 
179  return true;
180  break;
181  }
182  case PaCO::CommSide:
183  break;
184  }
185  return false;
186 }
void computeReceiveDataBlock1DServer(vAbstrait *vdarray, const Topology_t &dtopo, Abstrait *varray, void *comm)
varray must contain the rank of the caller
Here is the call graph for this function:

◆ computeReceiveDataBlock1DServer()

void computeReceiveDataBlock1DServer ( vAbstrait *  vdarray,
const Topology_t &  dtopo,
Abstrait *  varray,
void *  comm 
)

varray must contain the rank of the caller

Definition at line 18 of file PC/ServerSide.cc.

References blockSize(), computeReceiveBlock1D(), computeSendBlock1D(), doSchedule(), PaCO::PacoLocalData_s::len, localBlockLengthO(), PaCO::PacoLocalData_s::rank, sd, and PaCO::PacoLocalData_s::start.

Referenced by computeReceiveDataBlock1D().

19 {
20 
21  cerr << "In computeReceiveDataBlock1DServer...\n";
22 
23  vector<LocalData_t> sched_send;
24  vector<LocalData_t> sched_recv;
25 
26  sched_send.clear();
27  sched_recv.clear();
28 
29  // Init data from 1st: all entries are assumed to be identical !
30  GlobalData_t& gd = (*vdarray)[0]->gd();
31  Topology_t& stopo= (*vdarray)[0]->topo();
32 
36  // Compute what to send
38  cerr << "In computeReceiveDataBlock1DServer...computing what to send\n";
39  for (unsigned it=0; it<vdarray->size(); it++) {
40  if ((*vdarray)[it]->dist().length()==0) {
41  cerr << "Dist data empty: nothing to send\n";
42  } else {
43  cerr << "it = " << it << endl;
44  PaCO::PacoLocalData_t psd = (*vdarray)[it]->dist()[0];
45  LocalData_t sd;
46  sd.rank = psd.rank;
47  sd.start = psd.start;
48  sd.len = psd.len;
49  sd.base = (*vdarray)[it]->getDataBuffer(0, false);
50  computeSendBlock1D(gd, sd, stopo, dtopo, sched_send);
51  }
52  }
53 
57  // Compute what to receive
59  cerr << "In computeReceiveDataBlock1DServer...computing what to receive\n";
60 
63  // Allocating memory
64 
65  unsigned dbsz = blockSize(gd.len, dtopo.total);
66  LocalData_t vd;
67  vd.rank = varray->dist()[0].rank;
68  vd.start = vd.rank * dbsz;
69  vd.len = localBlockLengthO(gd.len, vd.rank, dtopo.total, dbsz);
70 
71 #ifdef DEBUG_INTERNAL
72  cerr << "Allocating a sequence of length " << vd.len << endl;
73 #endif
74  varray->setSeqLength(1);
75  varray->setDataLength(0, vd.len);
76  if (vd.len > 0 )
77  vd.base = varray->getDataBuffer(0, false);
78  else
79  vd.base = (char*) 1;
80 
81  if (vd.base==0) {
82  cerr << "Cannot allocate memory for #elements" << vd.len << endl;
83  } else {
84 #ifdef DEBUG_INTERNAL
85  fprintf(stderr, "dd.base = %p\n", vd.base);
86 #endif
87  }
88 
89  computeReceiveBlock1D(gd, vd, stopo, dtopo, sched_recv);
90 
94  // Doing local communication
96  fprintf(stderr, "In computeReceiveDataBlock1DServer...Doing local communications with ctopo: %ld\n", dtopo.total);
97  doSchedule(gd, vd, dtopo, sched_send, sched_recv, comm);
98 
99  cerr << "In computeReceiveDataBlock1DServer...ok\n";
100 }
vector< BasicBC > sd
Definition: debug.cc:14
void computeSendBlock1D(const GlobalData_t &gd, const LocalData_t &sd, const Topology_t &stopo, const Topology_t &dtopo, const ParisBlock_param_t *param, vector< LocalData_t > &vOut)
Definition: Schedule.cc:38
unsigned long start
Definition: PaCO++.idl:27
void doSchedule(const GlobalData_t &gd, const LocalData_t &ld, const Topology_t &ctopo, vector< LocalData_t > &sched_send, vector< LocalData_t > &sched_recv, void *comm)
Definition: Schedule.cc:227
unsigned long rank
Definition: PaCO++.idl:26
static unsigned blockSize(const unsigned glen, const unsigned nbprocs, const ParisBlock_param_t *param)
static unsigned localBlockLengthO(unsigned glen, unsigned rank, unsigned total, unsigned bsz)
void computeReceiveBlock1D(const GlobalData_t &gd, const LocalData_t &dd, const Topology_t &stopo, const Topology_t &dtopo, const ParisBlock_param_t *param, vector< LocalData_t > &vOut)
Definition: Schedule.cc:135
unsigned long len
Definition: PaCO++.idl:28
Here is the call graph for this function:

◆ nbofPart()

unsigned nbofPart ( const PaCO::distLoc_t mode,
const unsigned  stotal,
const unsigned  dtotal,
const unsigned  drank 
)

Definition at line 105 of file PC/ServerSide.cc.

References PaCO::ClientSide, PaCO::CommSide, PaCO::none, and PaCO::ServerSide.

Referenced by ParisBlockMPC::computeReceive(), BasicDistributionLibrary::computeReceive(), and ParisBlock::computeReceive().

105  {
106  switch(mode) {
107  case PaCO::none: cerr << "INTERNAL ERROR: " << __FILE__ << " " << __FUNCTION__ << endl; return 0;
108  case PaCO::ClientSide: return 1;
109  case PaCO::ServerSide:
110  {
111  unsigned int nvdarray = stotal/dtotal;
112  unsigned int remaining = (nvdarray*dtotal + drank < stotal)?1:0;
113  nvdarray += remaining;
114  if ( nvdarray == 0 ) return 1; // alway at least one
115  return nvdarray;
116  }
117  case PaCO::CommSide: cerr << "INTERNAL ERROR: not yet implemented in " << __FILE__ << " " << __FUNCTION__ << endl; return 0;
118  }
119  return 0;
120 }

◆ posofPart()

unsigned posofPart ( const PaCO::distLoc_t mode,
const unsigned  dtotal,
const unsigned  srank 
)

Definition at line 122 of file PC/ServerSide.cc.

References PaCO::ClientSide, PaCO::CommSide, PaCO::none, and PaCO::ServerSide.

Referenced by ParisBlockMPC::computeReceive(), BasicDistributionLibrary::computeReceive(), and ParisBlock::computeReceive().

122  {
123  switch(mode) {
124  case PaCO::none: cerr << "INTERNAL ERROR: " << __FILE__ << " " << __FUNCTION__ << endl; return 0;
125  case PaCO::ClientSide: return 0;
126  case PaCO::ServerSide: return srank / dtotal;
127  case PaCO::CommSide: cerr << "INTERNAL ERROR: not yet implemented in " << __FILE__ << " " << __FUNCTION__ << endl; return 0;
128  }
129  return 0;
130 }