PaCO++  0.05
GaBro Class Reference

#include <GaBro.h>

Inheritance diagram for GaBro:
Inheritance graph
Collaboration diagram for GaBro:
Collaboration graph

Classes

struct  info_t
 

Public Member Functions

virtual void clientFree ()
 
virtual PieceToSendcomputePiecesToSend (unsigned &size)
 
virtual bool freeComId (long id)
 
 GaBro ()
 
virtual void * getClientData (void *pid, int server_node, long &size, long &length, bool &end)
 
virtual void * getDescr ()
 
virtual PaCO::PacoTopology_t getDestTopology ()
 
virtual long getNodeRank ()
 
virtual void * getServerData (long &length)
 
virtual PaCO::PacoTopology_t getSourceTopology ()
 
virtual bool insertData (void *rcptBuf, unsigned long element_nb)
 
virtual void serverFree ()
 
virtual bool setComId (long id)
 
virtual void setCommunicator (void *group)
 
virtual void setDataPtr (void *dataPtr)
 
virtual void setDescr (void *descr)
 
virtual void setDestTopology (PaCO::PacoTopology_t topo)
 
void setEltSize (long size)
 
void setNodeNbElt (long elt_node_nb)
 
void setNodePos (long node_pos)
 
virtual void setNodeRank (long Rank)
 
virtual void setSourceTopology (PaCO::PacoTopology_t topo)
 
void setTotalNbElt (long elt_nb)
 
virtual ~GaBro ()
 

Private Types

typedef map< long, info_t * > info_list_map_t
 

Private Attributes

char * _client_buffer
 
long _cur_id
 
info_t_cur_info
 
long _current_data_size
 
long _current_pos
 
int _current_rcp
 
long _data_elt_nb
 
long _data_size
 
GaBroLib::GaBroDescr _descr
 
PaCO::PacoTopology_t _destTopo
 
long _elt_node_nb
 
info_list_map_t _info_list_map
 
long _my_rank
 
long * _nb_rcp
 
long _node_data_nb
 
long _node_pos
 
int * _pos
 
char * _server_buffer
 
long _server_nb_nodes
 
PaCO::PacoTopology_t _srcTopo
 
long _total_data_nb
 

Detailed Description

Definition at line 9 of file GaBro.h.

Member Typedef Documentation

◆ info_list_map_t

typedef map<long, info_t*> GaBro::info_list_map_t
private

Definition at line 74 of file GaBro.h.

Constructor & Destructor Documentation

◆ GaBro()

GaBro::GaBro ( )

Definition at line 4 of file GaBro.cc.

References _client_buffer, _current_data_size, _current_pos, _current_rcp, _data_elt_nb, _data_size, _elt_node_nb, _my_rank, _nb_rcp, _node_data_nb, _node_pos, _pos, _server_buffer, _server_nb_nodes, _total_data_nb, and setComId().

5 {
6  // Common
7  _data_size = -1;
8  _data_elt_nb = -1;
9  _my_rank = 0;
10  _server_nb_nodes = 1;
11 
12  // Client side
13  _client_buffer = NULL;
14  _pos = NULL;
15  _elt_node_nb = -1;
16  _node_pos = -1;
17 
18  this->setComId(-1);
19 
20  // Server side
21  _server_buffer = NULL;
22  _nb_rcp = NULL;
23  _current_rcp = -1;
24  _total_data_nb = -1;
25  _node_data_nb = -1;
26  _current_data_size = -1;
27  _current_pos = -1;
28 }
long * _nb_rcp
Definition: GaBro.h:82
long _my_rank
Definition: GaBro.h:57
long _server_nb_nodes
Definition: GaBro.h:58
long _data_elt_nb
Definition: GaBro.h:56
char * _server_buffer
Definition: GaBro.h:81
long _node_pos
Definition: GaBro.h:64
char * _client_buffer
Definition: GaBro.h:61
long _current_data_size
Definition: GaBro.h:87
long _current_pos
Definition: GaBro.h:84
long _elt_node_nb
Definition: GaBro.h:63
int * _pos
Definition: GaBro.h:62
int _current_rcp
Definition: GaBro.h:83
virtual bool setComId(long id)
Definition: GaBro.cc:266
long _data_size
Definition: GaBro.h:55
long _total_data_nb
Definition: GaBro.h:85
long _node_data_nb
Definition: GaBro.h:86
Here is the call graph for this function:

◆ ~GaBro()

GaBro::~GaBro ( )
virtual

Definition at line 30 of file GaBro.cc.

References _info_list_map, _nb_rcp, and _pos.

31 {
32  delete _pos;
33  delete _nb_rcp;
34  for(info_list_map_t::iterator it=_info_list_map.begin(); it!=_info_list_map.end(); ++it)
35  {
36  info_t* info = it->second;
37  delete info;
38  _info_list_map.erase(it);
39  }
40  _info_list_map.clear();
41 }
long * _nb_rcp
Definition: GaBro.h:82
info_list_map_t _info_list_map
Definition: GaBro.h:75
int * _pos
Definition: GaBro.h:62

Member Function Documentation

◆ clientFree()

void GaBro::clientFree ( )
virtual

Implements DistributionLibrary.

Definition at line 181 of file GaBro.cc.

References _pos, and _server_nb_nodes.

182 {
183  for (int i=0; i<_server_nb_nodes; i++)
184  {
185  _pos[i] = 0;
186  }
187 }
long _server_nb_nodes
Definition: GaBro.h:58
int * _pos
Definition: GaBro.h:62

◆ computePiecesToSend()

PieceToSend * GaBro::computePiecesToSend ( unsigned &  size)
virtual

Implements DistributionLibrary.

Definition at line 122 of file GaBro.cc.

References _data_size, _elt_node_nb, _my_rank, _server_nb_nodes, PieceToSend::destNode, PieceToSend::size, and PieceToSend::sourceNode.

123 {
124  size = _server_nb_nodes;
125  // Compute total data length
126  long total_length = _data_size * _elt_node_nb;
127  // We send at each server node the same data
128  PieceToSend * local_vector = new PieceToSend[_server_nb_nodes];
129  for (int i = 0; i < _server_nb_nodes; i++)
130  {
131  local_vector[i].sourceNode = _my_rank;
132  local_vector[i].destNode = i;
133  local_vector[i].size = total_length;
134  }
135  return local_vector;
136 }
long _my_rank
Definition: GaBro.h:57
long _server_nb_nodes
Definition: GaBro.h:58
long _elt_node_nb
Definition: GaBro.h:63
long _data_size
Definition: GaBro.h:55

◆ freeComId()

bool GaBro::freeComId ( long  id)
virtual

Reimplemented from DistributionLibrary.

Definition at line 301 of file GaBro.cc.

References _cur_id, and _info_list_map.

302 {
303  if (id == -1) {
304  // cerr << "freeComId: not allowed to free com id -1 (ignoring)\n";
305  return true;
306  }
307  if (_cur_id == id) {
308  // cerr << "freeComId: not allowed to free current com (ignoring)\n";
309  return true;
310  }
311  // cerr << "freeComid: communication id: "<<id<<endl;
312  info_list_map_t::iterator it = _info_list_map.find(id);
313  if (it != _info_list_map.end() )
314  {
315  info_t* info = it->second;
316  delete info;
317  _info_list_map.erase(it);
318  }
319  return true;
320 }
long _cur_id
Definition: GaBro.h:77
info_list_map_t _info_list_map
Definition: GaBro.h:75

◆ getClientData()

void * GaBro::getClientData ( void *  pid,
int  server_node,
long &  size,
long &  length,
bool &  end 
)
virtual

Implements DistributionLibrary.

Definition at line 145 of file GaBro.cc.

References _client_buffer, _data_size, _descr, _elt_node_nb, _pos, and GaBroLib::GaBroDescr::current_data_size.

146 {
147  void * result = NULL;
148  end = true;
149  //std:cerr << _data_size << " " << _data_elt_nb << " " << _pos[server_node] << endl;
150  long rst_data = (_data_size * _elt_node_nb) - _pos[server_node];
151  //std:cerr << "Size : " << size << endl;
152  //std:cerr << "Rst_data : " << rst_data << endl;
153  if (size == rst_data)
154  {
155  length = size / _data_size;
156  _descr.current_data_size = size;
157  result = (void *)&_client_buffer[_pos[server_node]];
158  _pos[server_node] = _pos[server_node] + size;
159  size = 0;
160  }
161  else if (size > rst_data)
162  {
163  length = rst_data / _data_size;
164  _descr.current_data_size = rst_data;
165  result = (void *)&_client_buffer[_pos[server_node]];
166  _pos[server_node] = _pos[server_node] + rst_data;
167  size = size - rst_data;
168  }
169  else if (size < rst_data)
170  {
171  length = size / _data_size;
172  _descr.current_data_size = size;
173  result = (void *)&_client_buffer[_pos[server_node]];
174  _pos[server_node] = _pos[server_node] + size;
175  size = 0;
176  }
177  return result;
178 }
char * _client_buffer
Definition: GaBro.h:61
long _elt_node_nb
Definition: GaBro.h:63
int * _pos
Definition: GaBro.h:62
GaBroLib::GaBroDescr _descr
Definition: GaBro.h:52
long _data_size
Definition: GaBro.h:55

◆ getDescr()

void * GaBro::getDescr ( )
virtual

Implements DistributionLibrary.

Definition at line 190 of file GaBro.cc.

References _descr.

191 {
192  return &_descr;
193 }
GaBroLib::GaBroDescr _descr
Definition: GaBro.h:52

◆ getDestTopology()

PaCO::PacoTopology_t GaBro::getDestTopology ( )
virtual

Implements DistributionLibrary.

Definition at line 74 of file GaBro.cc.

References _destTopo.

75 {
76  return _destTopo;
77 }
PaCO::PacoTopology_t _destTopo
Definition: GaBro.h:49

◆ getNodeRank()

long GaBro::getNodeRank ( )
virtual

Implements DistributionLibrary.

Definition at line 87 of file GaBro.cc.

References _my_rank.

88 {
89  return _my_rank;
90 }
long _my_rank
Definition: GaBro.h:57

◆ getServerData()

void * GaBro::getServerData ( long &  length)
virtual

Implements DistributionLibrary.

Definition at line 227 of file GaBro.cc.

References _server_buffer, and _total_data_nb.

228 {
229  length = _total_data_nb;
230  return _server_buffer;
231 }
char * _server_buffer
Definition: GaBro.h:81
long _total_data_nb
Definition: GaBro.h:85

◆ getSourceTopology()

PaCO::PacoTopology_t GaBro::getSourceTopology ( )
virtual

Implements DistributionLibrary.

Definition at line 55 of file GaBro.cc.

References _srcTopo.

56 {
57  return _srcTopo;
58 }
PaCO::PacoTopology_t _srcTopo
Definition: GaBro.h:48

◆ insertData()

bool GaBro::insertData ( void *  rcptBuf,
unsigned long  element_nb 
)
virtual

Implements DistributionLibrary.

Definition at line 196 of file GaBro.cc.

References _current_data_size, _current_pos, _current_rcp, _data_size, _nb_rcp, _node_data_nb, _server_buffer, _srcTopo, _total_data_nb, and PaCO::PacoTopology_s::total.

197 {
198 
199  bool ret = true;
200  if (element_nb != 0)
201  {
202  if (_server_buffer == NULL)
203  {
204  _server_buffer = (char *)malloc(_data_size * _total_data_nb);
205  }
206  // Copy the buffer !!!
207 // cerr << "current_pos : " << _current_pos << endl;
208 // cerr << "data_size : " << _data_size << endl;
209 // cerr << "nb_rcp[_current_rcp] " << _nb_rcp[_current_rcp] << endl;
210 
211  long current_sender_pos = (_current_pos * _data_size) + ((_data_size * _node_data_nb) - _nb_rcp[_current_rcp]);
212 // cerr << "current_sender_pos : " << current_sender_pos << endl;
213  memcpy((void *)&(_server_buffer[current_sender_pos]), rcptBuf, _current_data_size);
215  }
216  for (unsigned int i=0; i<_srcTopo.total; i++)
217  {
218  if (_nb_rcp[i] != 0)
219  {
220  ret = false;
221  }
222  }
223  return ret;
224 }
long * _nb_rcp
Definition: GaBro.h:82
char * _server_buffer
Definition: GaBro.h:81
long _current_data_size
Definition: GaBro.h:87
PaCO::PacoTopology_t _srcTopo
Definition: GaBro.h:48
long _current_pos
Definition: GaBro.h:84
unsigned long total
Definition: PaCO++.idl:35
int _current_rcp
Definition: GaBro.h:83
long _data_size
Definition: GaBro.h:55
long _total_data_nb
Definition: GaBro.h:85
long _node_data_nb
Definition: GaBro.h:86

◆ serverFree()

void GaBro::serverFree ( )
virtual

Implements DistributionLibrary.

Definition at line 254 of file GaBro.cc.

References _current_pos, _current_rcp, _nb_rcp, _server_buffer, _srcTopo, and PaCO::PacoTopology_s::total.

255 {
256  _current_rcp = -1;
257  _current_pos = -1;
258  _server_buffer = NULL;
259  for (unsigned int i=0; i<_srcTopo.total; i++)
260  {
261  _nb_rcp[i] = -1;
262  }
263 }
long * _nb_rcp
Definition: GaBro.h:82
char * _server_buffer
Definition: GaBro.h:81
PaCO::PacoTopology_t _srcTopo
Definition: GaBro.h:48
long _current_pos
Definition: GaBro.h:84
unsigned long total
Definition: PaCO++.idl:35
int _current_rcp
Definition: GaBro.h:83

◆ setComId()

bool GaBro::setComId ( long  id)
virtual

Reimplemented from DistributionLibrary.

Definition at line 266 of file GaBro.cc.

References _cur_id, _cur_info, _data_elt_nb, GaBro::info_t::_data_elt_nb, _data_size, GaBro::info_t::_data_size, _descr, _elt_node_nb, GaBro::info_t::_elt_node_nb, _info_list_map, _node_pos, GaBro::info_t::_node_pos, _server_nb_nodes, GaBro::info_t::_server_nb_nodes, GaBroLib::GaBroDescr::node_data_nb, GaBroLib::GaBroDescr::node_position, and GaBroLib::GaBroDescr::total_data_nb.

Referenced by GaBro().

267 {
268  info_t * _infolists;
269  info_list_map_t::iterator it = _info_list_map.find(id);
270  if (it == _info_list_map.end())
271  {
272  _infolists = new info_t();
273  _infolists->_data_size = _data_size;
274  _infolists->_elt_node_nb = _elt_node_nb;
275  _infolists->_server_nb_nodes = _server_nb_nodes;
276  _infolists->_data_elt_nb = _data_elt_nb;
277  _infolists->_node_pos = _node_pos;
278  _info_list_map[id] = _infolists;
279  }
280  else
281  {
282  _infolists = it->second;
283  }
284  _cur_info = _infolists;
285  _cur_id = id;
286  _data_size = _infolists->_data_size;
287  _elt_node_nb = _infolists->_elt_node_nb;
288  _data_elt_nb = _infolists->_data_elt_nb;
289  _server_nb_nodes = _infolists->_server_nb_nodes;
290  _node_pos = _infolists->_node_pos;
291 
295 
296  //std:cerr << _data_size << " " << _elt_node_nb << " " << _server_nb_nodes <<endl;
297  return true;
298 }
long _cur_id
Definition: GaBro.h:77
info_list_map_t _info_list_map
Definition: GaBro.h:75
long _server_nb_nodes
Definition: GaBro.h:58
long _data_elt_nb
Definition: GaBro.h:56
long _node_pos
Definition: GaBro.h:64
long _elt_node_nb
Definition: GaBro.h:63
info_t * _cur_info
Definition: GaBro.h:78
GaBroLib::GaBroDescr _descr
Definition: GaBro.h:52
long _data_size
Definition: GaBro.h:55

◆ setCommunicator()

virtual void GaBro::setCommunicator ( void *  group)
inlinevirtual

Implements DistributionLibrary.

Definition at line 22 of file GaBro.h.

22 {}

◆ setDataPtr()

void GaBro::setDataPtr ( void *  dataPtr)
virtual

Implements DistributionLibrary.

Definition at line 139 of file GaBro.cc.

References _client_buffer.

140 {
141  _client_buffer = (char *) dataPtr;
142 }
char * _client_buffer
Definition: GaBro.h:61

◆ setDescr()

void GaBro::setDescr ( void *  descr)
virtual

Implements DistributionLibrary.

Definition at line 234 of file GaBro.cc.

References _current_data_size, _current_pos, _current_rcp, _data_size, _descr, _nb_rcp, _node_data_nb, _total_data_nb, GaBroLib::GaBroDescr::current_data_size, GaBroLib::GaBroDescr::node_data_nb, GaBroLib::GaBroDescr::node_position, GaBroLib::GaBroDescr::sender, and GaBroLib::GaBroDescr::total_data_nb.

235 {
236  _descr = *((GaBroLib::GaBroDescr*) descr);
237  if (_current_rcp == -1)
238  {
239  // First piece reception !
241  }
246  //std:cerr << _current_data_size << endl;
247  if (_nb_rcp[_current_rcp] == -1)
248  {
250  }
251 }
long * _nb_rcp
Definition: GaBro.h:82
long _current_data_size
Definition: GaBro.h:87
long _current_pos
Definition: GaBro.h:84
int _current_rcp
Definition: GaBro.h:83
GaBroLib::GaBroDescr _descr
Definition: GaBro.h:52
long _data_size
Definition: GaBro.h:55
long _total_data_nb
Definition: GaBro.h:85
long _node_data_nb
Definition: GaBro.h:86

◆ setDestTopology()

void GaBro::setDestTopology ( PaCO::PacoTopology_t  topo)
virtual

Implements DistributionLibrary.

Definition at line 61 of file GaBro.cc.

References _destTopo, _pos, _server_nb_nodes, and PaCO::PacoTopology_s::total.

62 {
63  _destTopo = topo;
64  _server_nb_nodes = topo.total;
65  // _cur_info->_server_nb_nodes = _server_nb_nodes;
66  _pos = new int[_server_nb_nodes];
67  for (int i=0; i<_server_nb_nodes; i++)
68  {
69  _pos[i] = 0;
70  }
71 }
long _server_nb_nodes
Definition: GaBro.h:58
PaCO::PacoTopology_t _destTopo
Definition: GaBro.h:49
int * _pos
Definition: GaBro.h:62
unsigned long total
Definition: PaCO++.idl:35

◆ setEltSize()

void GaBro::setEltSize ( long  size)

Definition at line 93 of file GaBro.cc.

References _data_size.

94 {
95  _data_size = size;
96  // _cur_info->_data_size = _data_size;
97 }
long _data_size
Definition: GaBro.h:55

◆ setNodeNbElt()

void GaBro::setNodeNbElt ( long  elt_node_nb)

Definition at line 107 of file GaBro.cc.

References _descr, _elt_node_nb, and GaBroLib::GaBroDescr::node_data_nb.

108 {
109  _elt_node_nb = elt_node_nb;
110  // _cur_info->_elt_node_nb = _elt_node_nb;
112 }
long _elt_node_nb
Definition: GaBro.h:63
GaBroLib::GaBroDescr _descr
Definition: GaBro.h:52

◆ setNodePos()

void GaBro::setNodePos ( long  node_pos)

Definition at line 115 of file GaBro.cc.

References _descr, _node_pos, and GaBroLib::GaBroDescr::node_position.

116 {
117  _node_pos = node_pos;
119 }
long _node_pos
Definition: GaBro.h:64
GaBroLib::GaBroDescr _descr
Definition: GaBro.h:52

◆ setNodeRank()

void GaBro::setNodeRank ( long  Rank)
virtual

Implements DistributionLibrary.

Definition at line 80 of file GaBro.cc.

References _descr, _my_rank, and GaBroLib::GaBroDescr::sender.

81 {
82  _my_rank = Rank;
83  _descr.sender = Rank;
84 }
long _my_rank
Definition: GaBro.h:57
GaBroLib::GaBroDescr _descr
Definition: GaBro.h:52

◆ setSourceTopology()

void GaBro::setSourceTopology ( PaCO::PacoTopology_t  topo)
virtual

Implements DistributionLibrary.

Definition at line 44 of file GaBro.cc.

References _nb_rcp, _srcTopo, and PaCO::PacoTopology_s::total.

45 {
46  _srcTopo = topo;
47  _nb_rcp = new long[_srcTopo.total];
48  for (unsigned int i=0; i<_srcTopo.total; i++)
49  {
50  _nb_rcp[i] = -1;
51  }
52 }
long * _nb_rcp
Definition: GaBro.h:82
PaCO::PacoTopology_t _srcTopo
Definition: GaBro.h:48
unsigned long total
Definition: PaCO++.idl:35

◆ setTotalNbElt()

void GaBro::setTotalNbElt ( long  elt_nb)

Definition at line 100 of file GaBro.cc.

References _data_elt_nb, _descr, and GaBroLib::GaBroDescr::total_data_nb.

101 {
102  _data_elt_nb = elt_nb;
104 }
long _data_elt_nb
Definition: GaBro.h:56
GaBroLib::GaBroDescr _descr
Definition: GaBro.h:52

Member Data Documentation

◆ _client_buffer

char* GaBro::_client_buffer
private

Definition at line 61 of file GaBro.h.

Referenced by GaBro(), getClientData(), and setDataPtr().

◆ _cur_id

long GaBro::_cur_id
private

Definition at line 77 of file GaBro.h.

Referenced by freeComId(), and setComId().

◆ _cur_info

info_t* GaBro::_cur_info
private

Definition at line 78 of file GaBro.h.

Referenced by setComId().

◆ _current_data_size

long GaBro::_current_data_size
private

Definition at line 87 of file GaBro.h.

Referenced by GaBro(), insertData(), and setDescr().

◆ _current_pos

long GaBro::_current_pos
private

Definition at line 84 of file GaBro.h.

Referenced by GaBro(), insertData(), serverFree(), and setDescr().

◆ _current_rcp

int GaBro::_current_rcp
private

Definition at line 83 of file GaBro.h.

Referenced by GaBro(), insertData(), serverFree(), and setDescr().

◆ _data_elt_nb

long GaBro::_data_elt_nb
private

Definition at line 56 of file GaBro.h.

Referenced by GaBro(), setComId(), and setTotalNbElt().

◆ _data_size

long GaBro::_data_size
private

◆ _descr

GaBroLib::GaBroDescr GaBro::_descr
private

◆ _destTopo

PaCO::PacoTopology_t GaBro::_destTopo
private

Definition at line 49 of file GaBro.h.

Referenced by getDestTopology(), and setDestTopology().

◆ _elt_node_nb

long GaBro::_elt_node_nb
private

Definition at line 63 of file GaBro.h.

Referenced by computePiecesToSend(), GaBro(), getClientData(), setComId(), and setNodeNbElt().

◆ _info_list_map

info_list_map_t GaBro::_info_list_map
private

Definition at line 75 of file GaBro.h.

Referenced by freeComId(), setComId(), and ~GaBro().

◆ _my_rank

long GaBro::_my_rank
private

Definition at line 57 of file GaBro.h.

Referenced by computePiecesToSend(), GaBro(), getNodeRank(), and setNodeRank().

◆ _nb_rcp

long* GaBro::_nb_rcp
private

Definition at line 82 of file GaBro.h.

Referenced by GaBro(), insertData(), serverFree(), setDescr(), setSourceTopology(), and ~GaBro().

◆ _node_data_nb

long GaBro::_node_data_nb
private

Definition at line 86 of file GaBro.h.

Referenced by GaBro(), insertData(), and setDescr().

◆ _node_pos

long GaBro::_node_pos
private

Definition at line 64 of file GaBro.h.

Referenced by GaBro(), setComId(), and setNodePos().

◆ _pos

int* GaBro::_pos
private

Definition at line 62 of file GaBro.h.

Referenced by clientFree(), GaBro(), getClientData(), setDestTopology(), and ~GaBro().

◆ _server_buffer

char* GaBro::_server_buffer
private

Definition at line 81 of file GaBro.h.

Referenced by GaBro(), getServerData(), insertData(), and serverFree().

◆ _server_nb_nodes

long GaBro::_server_nb_nodes
private

Definition at line 58 of file GaBro.h.

Referenced by clientFree(), computePiecesToSend(), GaBro(), setComId(), and setDestTopology().

◆ _srcTopo

PaCO::PacoTopology_t GaBro::_srcTopo
private

Definition at line 48 of file GaBro.h.

Referenced by getSourceTopology(), insertData(), serverFree(), and setSourceTopology().

◆ _total_data_nb

long GaBro::_total_data_nb
private

Definition at line 85 of file GaBro.h.

Referenced by GaBro(), getServerData(), insertData(), and setDescr().


The documentation for this class was generated from the following files: