PaCO++  0.05
ParisBlockMPC.cc
Go to the documentation of this file.
1 #include "ParisBlockMPC.h"
2 
3 #include "Schedule.h"
4 
6  setFabric(f);
7  _darray = f->creer();
8  _vdarray = f->vcreer();
9  _vdarray->clear();
10 
11  _clttopo.total = 123; // debug
12  _srvtopo.total = 123; // debug
13 }
14 
16  delete _fab; delete _darray; delete _vdarray;
17 }
18 
19 void ParisBlockMPC::setFabric(Fabrique* f) { _fab = f; }
20 
21 void ParisBlockMPC::reset() { _vdarray->clear(); }
22 
23 const PaCO::distLoc_t& ParisBlockMPC::getMode() const { return _mode; }
24 
25 bool ParisBlockMPC::setMode(const PaCO::distLoc_t mode) { _mode = mode; return true; } // true if ok
26 
27 bool ParisBlockMPC::setClientConfiguration(const PaCO::PacoTopology_t & ctopo) { _clttopo = ctopo; return true; }
28 bool ParisBlockMPC::setServerConfiguration(const PaCO::PacoTopology_t & stopo) { _srvtopo = stopo; return true; }
29 
32  _ld.rank = ld.rank;
33  _ld.start = ld.start;
34  _ld.len = ld.len;
35  return true;
36 }
37 
38 void ParisBlockMPC::computeSend(const void* data, vAbstrait& vdarray, vector<unsigned>& destid) {
39  _ld.base = (char*) data;
40 
41  computeSendDataBlock1D(_gd, _ld, _clttopo, _srvtopo, vdarray, destid, _mode, _comm);
42 }
43 
44 bool ParisBlockMPC::computeReceive(Abstrait* darray) {
45 
46  this->setClientConfiguration(darray->topo());
47 
48  // Get the mode of the client
49  this->setMode(darray->mode());
50 
51  unsigned nb = nbofPart(_mode, _clttopo.total, _srvtopo.total, _ld.rank);
52 
53  unsigned pos;
54 
55  // In server side redistribution, empty dist for server nodes whose id > max client node
56  if (darray->dist().length() != 0 ) {
57  pos = posofPart(_mode, _srvtopo.total, darray->dist()[0].rank);
58  } else {
59  pos = 0;
60  }
61 
62  // Initialize _vdarray & remaining (assumed clean)
63  if (_vdarray->size() == 0) {
64  // _vdarray is empty: so let's define its size
65  _vdarray->size(nb);
66  _remaining = nb;
67  }
68 
69 
70  fprintf(stderr, "computeReceive: Node %d : set entry %d/%d to %p\n", _ld.rank, pos, nb, darray);
71  _vdarray->setAbstrait(pos, darray);
72  _remaining--;
73 
74  fprintf(stderr, "computeReceive: Node %d : got %d of %d data\n", _ld.rank, _vdarray->size() - _remaining, _vdarray->size());
75 
76  if (_remaining == 0) {
78  return true;
79  } else {
80  return false;
81  }
82 }
83 
84 Abstrait* ParisBlockMPC::getResult() const { return _darray; }
ParisBlockMPC(Fabrique *f)
Definition: ParisBlockMPC.cc:5
bool computeReceive(Abstrait *darray)
Compute communication schedule on the server side.
LocalData_t _ld
Definition: ParisBlockMPC.h:16
PaCO::distLoc_t _mode
Definition: ParisBlockMPC.h:10
bool computeReceiveDataBlock1D(vAbstrait *sdata, const PaCO::distLoc_t &mode, const unsigned total, const unsigned rank, const ParisBlock_param_t *param, Abstrait *varray, void *comm)
Definition: ServerSide.cc:151
bool setServerConfiguration(const PaCO::PacoTopology_t &stopo)
PaCO::PacoTopology_t _clttopo
Definition: ParisBlockMPC.h:11
Abstrait * getResult() const
If computeReceive returns ok, get the data.
bool setLocalDataConfiguration(const PaCO::PacoLocalData_t &ld)
virtual ~ParisBlockMPC()
unsigned nbofPart(const PaCO::distLoc_t &mode, const unsigned stotal, const unsigned dtotal, const unsigned drank)
Definition: ServerSide.cc:120
vAbstrait * _vdarray
Definition: ParisBlockMPC.h:22
Fabrique * _fab
Definition: ParisBlockMPC.h:20
bool setGlobalDataConfiguration(const PaCO::PacoGlobalData_t &gd)
distLoc_t
Definition: PaCO++.idl:12
void computeSendDataBlock1D(const GlobalData_t &gd, const LocalData_t &sd, const Topology_t &stopo, const Topology_t &dtopo, const ParisBlock_param_t *param, vAbstrait &vdarray, vector< unsigned > &destid, const PaCO::distLoc_t &mode, void *comm)
Definition: ClientSide.cc:215
void setFabric(Fabrique *f)
unsigned long total
Definition: PaCO++.idl:35
void computeSend(const void *data, vAbstrait &vdarray, vector< unsigned > &destid)
Compute communication schedule on the client side.
const PaCO::distLoc_t & getMode() const
PaCO::PacoGlobalData_t _gd
Definition: ParisBlockMPC.h:13
PaCO::PacoTopology_t _srvtopo
Definition: ParisBlockMPC.h:12
unsigned posofPart(const PaCO::distLoc_t &mode, const unsigned dtotal, const unsigned srank)
Definition: ServerSide.cc:138
unsigned long start
Definition: PaCO++.idl:27
bool setClientConfiguration(const PaCO::PacoTopology_t &ctopo)
unsigned long rank
Definition: PaCO++.idl:26
bool setMode(const PaCO::distLoc_t mode)
unsigned long len
Definition: PaCO++.idl:28
Abstrait * _darray
Definition: ParisBlockMPC.h:21