Changeset 597
- Timestamp:
- 05/26/15 16:13:47 (9 years ago)
- Location:
- XIOS/trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/client.cpp
r591 r597 201 201 context->initClient(contextComm,contextInterComm, contextServer); 202 202 203 204 203 // Secondly, initialize context on server side 205 contextServer->initServer(contextComm,contextInterComm );204 contextServer->initServer(contextComm,contextInterComm, context); 206 205 207 206 // Finally, we should return current context to context client -
XIOS/trunk/src/context_client.cpp
r596 r597 206 206 free &= (*itBuffer)->isBufferFree(*itSize); 207 207 } 208 if (!free) 209 context->server->listen(); 208 210 } 209 211 CTimer::get("Blocking time").suspend(); -
XIOS/trunk/src/context_server.cpp
r549 r597 52 52 } 53 53 54 bool CContextServer::hasFinished(void) 55 { 56 return finished; 57 } 58 54 59 bool CContextServer::eventLoop(void) 55 60 { … … 79 84 { 80 85 it=buffers.find(rank); 81 if (it==buffers.end()) 86 if (it==buffers.end()) // Receive the buffer size and allocate the buffer 82 87 { 83 88 StdSize buffSize = 0; … … 169 174 if (event->isFull()) 170 175 { 171 if (!scheduled && !CXios::isServer)176 if (!scheduled && CServer::eventScheduler) // Skip event scheduling for attached mode and reception on client side 172 177 { 173 178 CServer::eventScheduler->registerEvent(currentTimeLine,hashId); 174 179 scheduled=true; 175 180 } 176 else if ( CXios::isServer || CServer::eventScheduler->queryEvent(currentTimeLine,hashId) )181 else if (!CServer::eventScheduler || CServer::eventScheduler->queryEvent(currentTimeLine,hashId) ) 177 182 { 178 183 CTimer::get("Process events").resume(); … … 207 212 if (event.classId==CContext::GetType() && event.type==CContext::EVENT_ID_CONTEXT_FINALIZE) 208 213 { 214 finished=true; 209 215 info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl; 210 216 std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), … … 218 224 } 219 225 context->finalize(); 220 finished=true;221 226 report(0)<< " Memory report : Context <"<<context->getId()<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl; 222 227 } -
XIOS/trunk/src/context_server.hpp
r591 r597 23 23 void setPendingEvent(void) ; 24 24 bool hasPendingEvent(void) ; 25 bool hasFinished(void); 25 26 26 27 MPI_Comm intraComm ; -
XIOS/trunk/src/interface/c/iccalendar.cpp
r591 r597 13 13 CTimer::get("XIOS").resume(); 14 14 xios::CContext* context = CContext::getCurrent(); 15 if (!context->hasServer) context->c lient->checkBuffers();15 if (!context->hasServer) context->checkBuffersAndListen(); 16 16 context->updateCalendar(step); 17 17 context->sendUpdateCalendar(step); -
XIOS/trunk/src/interface/c/icdata.cpp
r593 r597 373 373 CTimer::get("XIOS send field").resume(); 374 374 CContext* context = CContext::getCurrent(); 375 if (!context->hasServer) context->c lient->checkBuffers();375 if (!context->hasServer) context->checkBuffersAndListen(); 376 376 CArray<double, 1> data(data_k8, shape(data_Xsize), neverDeleteData); 377 377 CField::get(fieldid_str)->setData(data); … … 389 389 390 390 CContext* context = CContext::getCurrent(); 391 if (!context->hasServer) context->c lient->checkBuffers();391 if (!context->hasServer) context->checkBuffersAndListen(); 392 392 393 393 CArray<double, 1> data(data_k8, shape(data_Xsize), neverDeleteData); … … 407 407 408 408 CContext* context = CContext::getCurrent(); 409 if (!context->hasServer) context->c lient->checkBuffers();409 if (!context->hasServer) context->checkBuffersAndListen(); 410 410 411 411 CArray<double, 2>data(data_k8, shape(data_Xsize, data_Ysize), neverDeleteData); … … 425 425 426 426 CContext* context = CContext::getCurrent(); 427 if (!context->hasServer) context->c lient->checkBuffers();427 if (!context->hasServer) context->checkBuffersAndListen(); 428 428 429 429 CArray<double, 3>data(data_k8, shape(data_Xsize, data_Ysize, data_Zsize), neverDeleteData); … … 442 442 CTimer::get("XIOS send field").resume(); 443 443 CContext* context = CContext::getCurrent(); 444 if (!context->hasServer) context->c lient->checkBuffers();444 if (!context->hasServer) context->checkBuffersAndListen(); 445 445 446 446 CArray<float, 1> data_tmp(data_k4, shape(data_Xsize), neverDeleteData); … … 461 461 462 462 CContext* context = CContext::getCurrent(); 463 if (!context->hasServer) context->c lient->checkBuffers();463 if (!context->hasServer) context->checkBuffersAndListen(); 464 464 465 465 CArray<float, 1> data_tmp(data_k4, shape(data_Xsize), neverDeleteData); … … 481 481 482 482 CContext* context = CContext::getCurrent(); 483 if (!context->hasServer) context->c lient->checkBuffers();483 if (!context->hasServer) context->checkBuffersAndListen(); 484 484 485 485 CArray<float, 2> data_tmp(data_k4, shape(data_Xsize, data_Ysize), neverDeleteData); … … 501 501 502 502 CContext* context = CContext::getCurrent(); 503 if (!context->hasServer) context->c lient->checkBuffers();503 if (!context->hasServer) context->checkBuffersAndListen(); 504 504 505 505 CArray<float, 3> data_tmp(data_k4, shape(data_Xsize, data_Ysize, data_Zsize), neverDeleteData); … … 523 523 524 524 CContext* context = CContext::getCurrent(); 525 if (!context->hasServer) context->c lient->checkBuffers();525 if (!context->hasServer) context->checkBuffersAndListen(); 526 526 527 527 CArray<double, 1> data(data_k8, shape(data_Xsize), neverDeleteData); … … 541 541 542 542 CContext* context = CContext::getCurrent(); 543 if (!context->hasServer) context->c lient->checkBuffers();543 if (!context->hasServer) context->checkBuffersAndListen(); 544 544 545 545 CArray<double, 2>data(data_k8, shape(data_Xsize, data_Ysize), neverDeleteData); … … 559 559 560 560 CContext* context = CContext::getCurrent(); 561 if (!context->hasServer) context->c lient->checkBuffers();561 if (!context->hasServer) context->checkBuffersAndListen(); 562 562 563 563 CArray<double, 3>data(data_k8, shape(data_Xsize, data_Ysize, data_Zsize), neverDeleteData); … … 577 577 578 578 CContext* context = CContext::getCurrent(); 579 if (!context->hasServer) context->c lient->checkBuffers();579 if (!context->hasServer) context->checkBuffersAndListen(); 580 580 581 581 CArray<double, 1> data(data_Xsize); … … 597 597 598 598 CContext* context = CContext::getCurrent(); 599 if (!context->hasServer) context->c lient->checkBuffers();599 if (!context->hasServer) context->checkBuffersAndListen(); 600 600 601 601 CArray<double, 2> data(data_Xsize, data_Ysize); … … 617 617 618 618 CContext* context = CContext::getCurrent(); 619 if (!context->hasServer) context->c lient->checkBuffers();619 if (!context->hasServer) context->checkBuffersAndListen(); 620 620 621 621 CArray<double, 3> data(data_Xsize, data_Ysize, data_Zsize); -
XIOS/trunk/src/node/context.cpp
r595 r597 23 23 CContext::CContext(void) 24 24 : CObjectTemplate<CContext>(), CContextAttributes() 25 , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_(), idServer_() 25 , calendar(), hasClient(false), hasServer(false), isPostProcessed(false), finalized(false) 26 , dataSize_(), idServer_(), client(0), server(0) 26 27 { /* Ne rien faire de plus */ } 27 28 28 29 CContext::CContext(const StdString & id) 29 30 : CObjectTemplate<CContext>(id), CContextAttributes() 30 , calendar(),hasClient(false),hasServer(false), isPostProcessed(false), dataSize_(), idServer_() 31 , calendar(), hasClient(false), hasServer(false), isPostProcessed(false), finalized(false) 32 , dataSize_(), idServer_(), client(0), server(0) 31 33 { /* Ne rien faire de plus */ } 32 34 33 35 CContext::~CContext(void) 34 36 { 35 if (hasClient)delete client;36 if (hasServer)delete server;37 delete client; 38 delete server; 37 39 } 38 40 … … 231 233 232 234 //! Initialize client side 233 void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer )235 void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer /*= 0*/) 234 236 { 235 237 hasClient=true; 236 238 client = new CContextClient(this,intraComm, interComm, cxtServer); 239 MPI_Comm intraCommServer, interCommServer; 240 if (cxtServer) // Attached mode 241 { 242 intraCommServer = intraComm; 243 interCommServer = interComm; 244 } 245 else 246 { 247 MPI_Comm_dup(intraComm, &intraCommServer); 248 MPI_Comm_dup(interComm, &interCommServer); 249 } 250 server = new CContextServer(this,intraCommServer,interCommServer); 237 251 } 238 252 … … 277 291 278 292 //! Initialize server 279 void CContext::initServer(MPI_Comm intraComm,MPI_Comm interComm )293 void CContext::initServer(MPI_Comm intraComm,MPI_Comm interComm, CContext* cxtClient /*= 0*/) 280 294 { 281 295 hasServer=true; 282 296 server = new CContextServer(this,intraComm,interComm); 297 MPI_Comm intraCommClient, interCommClient; 298 if (cxtClient) // Attached mode 299 { 300 intraCommClient = intraComm; 301 interCommClient = interComm; 302 } 303 else 304 { 305 MPI_Comm_dup(intraComm, &intraCommClient); 306 MPI_Comm_dup(interComm, &interCommClient); 307 } 308 client = new CContextClient(this,intraCommClient,interCommClient, cxtClient); 309 // Do something clever instead 310 std::map<int, StdSize> bufferSize; 311 for (int r = 0; r < client->serverSize; r++) 312 bufferSize[r] = 10 * sizeof(size_t) * 1024; 313 client->setBufferSize(bufferSize); 283 314 } 284 315 … … 289 320 } 290 321 322 //! Try to send the buffers and receive possible answers 323 bool CContext::checkBuffersAndListen(void) 324 { 325 client->checkBuffers(); 326 return server->eventLoop(); 327 } 328 291 329 //! Terminate a context 292 330 void CContext::finalize(void) 293 331 { 294 if (hasClient && !hasServer) 295 { 296 client->finalize(); 297 } 298 if (hasServer) 299 { 300 closeAllFile(); 332 if (!finalized) 333 { 334 finalized = true; 335 336 client->finalize(); 337 while (!server->hasFinished()) 338 { 339 server->eventLoop(); 340 } 341 342 if (hasServer) 343 { 344 closeAllFile(); 345 } 301 346 } 302 347 } -
XIOS/trunk/src/node/context.hpp
r593 r597 87 87 public : 88 88 // Initialize server or client 89 void initServer(MPI_Comm intraComm, MPI_Comm interComm );90 void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer =0);89 void initServer(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtClient = 0); 90 void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer = 0); 91 91 bool isInitialized(void); 92 92 93 93 // Put sever or client into loop state 94 94 bool eventLoop(void); 95 bool serverLoop(void); 96 void clientLoop(void);95 96 bool checkBuffersAndListen(void); 97 97 98 98 // Finalize a context … … 210 210 private: 211 211 bool isPostProcessed; 212 bool finalized; 212 213 std::map<int, StdSize> dataSize_; 213 214 StdString idServer_; -
XIOS/trunk/src/server.cpp
r591 r597 25 25 bool CServer::finished=false ; 26 26 bool CServer::is_MPI_Initialized ; 27 CEventScheduler* CServer::eventScheduler ;27 CEventScheduler* CServer::eventScheduler = 0; 28 28 29 29 void CServer::initialize(void) … … 392 392 for(it=contextList.begin();it!=contextList.end();it++) 393 393 { 394 finished=it->second-> eventLoop();394 finished=it->second->checkBuffersAndListen(); 395 395 if (finished) 396 396 {
Note: See TracChangeset
for help on using the changeset viewer.