PaCO++  0.05
BasicBC.h
Go to the documentation of this file.
1 #ifndef _BASICBC_H
2 #define _BASICBC_H
3 
5 #include "BasicBCIdl.h"
6 
7 #include <list>
8 
9 using namespace std;
10 
14 
15 typedef enum { BASICBC_BLOC=1, // no parameter: all bloc same size but last one: bc(n+p-1/p)
16  BASICBC_CYCLIC, // no parameter: bc(1)
17  BASICBC_BLOCCYCLIC // parameter
19 
23 
24 typedef struct {
25 
27  unsigned long unitsize; // size of one element of our "vector"; in octet
28  unsigned long blocsize; // for bloc-cyclic; in element
29 
31 
35 
37 {
38 private:
40  // Client & Server side
41 
42  unsigned _config; // vector of bit describing which elements have been configured (cf .cc)
43 
44  PaCO::PacoTopology_t _sTopo; // topology of the source (sender) -- SET
45  PaCO::PacoTopology_t _dTopo; // topology of the destination (receiver) -- SET
46 
47  BasicBC_param_t _param; // the parameter of the distribution -- SET
48  unsigned _nodeRank; // id of the node (either source or destination) -- SET
49 
50  unsigned _glen; // total vector size: in element -- SET
51  unsigned _llen; // local vector size: in element -- COMPUTED
52 
53  unsigned _lstart; // id of 1st local element -- COMPUTED
54  unsigned _sbsz; // source blocsize in element -- COMPUTED
55  unsigned _dbsz; // source blocsize in element -- COMPUTED
56 
58  // Client Side
59 
60  // Info passed between computePiecesToSend & getClientData
61  // is in fact a map of info_t with destNode as key :(
62  // Private type
63  typedef struct {
64  unsigned gstart; // in element
65  unsigned lstart; // in octet
66  unsigned msg_size; // in octet
67  unsigned sent_size; // in octet
68  } info_t;
69  typedef list<info_t*> info_list_t;
70 
71  typedef map<long, info_list_t**> info_list_map_t; // also store com for id == -1
72  info_list_map_t _info_list_map;
73 
74  long _cur_id; // current communication id, -1 means none
75  info_list_t** _infolists; // current array of dTotal entries
76 
77  bool _descr_to_be_cleaned; // true when descr should be reset - cf getClientData & getDescr (during an invocation)
78  char* _clientBuffer; // pointer to the user data (set)
79  BasicBCLib::BasicBCDescr _clientDescr; // contains the descr exchange between sender & destination -- SET indirectly
80 
82  // Server Side
83  unsigned long _serverToReceived; // #of element yet to be received (during an invocation)
84  unsigned _descr_ids_counter; // id of the current block (msg = sequence<block>) (during an invocation)
85  char* _serverBuffer; // Buffer where to receive the data
86 
87  BasicBCLib::BasicBCDescr* _serverDescr; // contains the descr exchange between sender & destination -- computed
88 
91 
92 public:
93  BasicBC();
94  virtual ~BasicBC();
95 
96  // Common
97  virtual void setSourceTopology(PaCO::PacoTopology_t topo);
98  virtual PaCO::PacoTopology_t getSourceTopology();
99  virtual void setDestTopology(PaCO::PacoTopology_t topo);
100  virtual PaCO::PacoTopology_t getDestTopology();
101  virtual void setNodeRank(long Rank);
102  virtual long getNodeRank();
103  virtual void setCommunicator(void * group) {}
104 
105  // Data description API
106  void setEltSize(unsigned long size);
107  void setBlocSize(unsigned long bsz); // bloc-> bc(0), cyclic -> bc(1)
108  void setTotalNbElt(unsigned long elt_nb);
109 
110  // Client Side
111  virtual PieceToSend* computePiecesToSend(unsigned& size);
112  virtual void setDataPtr(void* dataPtr);
113  virtual void* getClientData(void *pid, int server_node, long & size, long & length, bool & end);
114  virtual void* getDescr();
115  virtual void clientFree(); // true if com schedule to be freed
116 
117  virtual bool setComId(long id);
118  virtual bool freeComId(long id);
119 
120  // Server Side
121  virtual bool insertData(void* rcptBuf, unsigned long element_nb);
122  virtual void setDescr(void * descr);
123 
124  virtual void* getServerData(long & length);
125  virtual void serverFree();
126 
127 private:
128  void internalSetComId(long id);
129  void internalFreeComId(info_list_map_t::iterator& it);
130 
131  // Helper function
132  void allocate_new_info_list();
133  void reset_info_list();
134  void clear_info_list();
135 
136 };
137 
141 
143 {
144 
145  public:
147  virtual ~BasicBC_fab() {}
148 
150  {
151  return new BasicBC();
152  }
153 
154 };
155 
156 #endif
unsigned long _serverToReceived
Definition: BasicBC.h:83
PaCO::PacoTopology_t _dTopo
Definition: BasicBC.h:45
unsigned _lstart
Definition: BasicBC.h:53
info_list_map_t _info_list_map
Definition: BasicBC.h:72
BasicBC_fab()
Definition: BasicBC.h:146
long _cur_id
Definition: BasicBC.h:74
unsigned _glen
Definition: BasicBC.h:50
unsigned long blocsize
Definition: BasicBC.h:28
info_list_t ** _infolists
Definition: BasicBC.h:75
unsigned long unitsize
Definition: BasicBC.h:27
unsigned _nodeRank
Definition: BasicBC.h:48
BasicBC_param_t _param
Definition: BasicBC.h:47
char * _clientBuffer
Definition: BasicBC.h:78
virtual ~BasicBC_fab()
Definition: BasicBC.h:147
unsigned msg_size
Definition: BasicBC.h:66
BasicBC_distri_type_t
Definition: BasicBC.h:15
bool _descr_to_be_cleaned
Definition: BasicBC.h:77
DistributionLibrary * create()
Definition: BasicBC.h:149
map< long, info_list_t ** > info_list_map_t
Definition: BasicBC.h:71
virtual void setCommunicator(void *group)
Definition: BasicBC.h:103
BasicBC_distri_type_t type
Definition: BasicBC.h:26
unsigned lstart
Definition: BasicBC.h:65
unsigned _llen
Definition: BasicBC.h:51
unsigned _config
Definition: BasicBC.h:42
BasicBCLib::BasicBCDescr _clientDescr
Definition: BasicBC.h:79
PaCO::PacoTopology_t _sTopo
Definition: BasicBC.h:44
unsigned _dbsz
Definition: BasicBC.h:55
list< info_t * > info_list_t
Definition: BasicBC.h:69
BasicBCLib::BasicBCDescr * _serverDescr
Definition: BasicBC.h:87
char * _serverBuffer
Definition: BasicBC.h:85
unsigned _sbsz
Definition: BasicBC.h:54
unsigned _descr_ids_counter
Definition: BasicBC.h:84
unsigned gstart
Definition: BasicBC.h:64
unsigned sent_size
Definition: BasicBC.h:67