PaCO++
0.05
|
00001 #ifndef _BASICBC_H 00002 #define _BASICBC_H 00003 00004 #include "DistributionLibrairie.h" 00005 #include "BasicBCIdl.h" 00006 00007 #include <list> 00008 00009 using namespace std; 00010 00014 00015 typedef enum { BASICBC_BLOC=1, // no parameter: all bloc same size but last one: bc(n+p-1/p) 00016 BASICBC_CYCLIC, // no parameter: bc(1) 00017 BASICBC_BLOCCYCLIC // parameter 00018 } BasicBC_distri_type_t; 00019 00023 00024 typedef struct { 00025 00026 BasicBC_distri_type_t type; 00027 unsigned long unitsize; // size of one element of our "vector"; in octet 00028 unsigned long blocsize; // for bloc-cyclic; in element 00029 00030 } BasicBC_param_t; 00031 00035 00036 class BasicBC : public DistributionLibrary 00037 { 00038 private: 00040 // Client & Server side 00041 00042 unsigned _config; // vector of bit describing which elements have been configured (cf .cc) 00043 00044 PaCO::PacoTopology_t _sTopo; // topology of the source (sender) -- SET 00045 PaCO::PacoTopology_t _dTopo; // topology of the destination (receiver) -- SET 00046 00047 BasicBC_param_t _param; // the parameter of the distribution -- SET 00048 unsigned _nodeRank; // id of the node (either source or destination) -- SET 00049 00050 unsigned _glen; // total vector size: in element -- SET 00051 unsigned _llen; // local vector size: in element -- COMPUTED 00052 00053 unsigned _lstart; // id of 1st local element -- COMPUTED 00054 unsigned _sbsz; // source blocsize in element -- COMPUTED 00055 unsigned _dbsz; // source blocsize in element -- COMPUTED 00056 00058 // Client Side 00059 00060 // Info passed between computePiecesToSend & getClientData 00061 // is in fact a map of info_t with destNode as key :( 00062 // Private type 00063 typedef struct { 00064 unsigned gstart; // in element 00065 unsigned lstart; // in octet 00066 unsigned msg_size; // in octet 00067 unsigned sent_size; // in octet 00068 } info_t; 00069 typedef list<info_t*> info_list_t; 00070 00071 typedef map<long, info_list_t**> info_list_map_t; // also store com for id == -1 00072 info_list_map_t _info_list_map; 00073 00074 long _cur_id; // current communication id, -1 means none 00075 info_list_t** _infolists; // current array of dTotal entries 00076 00077 bool _descr_to_be_cleaned; // true when descr should be reset - cf getClientData & getDescr (during an invocation) 00078 char* _clientBuffer; // pointer to the user data (set) 00079 BasicBCLib::BasicBCDescr _clientDescr; // contains the descr exchange between sender & destination -- SET indirectly 00080 00082 // Server Side 00083 unsigned long _serverToReceived; // #of element yet to be received (during an invocation) 00084 unsigned _descr_ids_counter; // id of the current block (msg = sequence<block>) (during an invocation) 00085 char* _serverBuffer; // Buffer where to receive the data 00086 00087 BasicBCLib::BasicBCDescr* _serverDescr; // contains the descr exchange between sender & destination -- computed 00088 00091 00092 public: 00093 BasicBC(); 00094 virtual ~BasicBC(); 00095 00096 // Common 00097 virtual void setSourceTopology(PaCO::PacoTopology_t topo); 00098 virtual PaCO::PacoTopology_t getSourceTopology(); 00099 virtual void setDestTopology(PaCO::PacoTopology_t topo); 00100 virtual PaCO::PacoTopology_t getDestTopology(); 00101 virtual void setNodeRank(long Rank); 00102 virtual long getNodeRank(); 00103 virtual void setCommunicator(void * group) {} 00104 00105 // Data description API 00106 void setEltSize(unsigned long size); 00107 void setBlocSize(unsigned long bsz); // bloc-> bc(0), cyclic -> bc(1) 00108 void setTotalNbElt(unsigned long elt_nb); 00109 00110 // Client Side 00111 virtual PieceToSend* computePiecesToSend(unsigned& size); 00112 virtual void setDataPtr(void* dataPtr); 00113 virtual void* getClientData(void *pid, int server_node, long & size, long & length, bool & end); 00114 virtual void* getDescr(); 00115 virtual void clientFree(); // true if com schedule to be freed 00116 00117 virtual bool setComId(long id); 00118 virtual bool freeComId(long id); 00119 00120 // Server Side 00121 virtual bool insertData(void* rcptBuf, unsigned long element_nb); 00122 virtual void setDescr(void * descr); 00123 00124 virtual void* getServerData(long & length); 00125 virtual void serverFree(); 00126 00127 private: 00128 void internalSetComId(long id); 00129 void internalFreeComId(info_list_map_t::iterator& it); 00130 00131 // Helper function 00132 void allocate_new_info_list(); 00133 void reset_info_list(); 00134 void clear_info_list(); 00135 00136 }; 00137 00141 00142 class BasicBC_fab : virtual public paco_fabrique_distribution 00143 { 00144 00145 public: 00146 BasicBC_fab() {} 00147 virtual ~BasicBC_fab() {} 00148 00149 DistributionLibrary *create() 00150 { 00151 return new BasicBC(); 00152 } 00153 00154 }; 00155 00156 #endif