|
PaCO++
0.05
|
#include <GaBro.h>


Classes | |
| struct | info_t |
Public Member Functions | |
| virtual void | clientFree () |
| virtual PieceToSend * | computePiecesToSend (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 |
typedef map<long, info_t*> GaBro::info_list_map_t [private] |
| 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().
{
// Common
_data_size = -1;
_data_elt_nb = -1;
_my_rank = 0;
_server_nb_nodes = 1;
// Client side
_client_buffer = NULL;
_pos = NULL;
_elt_node_nb = -1;
_node_pos = -1;
this->setComId(-1);
// Server side
_server_buffer = NULL;
_nb_rcp = NULL;
_current_rcp = -1;
_total_data_nb = -1;
_node_data_nb = -1;
_current_data_size = -1;
_current_pos = -1;
}

| GaBro::~GaBro | ( | ) | [virtual] |
Definition at line 30 of file GaBro.cc.
References _info_list_map, _nb_rcp, and _pos.
{
delete _pos;
delete _nb_rcp;
for(info_list_map_t::iterator it=_info_list_map.begin(); it!=_info_list_map.end(); ++it)
{
info_t* info = it->second;
delete info;
_info_list_map.erase(it);
}
_info_list_map.clear();
}
| void GaBro::clientFree | ( | ) | [virtual] |
Implements DistributionLibrary.
Definition at line 181 of file GaBro.cc.
References _pos, and _server_nb_nodes.
{
for (int i=0; i<_server_nb_nodes; i++)
{
_pos[i] = 0;
}
}
| 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.
{
size = _server_nb_nodes;
// Compute total data length
long total_length = _data_size * _elt_node_nb;
// We send at each server node the same data
PieceToSend * local_vector = new PieceToSend[_server_nb_nodes];
for (int i = 0; i < _server_nb_nodes; i++)
{
local_vector[i].sourceNode = _my_rank;
local_vector[i].destNode = i;
local_vector[i].size = total_length;
}
return local_vector;
}
| bool GaBro::freeComId | ( | long | id | ) | [virtual] |
Reimplemented from DistributionLibrary.
Definition at line 301 of file GaBro.cc.
References _cur_id, and _info_list_map.
{
if (id == -1) {
// cerr << "freeComId: not allowed to free com id -1 (ignoring)\n";
return true;
}
if (_cur_id == id) {
// cerr << "freeComId: not allowed to free current com (ignoring)\n";
return true;
}
// cerr << "freeComid: communication id: "<<id<<endl;
info_list_map_t::iterator it = _info_list_map.find(id);
if (it != _info_list_map.end() )
{
info_t* info = it->second;
delete info;
_info_list_map.erase(it);
}
return true;
}
| 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.
{
void * result = NULL;
end = true;
//std:cerr << _data_size << " " << _data_elt_nb << " " << _pos[server_node] << endl;
long rst_data = (_data_size * _elt_node_nb) - _pos[server_node];
//std:cerr << "Size : " << size << endl;
//std:cerr << "Rst_data : " << rst_data << endl;
if (size == rst_data)
{
length = size / _data_size;
_descr.current_data_size = size;
result = (void *)&_client_buffer[_pos[server_node]];
_pos[server_node] = _pos[server_node] + size;
size = 0;
}
else if (size > rst_data)
{
length = rst_data / _data_size;
_descr.current_data_size = rst_data;
result = (void *)&_client_buffer[_pos[server_node]];
_pos[server_node] = _pos[server_node] + rst_data;
size = size - rst_data;
}
else if (size < rst_data)
{
length = size / _data_size;
_descr.current_data_size = size;
result = (void *)&_client_buffer[_pos[server_node]];
_pos[server_node] = _pos[server_node] + size;
size = 0;
}
return result;
}
| void * GaBro::getDescr | ( | ) | [virtual] |
Implements DistributionLibrary.
Definition at line 190 of file GaBro.cc.
References _descr.
{
return &_descr;
}
| PaCO::PacoTopology_t GaBro::getDestTopology | ( | ) | [virtual] |
Implements DistributionLibrary.
Definition at line 74 of file GaBro.cc.
References _destTopo.
{
return _destTopo;
}
| long GaBro::getNodeRank | ( | ) | [virtual] |
Implements DistributionLibrary.
Definition at line 87 of file GaBro.cc.
References _my_rank.
{
return _my_rank;
}
| void * GaBro::getServerData | ( | long & | length | ) | [virtual] |
Implements DistributionLibrary.
Definition at line 227 of file GaBro.cc.
References _server_buffer, and _total_data_nb.
{
length = _total_data_nb;
return _server_buffer;
}
| PaCO::PacoTopology_t GaBro::getSourceTopology | ( | ) | [virtual] |
Implements DistributionLibrary.
Definition at line 55 of file GaBro.cc.
References _srcTopo.
{
return _srcTopo;
}
| 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.
{
bool ret = true;
if (element_nb != 0)
{
if (_server_buffer == NULL)
{
_server_buffer = (char *)malloc(_data_size * _total_data_nb);
}
// Copy the buffer !!!
// cerr << "current_pos : " << _current_pos << endl;
// cerr << "data_size : " << _data_size << endl;
// cerr << "nb_rcp[_current_rcp] " << _nb_rcp[_current_rcp] << endl;
long current_sender_pos = (_current_pos * _data_size) + ((_data_size * _node_data_nb) - _nb_rcp[_current_rcp]);
// cerr << "current_sender_pos : " << current_sender_pos << endl;
memcpy((void *)&(_server_buffer[current_sender_pos]), rcptBuf, _current_data_size);
_nb_rcp[_current_rcp] = _nb_rcp[_current_rcp] - _current_data_size;
}
for (unsigned int i=0; i<_srcTopo.total; i++)
{
if (_nb_rcp[i] != 0)
{
ret = false;
}
}
return ret;
}
| 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.
{
_current_rcp = -1;
_current_pos = -1;
_server_buffer = NULL;
for (unsigned int i=0; i<_srcTopo.total; i++)
{
_nb_rcp[i] = -1;
}
}
| 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().
{
info_t * _infolists;
info_list_map_t::iterator it = _info_list_map.find(id);
if (it == _info_list_map.end())
{
_infolists = new info_t();
_infolists->_data_size = _data_size;
_infolists->_elt_node_nb = _elt_node_nb;
_infolists->_server_nb_nodes = _server_nb_nodes;
_infolists->_data_elt_nb = _data_elt_nb;
_infolists->_node_pos = _node_pos;
_info_list_map[id] = _infolists;
}
else
{
_infolists = it->second;
}
_cur_info = _infolists;
_cur_id = id;
_data_size = _infolists->_data_size;
_elt_node_nb = _infolists->_elt_node_nb;
_data_elt_nb = _infolists->_data_elt_nb;
_server_nb_nodes = _infolists->_server_nb_nodes;
_node_pos = _infolists->_node_pos;
_descr.node_position = _node_pos;
_descr.total_data_nb = _data_elt_nb;
_descr.node_data_nb = _elt_node_nb;
//std:cerr << _data_size << " " << _elt_node_nb << " " << _server_nb_nodes <<endl;
return true;
}
| virtual void GaBro::setCommunicator | ( | void * | group | ) | [inline, virtual] |
| void GaBro::setDataPtr | ( | void * | dataPtr | ) | [virtual] |
Implements DistributionLibrary.
Definition at line 139 of file GaBro.cc.
References _client_buffer.
{
_client_buffer = (char *) dataPtr;
}
| 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.
{
_descr = *((GaBroLib::GaBroDescr*) descr);
if (_current_rcp == -1)
{
// First piece reception !
_total_data_nb = _descr.total_data_nb;
}
_current_rcp = _descr.sender;
_current_pos = _descr.node_position;
_node_data_nb = _descr.node_data_nb;
_current_data_size = _descr.current_data_size;
//std:cerr << _current_data_size << endl;
if (_nb_rcp[_current_rcp] == -1)
{
_nb_rcp[_current_rcp] = (_data_size * _node_data_nb);
}
}
| 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.
{
_destTopo = topo;
_server_nb_nodes = topo.total;
// _cur_info->_server_nb_nodes = _server_nb_nodes;
_pos = new int[_server_nb_nodes];
for (int i=0; i<_server_nb_nodes; i++)
{
_pos[i] = 0;
}
}
| void GaBro::setEltSize | ( | long | size | ) |
Definition at line 93 of file GaBro.cc.
References _data_size.
{
_data_size = size;
// _cur_info->_data_size = _data_size;
}
| 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.
{
_elt_node_nb = elt_node_nb;
// _cur_info->_elt_node_nb = _elt_node_nb;
_descr.node_data_nb = _elt_node_nb;
}
| void GaBro::setNodePos | ( | long | node_pos | ) |
Definition at line 115 of file GaBro.cc.
References _descr, _node_pos, and GaBroLib::GaBroDescr::node_position.
{
_node_pos = node_pos;
_descr.node_position = _node_pos;
}
| void GaBro::setNodeRank | ( | long | Rank | ) | [virtual] |
Implements DistributionLibrary.
Definition at line 80 of file GaBro.cc.
References _descr, _my_rank, and GaBroLib::GaBroDescr::sender.
| void GaBro::setSourceTopology | ( | PaCO::PacoTopology_t | topo | ) | [virtual] |
| 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.
{
_data_elt_nb = elt_nb;
_descr.total_data_nb = _data_elt_nb;
}
char* GaBro::_client_buffer [private] |
Definition at line 61 of file GaBro.h.
Referenced by GaBro(), getClientData(), and setDataPtr().
long GaBro::_cur_id [private] |
Definition at line 77 of file GaBro.h.
Referenced by freeComId(), and setComId().
info_t* GaBro::_cur_info [private] |
Definition at line 78 of file GaBro.h.
Referenced by setComId().
long GaBro::_current_data_size [private] |
Definition at line 87 of file GaBro.h.
Referenced by GaBro(), insertData(), and setDescr().
long GaBro::_current_pos [private] |
Definition at line 84 of file GaBro.h.
Referenced by GaBro(), insertData(), serverFree(), and setDescr().
int GaBro::_current_rcp [private] |
Definition at line 83 of file GaBro.h.
Referenced by GaBro(), insertData(), serverFree(), and setDescr().
long GaBro::_data_elt_nb [private] |
Definition at line 56 of file GaBro.h.
Referenced by GaBro(), setComId(), and setTotalNbElt().
long GaBro::_data_size [private] |
Definition at line 55 of file GaBro.h.
Referenced by computePiecesToSend(), GaBro(), getClientData(), insertData(), setComId(), setDescr(), and setEltSize().
GaBroLib::GaBroDescr GaBro::_descr [private] |
Definition at line 52 of file GaBro.h.
Referenced by getClientData(), getDescr(), setComId(), setDescr(), setNodeNbElt(), setNodePos(), setNodeRank(), and setTotalNbElt().
PaCO::PacoTopology_t GaBro::_destTopo [private] |
Definition at line 49 of file GaBro.h.
Referenced by getDestTopology(), and setDestTopology().
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_t GaBro::_info_list_map [private] |
Definition at line 75 of file GaBro.h.
Referenced by freeComId(), setComId(), and ~GaBro().
long GaBro::_my_rank [private] |
Definition at line 57 of file GaBro.h.
Referenced by computePiecesToSend(), GaBro(), getNodeRank(), and setNodeRank().
long* GaBro::_nb_rcp [private] |
Definition at line 82 of file GaBro.h.
Referenced by GaBro(), insertData(), serverFree(), setDescr(), setSourceTopology(), and ~GaBro().
long GaBro::_node_data_nb [private] |
Definition at line 86 of file GaBro.h.
Referenced by GaBro(), insertData(), and setDescr().
long GaBro::_node_pos [private] |
Definition at line 64 of file GaBro.h.
Referenced by GaBro(), setComId(), and setNodePos().
int* GaBro::_pos [private] |
Definition at line 62 of file GaBro.h.
Referenced by clientFree(), GaBro(), getClientData(), setDestTopology(), and ~GaBro().
char* GaBro::_server_buffer [private] |
Definition at line 81 of file GaBro.h.
Referenced by GaBro(), getServerData(), insertData(), and serverFree().
long GaBro::_server_nb_nodes [private] |
Definition at line 58 of file GaBro.h.
Referenced by clientFree(), computePiecesToSend(), GaBro(), setComId(), and setDestTopology().
PaCO::PacoTopology_t GaBro::_srcTopo [private] |
Definition at line 48 of file GaBro.h.
Referenced by getSourceTopology(), insertData(), serverFree(), and setSourceTopology().
long GaBro::_total_data_nb [private] |
Definition at line 85 of file GaBro.h.
Referenced by GaBro(), getServerData(), insertData(), and setDescr().