Changeset 1194 for XIOS/dev/dev_olga/src
- Timestamp:
- 07/04/17 14:28:50 (7 years ago)
- Location:
- XIOS/dev/dev_olga/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/context_client.cpp
r1193 r1194 248 248 if (!mapBufferSize_.count(rank)) 249 249 { 250 error(0) << "WARNING: Unexpected request for buffer to communicate with server " << rank << std::endl;250 // error(0) << "WARNING: Unexpected request for buffer to communicate with server " << rank << std::endl; 251 251 mapBufferSize_[rank] = CXios::minBufferSize; 252 252 } … … 423 423 } 424 424 425 /*!426 * Finalize context client and do some reports. Function is non-blocking.427 */428 void CContextClient::postFinalize(void)429 {430 map<int,CClientBuffer*>::iterator itBuff;431 bool stop = false;432 433 CTimer::get("Blocking time").resume();434 while (hasTemporarilyBufferedEvent())435 {436 checkBuffers();437 sendTemporarilyBufferedEvent();438 }439 CTimer::get("Blocking time").suspend();440 441 CEventClient event(CContext::GetType(), CContext::EVENT_ID_CONTEXT_POST_FINALIZE);442 if (isServerLeader())443 {444 CMessage msg;445 const std::list<int>& ranks = getRanksServerLeader();446 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)447 event.push(*itRank, 1, msg);448 sendEvent(event);449 }450 else sendEvent(event);451 452 CTimer::get("Blocking time").resume();453 // while (!stop)454 {455 checkBuffers();456 if (hasTemporarilyBufferedEvent())457 sendTemporarilyBufferedEvent();458 stop = true;459 // for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++) stop &= !itBuff->second->hasPendingRequest();460 }461 CTimer::get("Blocking time").suspend();462 463 }464 425 465 426 /*! -
XIOS/dev/dev_olga/src/context_client.hpp
r1158 r1194 53 53 // void closeContext(void); Never been implemented. 54 54 void finalize(void); 55 void postFinalize(void);56 55 57 56 void setBufferSize(const std::map<int,StdSize>& mapSize, const std::map<int,StdSize>& maxEventSize); -
XIOS/dev/dev_olga/src/context_server.cpp
r1193 r1194 223 223 { 224 224 finished=true; 225 info(20)<<" CContextServer: Receive context <"<<context->getId()<<"> finalize."<<endl; 226 context->finalize(); 225 227 std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 226 228 iteMap = mapBufferSize_.end(), itMap; … … 232 234 totalBuf += itMap->second; 233 235 } 234 context->finalize();235 236 report(0)<< " Memory report : Context <"<<ctxId<<"> : server side : total memory used for buffer "<<totalBuf<<" bytes"<<endl; 236 }237 else if (event.classId==CContext::GetType() && event.type==CContext::EVENT_ID_CONTEXT_POST_FINALIZE)238 {239 info(20)<<" CContextServer: Receive context <"<<context->getId()<<"> finalize."<<endl;240 context->postFinalize();241 237 } 242 238 else if (event.classId==CContext::GetType()) CContext::dispatchEvent(event); -
XIOS/dev/dev_olga/src/node/context.cpp
r1193 r1194 413 413 // (1) blocking send context finalize to its server 414 414 // (2) blocking receive context finalize from its server 415 // (3) s end post finalize to its server415 // (3) some memory deallocations 416 416 if (CXios::isClient) 417 417 { … … 428 428 server->eventLoop(); 429 429 430 if (CXios::isServer) // Mode attache 431 postFinalize(); 432 else // Mode server 433 client->postFinalize(); 434 435 } 436 } 437 // Server: non-blocking send context finalize 430 if (hasServer) // Mode attache 431 { 432 closeAllFile(); 433 registryOut->hierarchicalGatherRegistry() ; 434 if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 435 } 436 437 //! Deallocate client buffers 438 client->releaseBuffers(); 439 440 //! Free internally allocated communicators 441 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 442 MPI_Comm_free(&(*it)); 443 comms.clear(); 444 445 info(20)<<"CContext: Context <"<<getId()<<"> is finalized."<<endl; 446 } 447 } 438 448 else if (CXios::isServer) 439 449 { 440 // First context finalize message received from a model => send context finalize to its child contexts (if any) 450 // First context finalize message received from a model 451 // Send context finalize to its child contexts (if any) 441 452 if (countChildCtx_ == 0) 442 453 for (int i = 0; i < clientPrimServer.size(); ++i) … … 445 456 // (Last) context finalized message received 446 457 if (countChildCtx_ == clientPrimServer.size()) 458 { 459 // Blocking send of context finalize message to its client (e.g. primary server or model) 447 460 client->finalize(); 461 bool bufferReleased; 462 do 463 { 464 client->checkBuffers(); 465 bufferReleased = !client->havePendingRequests(); 466 } while (!bufferReleased); 467 finalized = true; 468 469 if (hasServer && !hasClient) 470 { 471 closeAllFile(); 472 registryOut->hierarchicalGatherRegistry() ; 473 if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 474 } 475 476 //! Deallocate client buffers 477 client->releaseBuffers(); 478 for (int i = 0; i < clientPrimServer.size(); ++i) 479 clientPrimServer[i]->releaseBuffers(); 480 481 //! Free internally allocated communicators 482 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 483 MPI_Comm_free(&(*it)); 484 comms.clear(); 485 486 info(20)<<"CContext: Context <"<<getId()<<"> is finalized."<<endl; 487 } 448 488 449 489 ++countChildCtx_; 450 490 } 451 }452 453 /*!454 * \fn void CContext::postFinalize(void)455 * Close files, gather registries, and make deallocations.456 * Function is called when a context is finalized.457 */458 void CContext::postFinalize(void)459 {460 finalized = true;461 462 // Primary server: blocking send post finalize to secondary servers463 for (int i = 0; i < clientPrimServer.size(); ++i)464 clientPrimServer[i]->postFinalize();465 bool buffersReleased;466 do467 {468 buffersReleased = true;469 for (int i = 0; i < clientPrimServer.size(); ++i)470 {471 clientPrimServer[i]->checkBuffers();472 buffersReleased *= !clientPrimServer[i]->havePendingRequests();473 }474 } while (!buffersReleased);475 476 // Primary or classical server: block until all messages are sent to model477 // Client (model): block until all messages are sent to server478 if ( CServer::serverLevel==0 || CServer::serverLevel==1 || !hasServer)479 do480 {481 client->checkBuffers();482 buffersReleased = !client->havePendingRequests();483 } while (!buffersReleased);484 485 if (hasServer && !hasClient)486 {487 closeAllFile();488 registryOut->hierarchicalGatherRegistry() ;489 if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ;490 }491 492 //! Deallocate client buffers493 client->releaseBuffers();494 for (int i = 0; i < clientPrimServer.size(); ++i)495 clientPrimServer[i]->releaseBuffers();496 497 //! Free internally allocated communicators498 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it)499 MPI_Comm_free(&(*it));500 comms.clear();501 502 info(20)<<"CContext: Context <"<<getId()<<"> is finalized."<<endl;503 504 491 } 505 492 … … 530 517 checkGridEnabledFields(); 531 518 532 setClientServerBuffer(client); 519 // Buffer for primary server for connection to client will be allocated by default (to min size) 520 if (CServer::serverLevel != 1) 521 setClientServerBuffer(client); 533 522 if (hasServer) 534 523 for (int i = 0; i < clientPrimServer.size(); ++i) -
XIOS/dev/dev_olga/src/node/context.hpp
r1184 r1194 51 51 EVENT_ID_CLOSE_DEFINITION,EVENT_ID_UPDATE_CALENDAR, 52 52 EVENT_ID_CREATE_FILE_HEADER,EVENT_ID_CONTEXT_FINALIZE, 53 EVENT_ID_CONTEXT_POST_FINALIZE,54 53 EVENT_ID_POST_PROCESS, EVENT_ID_SEND_REGISTRY, 55 54 EVENT_ID_POST_PROCESS_GLOBAL_ATTRIBUTES, … … 100 99 // Finalize a context 101 100 void finalize(void); 102 void postFinalize(void);103 101 bool isFinalized(void); 104 102
Note: See TracChangeset
for help on using the changeset viewer.