8 #define DISTRIBUTION_TYPE 16 11 #undef DEBUG_INTERNAL2 16 static inline unsigned OwnerBloc(
const unsigned bid,
const unsigned nbprocs) {
29 return (high-1) / bsz;
36 const unsigned bsz,
const unsigned rank) {
37 unsigned nbbloc = (glen + bsz - 1 ) / bsz;
38 return (nbbloc / nbprocs) + (rank < (nbbloc % nbprocs ) ) ;
46 const unsigned nbprocs,
const unsigned bsz,
49 unsigned long low = ( pos * nbprocs + rank ) * bsz;
50 unsigned long end = low + bsz;
51 unsigned long high = (glen < end ? glen : end);
53 return ( high - low );
61 const unsigned nbprocs,
const unsigned pos) {
62 return ( pos * nbprocs + rank) * bsz;
70 const unsigned glen,
const unsigned rank,
71 const unsigned nbprocs,
const unsigned bsz,
73 unsigned long start = (pos * nbprocs + rank) * bsz;
74 unsigned long end = start + bsz;
76 *high = ((glen <= end)?glen:end);
83 const unsigned nbprocs,
const unsigned bsz) {
87 unsigned long low = ( nbblocfull * nbprocs + rank ) * bsz;
88 unsigned long end = low + bsz;
89 unsigned long high = (glen < end ? glen : end);
91 return nbblocfull * bsz + ( high - low );
98 static inline unsigned blocSize(
const unsigned glen,
const unsigned nbprocs,
105 return ((nbbloc + nbprocs - 1 ) / nbprocs) * param.
unitsize;
149 #ifdef DEBUG_INTERNAL 150 std::cerr <<
"-- setSourceTopology: " << topo.
total << std::endl;
159 std::cerr <<
"****** Why is the method " << __FUNCTION__ <<
"called?\n";
167 #ifdef DEBUG_INTERNAL 168 std::cerr <<
"-- setDestTopology: " << topo.
total << std::endl;
192 std::cerr <<
"****** Why is the method " << __FUNCTION__ <<
"called?\n";
200 #ifdef DEBUG_INTERNAL 201 std::cerr <<
"-- setNodeRank: " << Rank << std::endl;
215 #ifdef DEBUG_INTERNAL 216 std::cerr <<
"-- setBlocSize: " << size << std::endl;
221 #ifdef DEBUG_INTERNAL 222 cout <<
"Selecting a BLOC distribution\n";
228 #ifdef DEBUG_INTERNAL 229 cout <<
"Selecting a CYCLIC distribution\n";
235 #ifdef DEBUG_INTERNAL 236 cout <<
"Selecting a BLOCCYCLIC with bsz= " << size <<
" \n";
246 #ifdef DEBUG_INTERNAL 247 std::cerr <<
"-- setEltSize: " << size << std::endl;
256 #ifdef DEBUG_INTERNAL 257 std::cerr <<
"-- setTotalNbElt: " << elt_nb << std::endl;
283 #ifdef DEBUG_INTERNAL 287 fprintf(stderr,
"-- golen: %ld\ttype: %d\tsd.start %d\tllen: %d\n", golen,
292 #ifdef DEBUG_INTERNAL 293 fprintf(stderr,
"-- easy: n<->n case !\n");
313 #ifdef DEBUG_INTERNAL 314 fprintf(stderr,
"-- %2d -> %2d : gstart:%2u lstart:%2u len:%2d\n",
321 #ifdef DEBUG_INTERNAL 322 fprintf(stderr,
"-- medium: n<->m bloc redistribution case !\n");
329 #ifdef DEBUG_INTERNAL 330 std::cerr <<
"-- sbsz: "<<_sbsz<<
" sbounds: "<<slow<<
" - "<<shigh<<endl;
335 #ifdef DEBUG_INTERNAL 336 std::cerr <<
"-- dbsz: "<<dbsz<<endl;
343 #ifdef DEBUG_INTERNAL 344 fprintf(stderr,
"-- loop from %d to %d width dtotal: %ld\n", fpid, lpid,
_dTopo.
total);
348 size_out = lpid-fpid+1;
350 for(
unsigned i=fpid; i <= lpid; i++) {
357 unsigned tmp = i*dbsz;
359 tmp2 = ( slow >= tmp)?slow:tmp;
364 unsigned end = ( shigh <= tmp)?shigh:tmp;
374 #ifdef DEBUG_INTERNAL 375 fprintf(stderr,
"-- %2d -> %2d : gstart:%2u lstart:%2u len:%2d\n",
382 #ifdef DEBUG_INTERNAL 383 fprintf(stderr,
"-- hard: n<->m bloccyclic redistribution case !\n");
389 #ifdef DEBUG_INTERNAL 390 std::cerr <<
"-- sbsz: "<<_sbsz<<
" nbbloc: "<<nbbloc<<endl;
398 unsigned *tmp_dnb = (
unsigned*) calloc(
_dTopo.
total,
sizeof(
unsigned));
400 for(
unsigned b=0; b<nbbloc; b++) {
403 if (tmp_dnb[drank]++ == 0)
414 tmp_dor[i] = &sched[cur];
415 cur+= (tmp_dnb[i]>0?1:0);
418 #ifdef DEBUG_INTERNAL 419 cerr <<
"-- size_out: "<<size_out<<endl;
422 for(
unsigned b=0; b<nbbloc; b++) {
441 ilsp->push_back(inf);
444 #ifdef DEBUG_INTERNAL 445 fprintf(stderr,
"-- %2d -> %2d : gstart:%2u lstart:%2u len:%2d\n",
452 #ifdef DEBUG_INTERNAL 463 #ifdef DEBUG_INTERNAL 464 cerr <<
"-- _clientBuffer set to "<<dataPtr<<endl;
473 #ifdef DEBUG_INTERNAL2 474 std::cerr <<
"-- getClientData : _clientBuffer=" << (
void*)
_clientBuffer << std::endl;
475 std::cerr <<
"-- getClientData : " << dnode <<
" " << remaining_size_octet << std::endl;
485 info_list_t::const_iterator ci;
486 for(ci=ilsp->begin(); ci!=ilsp->end(); ++ci) {
487 rst_data = (*ci)->msg_size - (*ci)->sent_size;
493 if (ci == ilsp->end())
495 #ifdef DEBUG_INTERNAL2 496 std::cerr <<
"-- getClientData0 : no more block for this argument\n";
498 returned_length_element = 0;
505 #ifdef DEBUG_INTERNAL2 506 std::cerr <<
"-- getClientData0 : no more data for this bloc\n";
508 returned_length_element = 0;
516 if (remaining_size_octet >= rst_data)
525 remaining_size_octet -= rst_data;
526 end = (remaining_size_octet == 0);
528 #ifdef DEBUG_INTERNAL2 529 std::cerr <<
"-- getClientData1 : gstart:"<<
_clientDescr.
ids[descr_len]<<
" #element:"<<returned_length_element<<endl;
545 remaining_size_octet -= mlen;
550 std::cerr <<
"-- getClientData1 : gstart:"<<
_clientDescr.
ids[descr_len]<<
" #element:"<<returned_length_element<<endl;
561 #ifdef DEBUG_INTERNAL 562 std::cerr <<
"-- clientFree\n";
574 #ifdef DEBUG_INTERNAL 579 std::cerr<<std::endl;
603 #ifdef DEBUG_INTERNAL 604 std::cerr <<
" gstart: "<< gstart<<
" lstart: "<<lstart<<
" #element " << element_nb<<
" llen: "<<llen<<std::endl;
606 memcpy(rptr, rcptBuf, llen);
609 #ifdef DEBUG_INTERNAL 619 #ifdef DEBUG_INTERNAL 620 std::cerr <<
"-- getServerData: ptr : "<<(
void*)
_serverBuffer<<
" #element:"<<length<<std::endl;
643 #ifdef DEBUG_INTERNAL 648 #ifdef DEBUG_INTERNAL 658 #ifdef DEBUG_INTERNAL 671 #ifdef DEBUG_INTERNAL 672 cerr <<
"setComiI: set 1st time communication id "<<
id<<endl;
676 #ifdef DEBUG_INTERNAL 677 cerr <<
"setComId: allocating a new _infolists: "<<
_infolists<<endl;
681 #ifdef DEBUG_INTERNAL 682 cerr <<
"setComId: set (not 1st time) communication id "<<
id<<endl;
693 if (
_cur_id ==
id)
return true;
705 #ifdef DEBUG_INTERNAL 706 cerr <<
"freeComid: communication id not found (ignoring)\n";
709 #ifdef DEBUG_INTERNAL 710 cerr <<
"freeComid: freeing communication "<<endl;
717 for(info_list_t::const_iterator ci=ilp->begin(); ci!=ilp->end(); ++ci)
729 #ifdef DEBUG_INTERNAL 730 cerr <<
"freeComId: not allowed to free com id -1 (ignoring)\n";
736 #ifdef DEBUG_INTERNAL 737 cerr <<
"freeComId: not allowed to free current com (ignoring)\n";
742 #ifdef DEBUG_INTERNAL 743 cerr <<
"freeComid: communication id: "<<
id<<endl;
764 #ifdef DEBUG_INTERNAL 765 std::cerr <<
"-- reset info list\n";
771 for(info_list_t::const_iterator ci=ilp->begin(); ci!=ilp->end(); ++ci)
772 (*ci)->sent_size = 0;
779 #ifdef DEBUG_INTERNAL 780 std::cerr <<
"-- clear info list\n";
786 for(info_list_t::const_iterator ci=ilp->begin(); ci!=ilp->end(); ++ci)
unsigned long _serverToReceived
PaCO::PacoTopology_t _dTopo
virtual long getNodeRank()
info_list_map_t _info_list_map
static unsigned TotalNumberOfElementProc(const unsigned glen, const unsigned rank, const unsigned nbprocs, const unsigned bsz)
virtual void setDescr(void *descr)
void setTotalNbElt(unsigned long elt_nb)
virtual PaCO::PacoTopology_t getSourceTopology()
static unsigned OwnerBloc(const unsigned bid, const unsigned nbprocs)
virtual void clientFree()
static unsigned blocSize(const unsigned glen, const unsigned nbprocs, const BasicBC_param_t ¶m)
info_list_t ** _infolists
#define DISTRIBUTION_TYPE
static void computeBlocBounds(unsigned long *low, unsigned long *high, const unsigned glen, const unsigned rank, const unsigned nbprocs, const unsigned bsz, const unsigned pos)
static unsigned NumberOfBlocProc(const unsigned glen, const unsigned nbprocs, const unsigned bsz, const unsigned rank)
void allocate_new_info_list()
static unsigned BlocNumberOfElementProc(const unsigned glen, const unsigned rank, const unsigned nbprocs, const unsigned bsz, const unsigned pos)
virtual void setNodeRank(long Rank)
bool _descr_to_be_cleaned
virtual bool setComId(long id)
virtual void serverFree()
virtual void * getDescr()
static unsigned getProcRangeInf(unsigned low, unsigned bsz)
BasicBC_distri_type_t type
void setBlocSize(unsigned long bsz)
void setEltSize(unsigned long size)
virtual void * getServerData(long &length)
void internalFreeComId(info_list_map_t::iterator &it)
static unsigned computeBlocBoundInf(const unsigned bsz, const unsigned rank, const unsigned nbprocs, const unsigned pos)
virtual PieceToSend * computePiecesToSend(unsigned &size)
BasicBCLib::BasicBCDescr _clientDescr
PaCO::PacoTopology_t _sTopo
list< info_t * > info_list_t
virtual void setSourceTopology(PaCO::PacoTopology_t topo)
BasicBCLib::BasicBCDescr * _serverDescr
virtual bool freeComId(long id)
virtual PaCO::PacoTopology_t getDestTopology()
virtual void setDataPtr(void *dataPtr)
virtual void setDestTopology(PaCO::PacoTopology_t topo)
virtual void * getClientData(void *pid, int server_node, long &size, long &length, bool &end)
static unsigned getProcRangeSup(unsigned high, unsigned bsz)
void internalSetComId(long id)
unsigned _descr_ids_counter
virtual bool insertData(void *rcptBuf, unsigned long element_nb)