Changeset 1071 for XIOS/dev/dev_olga/src/node/context.cpp
- Timestamp:
- 03/13/17 17:21:04 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/node/context.cpp
r1054 r1071 28 28 , isPostProcessed(false), finalized(false) 29 29 , idServer_(), client(0), server(0) 30 // , clientPrimServer(0), serverPrimServer(0)31 30 , allProcessed(false) 32 31 { /* Ne rien faire de plus */ } … … 37 36 , isPostProcessed(false), finalized(false) 38 37 , idServer_(), client(0), server(0) 39 // , clientPrimServer(0), serverPrimServer(0)40 38 , allProcessed(false) 41 39 { /* Ne rien faire de plus */ } … … 45 43 delete client; 46 44 delete server; 47 // delete clientPrimServer;48 // delete serverPrimServer;45 for (std::vector<CContextClient*>::iterator it = clientPrimServer.begin(); it != clientPrimServer.end(); it++) delete *it; 46 for (std::vector<CContextServer*>::iterator it = serverPrimServer.begin(); it != serverPrimServer.end(); it++) delete *it; 49 47 } 50 48 … … 249 247 250 248 hasClient = true; 249 MPI_Comm intraCommServer, interCommServer; 251 250 252 251 if (CServer::serverLevel != 1) 253 // initClient is called by client252 // initClient is called by client 254 253 { 255 254 client = new CContextClient(this, intraComm, interComm, cxtServer); 256 server = new CContextServer(this, intraComm, interComm);257 MPI_Comm intraCommServer, interCommServer;258 255 if (cxtServer) // Attached mode 259 256 { … … 263 260 else 264 261 { 265 // MPI_Comm_dup(intraComm, &intraCommServer); 266 // comms.push_back(intraCommServer); 267 // MPI_Comm_dup(interComm, &interCommServer); 268 // comms.push_back(interCommServer); 269 } 270 } 271 262 MPI_Comm_dup(intraComm, &intraCommServer); 263 comms.push_back(intraCommServer); 264 MPI_Comm_dup(interComm, &interCommServer); 265 comms.push_back(interCommServer); 266 } 267 registryIn=new CRegistry(intraComm); 268 registryIn->setPath(getId()) ; 269 if (client->clientRank==0) registryIn->fromFile("xios_registry.bin") ; 270 registryIn->bcastRegistry() ; 271 registryOut=new CRegistry(intraComm) ; 272 registryOut->setPath(getId()) ; 273 274 server = new CContextServer(this, intraCommServer, interCommServer); 275 } 272 276 else 273 277 // initClient is called by primary server 274 278 { 275 279 clientPrimServer.push_back(new CContextClient(this, intraComm, interComm)); 276 serverPrimServer.push_back(new CContextServer(this, intraComm, interComm)); 277 } 278 279 280 281 // registryIn=new CRegistry(intraComm); 282 // registryIn->setPath(getId()) ; 283 // if (client->clientRank==0) registryIn->fromFile("xios_registry.bin") ; 284 // registryIn->bcastRegistry() ; 285 // 286 // registryOut=new CRegistry(intraComm) ; 287 // registryOut->setPath(getId()) ; 288 289 280 MPI_Comm_dup(intraComm, &intraCommServer); 281 comms.push_back(intraCommServer); 282 MPI_Comm_dup(interComm, &interCommServer); 283 comms.push_back(interCommServer); 284 serverPrimServer.push_back(new CContextServer(this, intraCommServer, interCommServer)); 285 } 290 286 } 291 287 … … 354 350 hasServer=true; 355 351 server = new CContextServer(this,intraComm,interComm); 356 client = new CContextClient(this,intraComm,interComm);357 352 // client = new CContextClient(this,intraComm,interComm, cxtClient); 358 353 359 //registryIn=new CRegistry(intraComm);360 //registryIn->setPath(getId()) ;361 //if (server->intraCommRank==0) registryIn->fromFile("xios_registry.bin") ;362 //registryIn->bcastRegistry() ;363 //registryOut=new CRegistry(intraComm) ;364 //registryOut->setPath(getId()) ;354 registryIn=new CRegistry(intraComm); 355 registryIn->setPath(getId()) ; 356 if (server->intraCommRank==0) registryIn->fromFile("xios_registry.bin") ; 357 registryIn->bcastRegistry() ; 358 registryOut=new CRegistry(intraComm) ; 359 registryOut->setPath(getId()) ; 365 360 366 361 MPI_Comm intraCommClient, interCommClient; … … 372 367 else 373 368 { 374 // MPI_Comm_dup(intraComm, &intraCommClient); 375 // comms.push_back(intraCommClient); 376 // MPI_Comm_dup(interComm, &interCommClient); 377 // comms.push_back(interCommClient); 378 } 379 380 } 381 382 //! Server side: Put server into a loop in order to listen message from client 383 // bool CContext::eventLoop(void) 384 // { 385 // if (CServer::serverLevel == 0) 386 // { 387 // return server->eventLoop(); 388 // } 389 // else if (CServer::serverLevel == 1) 390 // { 391 // bool serverFinished = server->eventLoop(); 392 // bool serverPrimFinished = true; 393 // for (int i = 0; i < serverPrimServer.size(); ++i) 394 // { 395 // serverPrimFinished *= serverPrimServer[i]->eventLoop(); 396 // } 397 // return ( serverFinished && serverPrimFinished); 398 // } 399 // else 400 // { 401 // return server->eventLoop(); 402 // } 403 // } 369 MPI_Comm_dup(intraComm, &intraCommClient); 370 comms.push_back(intraCommClient); 371 MPI_Comm_dup(interComm, &interCommClient); 372 comms.push_back(interCommClient); 373 } 374 client = new CContextClient(this,intraCommClient,interCommClient); 375 376 } 404 377 405 378 //! Try to send the buffers and receive possible answers … … 412 385 if (hasTmpBufferedEvent) 413 386 hasTmpBufferedEvent = !client->sendTemporarilyBufferedEvent(); 414 415 387 // Don't process events if there is a temporarily buffered event 416 388 return server->eventLoop(!hasTmpBufferedEvent); … … 432 404 if (hasTmpBufferedEventPrim) 433 405 hasTmpBufferedEventPrim = !clientPrimServer[i]->sendTemporarilyBufferedEvent(); 434 serverPrimFinished *= serverPrimServer[i]->eventLoop(hasTmpBufferedEventPrim); 406 // serverPrimFinished *= serverPrimServer[i]->eventLoop(!hasTmpBufferedEventPrim); 407 serverPrimFinished *= serverPrimServer[i]->eventLoop(); 435 408 } 436 409 return ( serverFinished && serverPrimFinished); … … 441 414 client->checkBuffers(); 442 415 bool hasTmpBufferedEvent = client->hasTemporarilyBufferedEvent(); 443 if (hasTmpBufferedEvent) 444 hasTmpBufferedEvent = !client->sendTemporarilyBufferedEvent(); 445 return server->eventLoop(!hasTmpBufferedEvent); 446 } 416 // if (hasTmpBufferedEvent) 417 // hasTmpBufferedEvent = !client->sendTemporarilyBufferedEvent(); 418 // return server->eventLoop(!hasTmpBufferedEvent); 419 return server->eventLoop(); 420 } 447 421 } 448 422 … … 453 427 { 454 428 finalized = true; 455 // if (hasClient) sendRegistry() ; 456 457 client->finalize(); 458 while (!server->hasFinished()) 459 { 460 server->eventLoop(); 461 } 429 430 if (hasClient) sendRegistry() ; 462 431 463 432 if ((hasClient) && (hasServer)) … … 475 444 } 476 445 } 477 446 client->finalize(); 447 while (!server->hasFinished()) 448 { 449 server->eventLoop(); 450 } 451 452 info(20)<<"Server Side context <"<<getId()<<"> finalized"<<endl; 478 453 report(0)<< " Memory report : Context <"<<getId()<<"> : server side : total memory used for buffers "<<CContextServer::getTotalBuf()<<" bytes"<<endl; 479 454 … … 482 457 { 483 458 closeAllFile(); 484 // registryOut->hierarchicalGatherRegistry() ; 485 // if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 486 } 487 488 for (std::vector<CContextClient*>::iterator it = clientPrimServer.begin(); it != clientPrimServer.end(); it++) 489 delete *it; 490 491 for (std::vector<CContextServer*>::iterator it = serverPrimServer.begin(); it != serverPrimServer.end(); it++) 492 delete *it; 493 494 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 495 MPI_Comm_free(&(*it)); 496 comms.clear(); 459 registryOut->hierarchicalGatherRegistry() ; 460 if (server->intraCommRank==0) CXios::globalRegistry->mergeRegistry(*registryOut) ; 461 } 462 463 // for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 464 // MPI_Comm_free(&(*it)); 465 // comms.clear(); 497 466 498 467 } 499 468 } 500 469 //! Free internally allocated communicators 470 void CContext::freeComms(void) 471 { 472 for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it) 473 MPI_Comm_free(&(*it)); 474 comms.clear(); 475 } 501 476 502 477 void CContext::postProcessingGlobalAttributes() … … 1597 1572 1598 1573 // Use correct context client to send message 1599 // int nbSrvPools = (hasServer) ? clientPrimServer.size() : 1;1600 1574 int nbSrvPools = (this->hasServer) ? (this->hasClient ? this->clientPrimServer.size() : 0) : 1; 1601 1575 for (int i = 0; i < nbSrvPools; ++i) … … 1618 1592 else contextClientTmp->sendEvent(event); 1619 1593 } 1620 1621 // if (!hasServer)1622 // {1623 // if (client->isServerLeader())1624 // {1625 // CMessage msg ;1626 // msg<<this->getIdServer();1627 // if (client->clientRank==0) msg<<*registryOut ;1628 // const std::list<int>& ranks = client->getRanksServerLeader();1629 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)1630 // event.push(*itRank,1,msg);1631 // client->sendEvent(event);1632 // }1633 // else client->sendEvent(event);1634 // }1635 // else1636 // {1637 // if (clientPrimServer->isServerLeader())1638 // {1639 // CMessage msg ;1640 // msg<<this->getIdServer();1641 // if (clientPrimServer->clientRank==0) msg<<*registryOut ;1642 // const std::list<int>& ranks = clientPrimServer->getRanksServerLeader();1643 // for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)1644 // event.push(*itRank,1,msg);1645 // clientPrimServer->sendEvent(event);1646 // }1647 // else clientPrimServer->sendEvent(event);1648 // }1649 1594 } 1650 1595
Note: See TracChangeset
for help on using the changeset viewer.