Changeset 595
- Timestamp:
- 05/26/15 16:13:46 (9 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/context_client.cpp
r591 r595 21 21 \cxtSer [in] cxtSer Pointer to context of server side. (It is only used on case of attached mode) 22 22 */ 23 CContextClient::CContextClient(CContext* parent, MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer)23 CContextClient::CContextClient(CContext* parent, MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer) 24 24 : mapBufferSize_(), parentServer(cxtSer) 25 25 { 26 context=parent ; 27 intraComm=intraComm_ ; 28 interComm=interComm_ ; 29 MPI_Comm_rank(intraComm,&clientRank) ; 30 MPI_Comm_size(intraComm,&clientSize) ; 31 32 int flag ; 33 MPI_Comm_test_inter(interComm,&flag) ; 34 if (flag) MPI_Comm_remote_size(interComm,&serverSize); 35 else MPI_Comm_size(interComm,&serverSize) ; 36 37 timeLine=0 ; 38 26 context = parent; 27 intraComm = intraComm_; 28 interComm = interComm_; 29 MPI_Comm_rank(intraComm, &clientRank); 30 MPI_Comm_size(intraComm, &clientSize); 31 32 int flag; 33 MPI_Comm_test_inter(interComm, &flag); 34 if (flag) MPI_Comm_remote_size(interComm, &serverSize); 35 else MPI_Comm_size(interComm, &serverSize); 36 37 if (clientSize < serverSize) 38 { 39 int serverByClient = serverSize / clientSize; 40 int remain = serverSize % clientSize; 41 int rankStart = serverByClient * clientRank; 42 43 if (clientRank < remain) 44 { 45 serverByClient++; 46 rankStart += clientRank; 47 } 48 else 49 rankStart += remain; 50 51 for (int i = 0; i < serverByClient; i++) 52 ranksServerLeader.push_back(rankStart + i); 53 } 54 else 55 { 56 int clientByServer = clientSize / serverSize; 57 int remain = clientSize % serverSize; 58 59 if (clientRank < (clientByServer + 1) * remain) 60 { 61 if (clientRank % (clientByServer + 1) == 0) 62 ranksServerLeader.push_back(clientRank / (clientByServer + 1)); 63 } 64 else 65 { 66 int rank = clientRank - (clientByServer + 1) * remain; 67 if (rank % clientByServer == 0) 68 ranksServerLeader.push_back(remain + rank / clientByServer); 69 } 70 } 71 72 timeLine = 0; 39 73 } 40 74 … … 45 79 void CContextClient::sendEvent(CEventClient& event) 46 80 { 47 list<int>::iterator itServer ; 48 list<int> ranks ; 49 list<int> sizes ; 50 list<int>::iterator itSize ; 51 52 ranks=event.getRanks() ; 53 if (! event.isEmpty()) 54 { 55 sizes=event.getSizes() ; 56 CMessage msg ; 57 58 msg<<*(sizes.begin())<<timeLine ; 59 for(list<int>::iterator it=sizes.begin();it!=sizes.end();it++) *it+=msg.size() ; 60 list<CBufferOut*> buffList=getBuffers(ranks,sizes) ; 61 62 list<CBufferOut*>::iterator it ; 63 for(it=buffList.begin(),itSize=sizes.begin();it!=buffList.end();++it,++itSize) 64 { 65 **it<<*itSize<<timeLine ; 66 } 67 event.send(buffList) ; 68 checkBuffers(ranks) ; 69 } 70 71 // if (context->hasServer) 72 if (0 != parentServer) 81 list<int>::iterator itServer; 82 list<int> ranks; 83 list<int> sizes; 84 list<int>::iterator itSize; 85 86 ranks = event.getRanks(); 87 if (!event.isEmpty()) 88 { 89 sizes = event.getSizes(); 90 CMessage msg; 91 92 msg << *(sizes.begin()) << timeLine; 93 for (list<int>::iterator it = sizes.begin(); it != sizes.end(); it++) *it += msg.size(); 94 list<CBufferOut*> buffList = getBuffers(ranks, sizes); 95 96 list<CBufferOut*>::iterator it; 97 for (it = buffList.begin(), itSize = sizes.begin(); it != buffList.end(); ++it, ++itSize) 98 { 99 **it << *itSize << timeLine; 100 } 101 event.send(buffList); 102 checkBuffers(ranks); 103 } 104 105 if (0 != parentServer) // context->hasServer 73 106 { 74 107 waitEvent(ranks); … … 76 109 } 77 110 78 timeLine++ 111 timeLine++; 79 112 } 80 113 … … 85 118 void CContextClient::sendBufferSizeEvent() 86 119 { 87 std::map<int, 88 std::map<int, 120 std::map<int,CClientBuffer*>::iterator it, itE; 121 std::map<int,StdSize>::const_iterator itMap = mapBufferSize_.begin(), iteMap = mapBufferSize_.end(); 89 122 90 123 if (itMap == iteMap) 91 ERROR(" CBufferOut* CContextClient::sendBufferSizeEvent() ;",124 ERROR("void CContextClient::sendBufferSizeEvent()", 92 125 <<"No information about server buffer, that should not happen..."); 93 126 … … 115 148 void CContextClient::waitEvent(list<int>& ranks) 116 149 { 117 // context->server->setPendingEvent() 118 // while (checkBuffers(ranks))150 // context->server->setPendingEvent(); 151 // while (checkBuffers(ranks)) 119 152 // { 120 // context->server->listen() 121 // context->server->checkPendingRequest() 153 // context->server->listen(); 154 // context->server->checkPendingRequest(); 122 155 // } 123 156 // 124 // while (context->server->hasPendingEvent())157 // while (context->server->hasPendingEvent()) 125 158 // { 126 // context->server->eventLoop() 159 // context->server->eventLoop(); 127 160 // } 128 161 129 parentServer->server->setPendingEvent() 130 while (checkBuffers(ranks))131 { 132 parentServer->server->listen() 133 parentServer->server->checkPendingRequest() 134 } 135 136 while (parentServer->server->hasPendingEvent())137 { 138 parentServer->server->eventLoop() 162 parentServer->server->setPendingEvent(); 163 while (checkBuffers(ranks)) 164 { 165 parentServer->server->listen(); 166 parentServer->server->checkPendingRequest(); 167 } 168 169 while (parentServer->server->hasPendingEvent()) 170 { 171 parentServer->server->eventLoop(); 139 172 } 140 173 } … … 148 181 list<CBufferOut*> CContextClient::getBuffers(list<int>& serverList, list<int>& sizeList) 149 182 { 150 list<int>::iterator itServer, itSize;151 list<CClientBuffer*> bufferList 152 map<int,CClientBuffer*>::iterator it 153 list<CClientBuffer*>::iterator itBuffer 154 list<CBufferOut*> retBuffer 155 bool free 156 157 for (itServer=serverList.begin();itServer!=serverList.end();itServer++)158 { 159 it =buffers.find(*itServer);160 if (it ==buffers.end())161 { 162 newBuffer(*itServer) 163 it =buffers.find(*itServer);164 } 165 bufferList.push_back(it->second) 166 } 167 free =false;183 list<int>::iterator itServer, itSize; 184 list<CClientBuffer*> bufferList; 185 map<int,CClientBuffer*>::iterator it; 186 list<CClientBuffer*>::iterator itBuffer; 187 list<CBufferOut*> retBuffer; 188 bool free; 189 190 for (itServer = serverList.begin(); itServer != serverList.end(); itServer++) 191 { 192 it = buffers.find(*itServer); 193 if (it == buffers.end()) 194 { 195 newBuffer(*itServer); 196 it = buffers.find(*itServer); 197 } 198 bufferList.push_back(it->second); 199 } 200 free = false; 168 201 169 202 CTimer::get("Blocking time").resume(); 170 while (!free)171 { 172 free =true;173 for (itBuffer=bufferList.begin(),itSize=sizeList.begin(); itBuffer!=bufferList.end();itBuffer++,itSize++)174 { 175 (*itBuffer)->checkBuffer() 176 free &=(*itBuffer)->isBufferFree(*itSize);203 while (!free) 204 { 205 free = true; 206 for (itBuffer = bufferList.begin(), itSize = sizeList.begin(); itBuffer != bufferList.end(); itBuffer++, itSize++) 207 { 208 (*itBuffer)->checkBuffer(); 209 free &= (*itBuffer)->isBufferFree(*itSize); 177 210 } 178 211 } 179 212 CTimer::get("Blocking time").suspend(); 180 213 181 for(itBuffer=bufferList.begin(),itSize=sizeList.begin(); itBuffer!=bufferList.end();itBuffer++,itSize++) 182 { 183 retBuffer.push_back((*itBuffer)->getBuffer(*itSize)) ; 184 } 185 return retBuffer ; 186 214 for (itBuffer = bufferList.begin(), itSize = sizeList.begin(); itBuffer != bufferList.end(); itBuffer++, itSize++) 215 { 216 retBuffer.push_back((*itBuffer)->getBuffer(*itSize)); 217 } 218 return retBuffer; 187 219 } 188 220 … … 193 225 void CContextClient::newBuffer(int rank) 194 226 { 195 buffers[rank] =new CClientBuffer(interComm,rank, mapBufferSize_[rank]);227 buffers[rank] = new CClientBuffer(interComm, rank, mapBufferSize_[rank]); 196 228 } 197 229 … … 202 234 bool CContextClient::checkBuffers(void) 203 235 { 204 map<int,CClientBuffer*>::iterator itBuff 205 bool pending =false;206 for (itBuff=buffers.begin();itBuff!=buffers.end();itBuff++) pending|=itBuff->second->checkBuffer();207 return pending 236 map<int,CClientBuffer*>::iterator itBuff; 237 bool pending = false; 238 for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) pending |= itBuff->second->checkBuffer(); 239 return pending; 208 240 } 209 241 … … 211 243 void CContextClient::releaseBuffers(void) 212 244 { 213 map<int,CClientBuffer*>::iterator itBuff 214 for (itBuff=buffers.begin();itBuff!=buffers.end();itBuff++) delete itBuff->second;245 map<int,CClientBuffer*>::iterator itBuff; 246 for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) delete itBuff->second; 215 247 } 216 248 … … 222 254 bool CContextClient::checkBuffers(list<int>& ranks) 223 255 { 224 list<int>::iterator it 225 bool pending =false;226 for (it=ranks.begin();it!=ranks.end();it++) pending|=buffers[*it]->checkBuffer();227 return pending 256 list<int>::iterator it; 257 bool pending = false; 258 for (it = ranks.begin(); it != ranks.end(); it++) pending |= buffers[*it]->checkBuffer(); 259 return pending; 228 260 } 229 261 … … 232 264 \param [in] mapSize mapping rank of connected server to size of allocated buffer 233 265 */ 234 void CContextClient::setBufferSize(const std::map<int, 266 void CContextClient::setBufferSize(const std::map<int,StdSize>& mapSize) 235 267 { 236 268 mapBufferSize_ = mapSize; … … 238 270 } 239 271 240 /*! 241 Get leading server in the group of connected server 242 \return rank of leading server 243 */ 244 int CContextClient::getServerLeader(void) 245 { 246 int clientByServer=clientSize/serverSize ; 247 int remain=clientSize%serverSize ; 248 249 if (clientRank<(clientByServer+1)*remain) 250 { 251 return clientRank/(clientByServer+1) ; 252 } 253 else 254 { 255 int rank=clientRank-(clientByServer+1)*remain ; 256 int nbServer=serverSize-remain ; 257 return remain+rank/clientByServer ; 258 } 259 } 260 261 /*! 262 Check if client connects to leading server 263 \return connected(true), not connected (false) 264 */ 265 bool CContextClient::isServerLeader(void) 266 { 267 int clientByServer=clientSize/serverSize ; 268 int remain=clientSize%serverSize ; 269 270 if (clientRank<(clientByServer+1)*remain) 271 { 272 if (clientRank%(clientByServer+1)==0) return true ; 273 else return false ; 274 } 275 else 276 { 277 int rank=clientRank-(clientByServer+1)*remain ; 278 int nbServer=serverSize-remain ; 279 if (rank%clientByServer==0) return true ; 280 else return false ; 281 } 282 } 272 /*! 273 Get leading server in the group of connected server 274 \return ranks of leading servers 275 */ 276 const std::list<int>& CContextClient::getRanksServerLeader(void) const 277 { 278 return ranksServerLeader; 279 } 280 281 /*! 282 Check if client connects to leading server 283 \return connected(true), not connected (false) 284 */ 285 bool CContextClient::isServerLeader(void) const 286 { 287 return !ranksServerLeader.empty(); 288 } 283 289 284 290 /*! … … 287 293 void CContextClient::finalize(void) 288 294 { 289 map<int,CClientBuffer*>::iterator itBuff 290 bool stop =true;291 292 CEventClient event(CContext::GetType(), CContext::EVENT_ID_CONTEXT_FINALIZE);295 map<int,CClientBuffer*>::iterator itBuff; 296 bool stop = true; 297 298 CEventClient event(CContext::GetType(), CContext::EVENT_ID_CONTEXT_FINALIZE); 293 299 if (isServerLeader()) 294 300 { 295 CMessage msg ; 296 event.push(getServerLeader(),1,msg) ; 297 sendEvent(event) ; 301 CMessage msg; 302 const std::list<int>& ranks = getRanksServerLeader(); 303 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 304 event.push(*itRank, 1, msg); 305 sendEvent(event); 298 306 } 299 else sendEvent(event) 307 else sendEvent(event); 300 308 301 309 CTimer::get("Blocking time").resume(); 302 while (stop)310 while (stop) 303 311 { 304 checkBuffers() 305 stop =false;306 for (itBuff=buffers.begin();itBuff!=buffers.end();itBuff++) stop|=itBuff->second->hasPendingRequest();312 checkBuffers(); 313 stop = false; 314 for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) stop |= itBuff->second->hasPendingRequest(); 307 315 } 308 316 CTimer::get("Blocking time").suspend(); 309 317 310 std::map<int, 311 318 std::map<int,StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 319 iteMap = mapBufferSize_.end(), itMap; 312 320 StdSize totalBuf = 0; 313 321 for (itMap = itbMap; itMap != iteMap; ++itMap) 314 322 { 315 report(10) << " Memory report : Context <"<<context->getId()<<"> : client side : memory used for buffer of each connection to server" << endl316 << " +) To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl;323 report(10) << " Memory report : Context <" << context->getId() << "> : client side : memory used for buffer of each connection to server" << endl 324 << " +) To server with rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 317 325 totalBuf += itMap->second; 318 326 } 319 report(0) << " Memory report : Context <"<<context->getId()<<"> : client side : total memory used for buffer "<<totalBuf<<" bytes"<<endl;320 321 releaseBuffers() 327 report(0) << " Memory report : Context <" << context->getId() << "> : client side : total memory used for buffer " << totalBuf << " bytes" << endl; 328 329 releaseBuffers(); 322 330 } 323 331 } -
XIOS/trunk/src/context_client.hpp
r591 r595 10 10 namespace xios 11 11 { 12 class CContext 12 class CContext; 13 13 14 14 /*! … … 23 23 { 24 24 public: 25 // Contructor26 CContextClient(CContext* parent,MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0);25 // Contructor 26 CContextClient(CContext* parent, MPI_Comm intraComm, MPI_Comm interComm, CContext* parentServer = 0); 27 27 28 // Send event to server29 void sendEvent(CEventClient& event);30 void waitEvent(list<int>& ranks);28 // Send event to server 29 void sendEvent(CEventClient& event); 30 void waitEvent(list<int>& ranks); 31 31 32 // Functions relates to set/get buffers33 list<CBufferOut*> getBuffers(list<int>& serverlist, list<int>& sizeList);34 void newBuffer(int rank);35 bool checkBuffers(list<int>& ranks);36 bool checkBuffers(void);37 void releaseBuffers(void);32 // Functions relates to set/get buffers 33 list<CBufferOut*> getBuffers(list<int>& serverlist, list<int>& sizeList); 34 void newBuffer(int rank); 35 bool checkBuffers(list<int>& ranks); 36 bool checkBuffers(void); 37 void releaseBuffers(void); 38 38 39 bool isServerLeader(void);40 int getServerLeader(void);39 bool isServerLeader(void) const; 40 const std::list<int>& getRanksServerLeader(void) const; 41 41 42 // Close and finalize context client43 void closeContext(void);44 void finalize(void);42 // Close and finalize context client 43 void closeContext(void); 44 void finalize(void); 45 45 46 void setBufferSize(const std::map<int,StdSize>& mapSize);47 void sendBufferSizeEvent();46 void setBufferSize(const std::map<int,StdSize>& mapSize); 47 void sendBufferSizeEvent(); 48 48 49 49 public: 50 CContext* context 50 CContext* context; //!< Context for client 51 51 52 size_t timeLine 52 size_t timeLine; //!< Timeline of each event 53 53 54 int clientRank 54 int clientRank; //!< Rank of current client 55 55 56 int clientSize 56 int clientSize; //!< Size of client group 57 57 58 int serverSize 58 int serverSize; //!< Size of server group 59 59 60 MPI_Comm interComm 60 MPI_Comm interComm; //!< Communicator of server group 61 61 62 MPI_Comm intraComm 62 MPI_Comm intraComm; //!< Communicator of client group 63 63 64 map<int,CClientBuffer*> buffers 64 map<int,CClientBuffer*> buffers; //!< Buffers for connection to servers 65 65 66 66 private: 67 67 //! Mapping of server and buffer size for each connection to server 68 std::map<int, 68 std::map<int,StdSize> mapBufferSize_; 69 69 70 70 //! Context for server (Only used in attached mode) 71 71 CContext* parentServer; 72 72 73 //! List of server ranks for which the client is leader 74 std::list<int> ranksServerLeader; 75 73 76 public: // Some function should be removed in the future 74 // void registerEvent(CEventClient& event) 75 // list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes) 76 // bool locked 77 // set<int> connectedServer 77 // void registerEvent(CEventClient& event); 78 // list<CBufferOut*> newEvent(CEventClient& event,list<int>& sizes); 79 // bool locked; 80 // set<int> connectedServer; 78 81 79 } 82 }; 80 83 } 81 84 -
XIOS/trunk/src/group_template_impl.hpp
r591 r595 385 385 msg<<this->getId() ; 386 386 msg<<id ; 387 event.push(client->getServerLeader(),1,msg) ; 387 const std::list<int>& ranks = client->getRanksServerLeader(); 388 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 389 event.push(*itRank,1,msg) ; 388 390 client->sendEvent(event) ; 389 391 } … … 407 409 msg<<this->getId() ; 408 410 msg<<id ; 409 event.push(client->getServerLeader(),1,msg) ; 411 const std::list<int>& ranks = client->getRanksServerLeader(); 412 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 413 event.push(*itRank,1,msg) ; 410 414 client->sendEvent(event) ; 411 415 } -
XIOS/trunk/src/node/axis.cpp
r594 r595 119 119 StdSize zoom_begin,zoom_end, zoom_size, axisSize; 120 120 121 zoom_begin = (this->zoom_begin.isEmpty()) ? 0 : this->zoom_begin.getValue();122 zoom_size = (this->zoom_size.isEmpty()) ? size.getValue() : this->zoom_size.getValue();123 zoom_end = (this->zoom_end.isEmpty()) ? (size.getValue() - 1) : this->zoom_end.getValue();124 125 if (this->zoom_begin.isEmpty()) zoom_begin =zoom_end-zoom_size+1;126 if (this->zoom_end.isEmpty()) zoom_end =zoom_begin+zoom_size-1;127 if (this->zoom_size.isEmpty()) zoom_size =zoom_end-zoom_begin+1;121 zoom_begin = this->zoom_begin.isEmpty() ? 0 : this->zoom_begin.getValue(); 122 zoom_size = this->zoom_size.isEmpty() ? size.getValue() : this->zoom_size.getValue(); 123 zoom_end = this->zoom_end.isEmpty() ? (size.getValue() - 1) : this->zoom_end.getValue(); 124 125 if (this->zoom_begin.isEmpty()) zoom_begin = zoom_end - zoom_size + 1; 126 if (this->zoom_end.isEmpty()) zoom_end = zoom_begin + zoom_size - 1; 127 if (this->zoom_size.isEmpty()) zoom_size = zoom_end - zoom_begin + 1; 128 128 axisSize = size.getValue(); 129 129 … … 132 132 << "One or more attributes among <zoom_begin>, <zoom_end>, <zoom_size> of axis [ id = '" << getId() << "' , context = '" << CObjectFactory::GetCurrentContextId() << "' ] are not well specified"); 133 133 134 this->zoom_begin.setValue(zoom_begin) 135 this->zoom_end.setValue(zoom_end) 136 this->zoom_size.setValue(zoom_size) 134 this->zoom_begin.setValue(zoom_begin); 135 this->zoom_end.setValue(zoom_end); 136 this->zoom_size.setValue(zoom_size); 137 137 } 138 138 … … 158 158 if (mask.extent(0) != ni) 159 159 ERROR("CAxis::checkMask(void)", 160 << "the mask has not the same size than the local axis"<<endl161 << "Local size is "<<ni<<"x"<<endl162 << "Mask size is "<<mask.extent(0)<<"x");160 << "the mask has not the same size than the local axis" << endl 161 << "Local size is " << ni << "x" << endl 162 << "Mask size is " << mask.extent(0) << "x"); 163 163 for (int i = 0; i < ni; ++i) 164 164 { … … 181 181 bool CAxis::dispatchEvent(CEventServer& event) 182 182 { 183 if (SuperClass::dispatchEvent(event)) return true 183 if (SuperClass::dispatchEvent(event)) return true; 184 184 else 185 185 { … … 187 187 { 188 188 case EVENT_ID_SERVER_ATTRIBUT : 189 recvServerAttribut(event) 190 return true 191 break 189 recvServerAttribut(event); 190 return true; 191 break; 192 192 default : 193 193 ERROR("bool CContext::dispatchEvent(CEventServer& event)", 194 << "Unknown Event");195 return false 194 << "Unknown Event"); 195 return false; 196 196 } 197 197 } … … 202 202 { 203 203 if (this->areClientAttributesChecked_) return; 204 204 205 this->checkAttributes(); 205 206 206 CContext* context=CContext::getCurrent() ;207 if (context->hasClient)208 {209 computeServerIndex(globalDim, orderPositionInGrid, distType);210 }211 212 207 this->areClientAttributesChecked_ = true; 213 }214 215 void CAxis::computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid,216 CServerDistributionDescription::ServerDistributionType distType)217 {218 CServerDistributionDescription serverDescription(globalDim);219 220 CContext* context=CContext::getCurrent() ;221 CContextClient* client=context->client ;222 int nbServer=client->serverSize ;223 int serverRank=client->getServerLeader() ;224 225 serverDescription.computeServerDistribution(nbServer, false, distType);226 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin();227 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes();228 begin_srv = (serverIndexBegin[serverRank])[orderPositionInGrid];229 ni_srv = serverDimensionSizes[serverRank][orderPositionInGrid];230 end_srv = begin_srv+ni_srv-1;231 208 } 232 209 … … 238 215 orderPositionInGrid, 239 216 distType); 240 CContext* context =CContext::getCurrent();217 CContext* context = CContext::getCurrent(); 241 218 242 219 if (this->isChecked) return; 243 220 if (context->hasClient) 244 221 { 245 sendServerAttribut( );222 sendServerAttribut(globalDim, orderPositionInGrid, distType); 246 223 } 247 224 … … 249 226 } 250 227 251 void CAxis::sendServerAttribut(void) 228 void CAxis::sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, 229 CServerDistributionDescription::ServerDistributionType distType) 252 230 { 253 CContext* context=CContext::getCurrent(); 254 CContextClient* client=context->client; 255 256 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 231 CContext* context = CContext::getCurrent(); 232 CContextClient* client = context->client; 233 234 CServerDistributionDescription serverDescription(globalDim); 235 236 int nbServer = client->serverSize; 237 238 serverDescription.computeServerDistribution(nbServer, false, distType); 239 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 240 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 241 242 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 257 243 if (client->isServerLeader()) 258 244 { 259 CMessage msg ; 260 msg<<this->getId() ; 261 msg<<ni_srv<<begin_srv<<end_srv; 262 event.push(client->getServerLeader(),1,msg) ; 263 client->sendEvent(event) ; 245 std::list<CMessage> msgs; 246 247 const std::list<int>& ranks = client->getRanksServerLeader(); 248 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 249 { 250 // Use const int to ensure CMessage holds a copy of the value instead of just a reference 251 const int begin = serverIndexBegin[*itRank][orderPositionInGrid]; 252 const int ni = serverDimensionSizes[*itRank][orderPositionInGrid]; 253 const int end = begin + ni - 1; 254 255 msgs.push_back(CMessage()); 256 CMessage& msg = msgs.back(); 257 msg << this->getId(); 258 msg << ni << begin << end; 259 260 event.push(*itRank,1,msg); 261 } 262 client->sendEvent(event); 264 263 } 265 else client->sendEvent(event) 264 else client->sendEvent(event); 266 265 } 267 266 268 267 void CAxis::recvServerAttribut(CEventServer& event) 269 268 { 270 CBufferIn* buffer =event.subEvents.begin()->buffer;271 string axisId 272 *buffer >>axisId;273 get(axisId)->recvServerAttribut(*buffer) 269 CBufferIn* buffer = event.subEvents.begin()->buffer; 270 string axisId; 271 *buffer >> axisId; 272 get(axisId)->recvServerAttribut(*buffer); 274 273 } 275 274 … … 281 280 buffer>>ni_srv>>begin_srv>>end_srv; 282 281 283 zoom_begin_srv = zoom_begin.getValue() > begin_srv ? zoom_begin.getValue() : begin_srv 284 zoom_end_srv = zoom_end < end_srv ? zoom_end : end_srv 285 zoom_size_srv = zoom_end_srv -zoom_begin_srv+1;282 zoom_begin_srv = zoom_begin.getValue() > begin_srv ? zoom_begin.getValue() : begin_srv; 283 zoom_end_srv = zoom_end < end_srv ? zoom_end : end_srv; 284 zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 286 285 287 286 if (zoom_size_srv<=0) 288 287 { 289 zoom_begin_srv =0 ; zoom_end_srv=0 ; zoom_size_srv=0;288 zoom_begin_srv = 0; zoom_end_srv = 0; zoom_size_srv = 0; 290 289 } 291 290 … … 294 293 zoom_begin_srv = zoom_begin.getValue(); 295 294 zoom_end_srv = zoom_end; 296 zoom_size_srv = zoom_end_srv -zoom_begin_srv+1;295 zoom_size_srv = zoom_end_srv - zoom_begin_srv + 1; 297 296 } 298 297 } -
XIOS/trunk/src/node/axis.hpp
r594 r595 14 14 15 15 namespace xios { 16 17 16 /// ////////////////////// Déclarations ////////////////////// /// 18 17 … … 75 74 static ENodeType GetType(void); 76 75 77 void sendServerAttribut(void); 76 void sendServerAttribut(const std::vector<int>& globalDim, int orderPositionInGrid, 77 CServerDistributionDescription::ServerDistributionType distType); 78 78 static bool dispatchEvent(CEventServer& event); 79 79 static void recvServerAttribut(CEventServer& event); … … 86 86 int zoom_begin_srv, zoom_end_srv, zoom_size_srv; 87 87 int ni_srv, begin_srv, end_srv; 88 88 89 private : 89 90 void checkData(); 90 91 void checkMask(); 91 92 void checkZoom(); 92 void computeServerIndex(const std::vector<int>& globalDim, int orderPositionInGrid, 93 CServerDistributionDescription::ServerDistributionType disType); 93 94 94 private: 95 95 … … 100 100 101 101 DECLARE_REF_FUNC(Axis,axis) 102 103 104 102 }; // class CAxis 105 103 … … 108 106 // Declare/Define CAxisGroup and CAxisDefinition 109 107 DECLARE_GROUP(CAxis); 110 111 ///--------------------------------------------------------------112 113 108 } // namespace xios 114 109 -
XIOS/trunk/src/node/context.cpp
r593 r595 241 241 if (hasClient) 242 242 { 243 size_t bufferSizeMin = 10 *sizeof(size_t)*1024;243 size_t bufferSizeMin = 10 * sizeof(size_t) * 1024; 244 244 #define DECLARE_NODE(Name_, name_) \ 245 bufferSizeMin = (bufferSizeMin < sizeof(C##Name_##Definition)) ? sizeof(C##Name_##Definition) : bufferSizeMin;245 bufferSizeMin = (bufferSizeMin < sizeof(C##Name_##Definition)) ? sizeof(C##Name_##Definition) : bufferSizeMin; 246 246 #define DECLARE_NODE_PAR(Name_, name_) 247 247 #include "node_type.conf" … … 251 251 if (client->isServerLeader()) 252 252 { 253 bufferSize[client->getServerLeader()] = bufferSizeMin; 253 const std::list<int>& ranks = client->getRanksServerLeader(); 254 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 255 bufferSize[*itRank] = bufferSizeMin; 254 256 } 255 257 else 256 258 return; 257 259 } 258 259 std::map<int, StdSize>::iterator it = bufferSize.begin(), 260 ite = bufferSize.end(); 261 for (; it != ite; ++it) 262 it->second = (it->second < bufferSizeMin) ? bufferSizeMin : it->second; 260 else 261 { 262 std::map<int, StdSize>::iterator it = bufferSize.begin(), 263 ite = bufferSize.end(); 264 for (; it != ite; ++it) 265 it->second = (it->second < bufferSizeMin) ? bufferSizeMin : it->second; 266 } 267 263 268 client->setBufferSize(bufferSize); 264 269 } … … 513 518 CMessage msg; 514 519 msg<<this->getIdServer(); 515 event.push(client->getServerLeader(),1,msg); 520 const std::list<int>& ranks = client->getRanksServerLeader(); 521 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 522 event.push(*itRank,1,msg); 516 523 client->sendEvent(event); 517 524 } … … 539 546 CMessage msg; 540 547 msg<<this->getIdServer()<<step; 541 event.push(client->getServerLeader(),1,msg); 548 const std::list<int>& ranks = client->getRanksServerLeader(); 549 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 550 event.push(*itRank,1,msg); 542 551 client->sendEvent(event); 543 552 } … … 549 558 void CContext::recvUpdateCalendar(CEventServer& event) 550 559 { 551 552 560 CBufferIn* buffer=event.subEvents.begin()->buffer; 553 561 string id; … … 572 580 CMessage msg; 573 581 msg<<this->getIdServer(); 574 event.push(client->getServerLeader(),1,msg); 582 const std::list<int>& ranks = client->getRanksServerLeader(); 583 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 584 event.push(*itRank,1,msg) ; 575 585 client->sendEvent(event); 576 586 } … … 603 613 CMessage msg; 604 614 msg<<this->getIdServer(); 605 event.push(client->getServerLeader(),1,msg); 615 const std::list<int>& ranks = client->getRanksServerLeader(); 616 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 617 event.push(*itRank,1,msg); 606 618 client->sendEvent(event); 607 619 } -
XIOS/trunk/src/node/domain.cpp
r594 r595 646 646 CServerDistributionDescription serverDescription(nGlobDomain); 647 647 648 int ni_srv=ni_glo.getValue() ; 649 int ibegin_srv=0 ; 650 int iend_srv=ni_glo.getValue() ; 651 652 int nj_srv ; 653 int jbegin_srv ; 654 int jend_srv ; 655 656 CContext* context=CContext::getCurrent() ; 657 CContextClient* client=context->client ; 658 int nbServer=client->serverSize ; 659 int serverRank=client->getServerLeader() ; 660 661 serverDescription.computeServerDistribution(nbServer); 662 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 663 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 664 ibegin_srv = (serverIndexBegin[serverRank])[0]; 665 jbegin_srv = serverIndexBegin[serverRank][1]; 666 ni_srv = serverDimensionSizes[serverRank][0]; 667 nj_srv = serverDimensionSizes[serverRank][1]; 668 iend_srv = ibegin_srv+ni_srv-1; 669 jend_srv = jbegin_srv+nj_srv-1; 670 671 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT) ; 672 if (client->isServerLeader()) 673 { 674 CMessage msg ; 675 msg<<this->getId() ; 676 msg<<ni_srv<<ibegin_srv<<iend_srv<<nj_srv<<jbegin_srv<<jend_srv; 677 event.push(client->getServerLeader(),1,msg) ; 678 client->sendEvent(event) ; 679 } 680 else client->sendEvent(event) ; 648 CContext* context = CContext::getCurrent(); 649 CContextClient* client = context->client; 650 int nbServer = client->serverSize; 651 652 serverDescription.computeServerDistribution(nbServer); 653 std::vector<std::vector<int> > serverIndexBegin = serverDescription.getServerIndexBegin(); 654 std::vector<std::vector<int> > serverDimensionSizes = serverDescription.getServerDimensionSizes(); 655 656 CEventClient event(getType(),EVENT_ID_SERVER_ATTRIBUT); 657 if (client->isServerLeader()) 658 { 659 std::list<CMessage> msgs; 660 661 const std::list<int>& ranks = client->getRanksServerLeader(); 662 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 663 { 664 // Use const int to ensure CMessage holds a copy of the value instead of just a reference 665 const int ibegin_srv = serverIndexBegin[*itRank][0]; 666 const int jbegin_srv = serverIndexBegin[*itRank][1]; 667 const int ni_srv = serverDimensionSizes[*itRank][0]; 668 const int nj_srv = serverDimensionSizes[*itRank][1]; 669 const int iend_srv = ibegin_srv + ni_srv - 1; 670 const int jend_srv = jbegin_srv + nj_srv - 1; 671 672 msgs.push_back(CMessage()); 673 CMessage& msg = msgs.back(); 674 msg << this->getId() ; 675 msg << ni_srv << ibegin_srv << iend_srv << nj_srv << jbegin_srv << jend_srv; 676 677 event.push(*itRank,1,msg); 678 } 679 client->sendEvent(event); 680 } 681 else client->sendEvent(event); 681 682 } 682 683 … … 921 922 void CDomain::recvServerAttribut(CBufferIn& buffer) 922 923 { 923 int zoom_iend=zoom_ibegin.getValue()+zoom_ni.getValue()-1 ; 924 int zoom_jend=zoom_jbegin.getValue()+zoom_nj.getValue()-1 ; 925 926 buffer>>ni_srv>>ibegin_srv>>iend_srv>>nj_srv>>jbegin_srv>>jend_srv; 927 924 int zoom_iend = zoom_ibegin.getValue() + zoom_ni.getValue() - 1; 925 int zoom_jend = zoom_jbegin.getValue() + zoom_nj.getValue() - 1; 926 927 buffer >> ni_srv >> ibegin_srv >> iend_srv >> nj_srv >> jbegin_srv >> jend_srv; 928 928 929 929 zoom_ibegin_srv = zoom_ibegin.getValue() > ibegin_srv ? zoom_ibegin.getValue() : ibegin_srv ; -
XIOS/trunk/src/node/field.cpp
r591 r595 872 872 msg << this->getId(); 873 873 msg << id; 874 event.push(client->getServerLeader(),1,msg); 874 const std::list<int>& ranks = client->getRanksServerLeader(); 875 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 876 event.push(*itRank,1,msg); 875 877 client->sendEvent(event); 876 878 } … … 892 894 msg << this->getId(); 893 895 msg << id; 894 event.push(client->getServerLeader(),1,msg); 896 const std::list<int>& ranks = client->getRanksServerLeader(); 897 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 898 event.push(*itRank,1,msg); 895 899 client->sendEvent(event); 896 900 } -
XIOS/trunk/src/node/file.cpp
r591 r595 617 617 msg<<this->getId() ; 618 618 msg<<id ; 619 event.push(client->getServerLeader(),1,msg) ; 619 const std::list<int>& ranks = client->getRanksServerLeader(); 620 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 621 event.push(*itRank,1,msg); 620 622 client->sendEvent(event) ; 621 623 } … … 642 644 msg<<this->getId() ; 643 645 msg<<id ; 644 event.push(client->getServerLeader(),1,msg) ; 646 const std::list<int>& ranks = client->getRanksServerLeader(); 647 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 648 event.push(*itRank,1,msg); 645 649 client->sendEvent(event) ; 646 650 } … … 744 748 msg<<this->getId() ; 745 749 msg<<id ; 746 event.push(client->getServerLeader(),1,msg) ; 750 const std::list<int>& ranks = client->getRanksServerLeader(); 751 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 752 event.push(*itRank,1,msg); 747 753 client->sendEvent(event) ; 748 754 } … … 769 775 msg<<this->getId() ; 770 776 msg<<id ; 771 event.push(client->getServerLeader(),1,msg) ; 777 const std::list<int>& ranks = client->getRanksServerLeader(); 778 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 779 event.push(*itRank,1,msg); 772 780 client->sendEvent(event) ; 773 781 } -
XIOS/trunk/src/node/grid.cpp
r593 r595 949 949 msg<<this->getId() ; 950 950 msg<<id ; 951 event.push(client->getServerLeader(),1,msg) ; 951 const std::list<int>& ranks = client->getRanksServerLeader(); 952 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 953 event.push(*itRank,1,msg); 952 954 client->sendEvent(event) ; 953 955 } … … 974 976 msg<<this->getId() ; 975 977 msg<<id ; 976 event.push(client->getServerLeader(),1,msg) ; 978 const std::list<int>& ranks = client->getRanksServerLeader(); 979 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 980 event.push(*itRank,1,msg); 977 981 client->sendEvent(event) ; 978 982 } -
XIOS/trunk/src/node/variable.cpp
r591 r595 87 87 msg<<this->getId() ; 88 88 msg<<content ; 89 event.push(client->getServerLeader(),1,msg) ; 89 const std::list<int>& ranks = client->getRanksServerLeader(); 90 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 91 event.push(*itRank,1,msg); 90 92 client->sendEvent(event) ; 91 93 } -
XIOS/trunk/src/object_template_impl.hpp
r591 r595 198 198 msg << attr.getName(); 199 199 msg << attr; 200 event.push(client->getServerLeader(),1,msg); 200 const std::list<int>& ranks = client->getRanksServerLeader(); 201 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 202 event.push(*itRank,1,msg); 201 203 client->sendEvent(event); 202 204 }
Note: See TracChangeset
for help on using the changeset viewer.