Changeset 983 for XIOS/dev/dev_olga/src/server.cpp
- Timestamp:
- 11/07/16 17:55:55 (7 years ago)
- Location:
- XIOS/dev/dev_olga
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/server.cpp
r956 r983 3 3 #include "cxios.hpp" 4 4 #include "server.hpp" 5 #include "client.hpp" 5 6 #include "type.hpp" 6 7 #include "context.hpp" … … 19 20 list<MPI_Comm> CServer::interComm ; 20 21 std::list<MPI_Comm> CServer::contextInterComms; 21 bool CServer::isRoot ;22 bool CServer::isRoot = false ; 22 23 int CServer::rank = INVALID_RANK; 23 24 StdOFStream CServer::m_infoStream; … … 27 28 bool CServer::is_MPI_Initialized ; 28 29 CEventScheduler* CServer::eventScheduler = 0; 29 30 31 //--------------------------------------------------------------- 32 /*! 33 * \fn void CServer::initialize(void) 34 * Function creates intra and inter comm for each initialized server pool 35 */ 30 36 void CServer::initialize(void) 31 37 { … … 45 51 CTimer::get("XIOS").resume() ; 46 52 53 int nbSrvLevels = 2; 54 47 55 boost::hash<string> hashString ; 48 49 unsigned long hashServer=hashString(CXios::xiosCodeId) ; 56 unsigned long hashServer1 = hashString(CXios::xiosCodeIdPrm); 57 unsigned long hashServer2 = hashString(CXios::xiosCodeIdSnd); 58 unsigned long hashServer = (CXios::serverLevel < 2) ? hashServer1 : hashServer2; 59 50 60 unsigned long* hashAll ; 51 61 … … 56 66 MPI_Comm newComm ; 57 67 58 MPI_Comm_size(CXios::globalComm, &size) ;59 MPI_Comm_rank(CXios::globalComm, &rank);68 MPI_Comm_size(CXios::globalComm, &size) ; 69 MPI_Comm_rank(CXios::globalComm, &rank); 60 70 hashAll=new unsigned long[size] ; 61 62 MPI_Allgather(&hashServer,1,MPI_LONG,hashAll,1,MPI_LONG,CXios::globalComm) ; 71 MPI_Allgather(&hashServer, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ; 63 72 64 73 map<unsigned long, int> colors ; … … 77 86 78 87 myColor=colors[hashServer] ; 79 MPI_Comm_split(MPI_COMM_WORLD,myColor,rank,&intraComm) ; 80 81 int serverLeader=leaders[hashServer] ; 82 int clientLeader; 83 84 serverLeader=leaders[hashServer] ; 85 for(it=leaders.begin();it!=leaders.end();it++) 86 { 87 if (it->first!=hashServer) 88 { 89 clientLeader=it->second ; 90 int intraCommSize, intraCommRank ; 91 MPI_Comm_size(intraComm,&intraCommSize) ; 92 MPI_Comm_rank(intraComm,&intraCommRank) ; 93 info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize 94 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< clientLeader<<endl ; 95 96 MPI_Intercomm_create(intraComm,0,CXios::globalComm,clientLeader,0,&newComm) ; 97 interComm.push_back(newComm) ; 98 } 99 } 100 101 delete [] hashAll ; 88 MPI_Comm_split(MPI_COMM_WORLD, myColor, rank, &intraComm) ; 89 90 if (CXios::serverLevel == 0) 91 { 92 int clientLeader; 93 for(it=leaders.begin();it!=leaders.end();it++) 94 { 95 if (it->first!=hashServer) 96 { 97 clientLeader=it->second ; 98 int intraCommSize, intraCommRank ; 99 MPI_Comm_size(intraComm,&intraCommSize) ; 100 MPI_Comm_rank(intraComm,&intraCommRank) ; 101 info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize 102 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< clientLeader<<endl ; 103 104 MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 105 interComm.push_back(newComm) ; 106 } 107 } 108 } 109 110 else if ((CXios::serverLevel == 1)) 111 { 112 int clientLeader; 113 int srvSndLeader; 114 for(it=leaders.begin();it!=leaders.end();it++) 115 { 116 if (it->first != hashServer2) 117 { 118 if (it->first != hashServer1) 119 { 120 clientLeader=it->second ; 121 int intraCommSize, intraCommRank ; 122 MPI_Comm_size(intraComm,&intraCommSize) ; 123 MPI_Comm_rank(intraComm,&intraCommRank) ; 124 info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize 125 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< clientLeader<<endl ; 126 MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 127 interComm.push_back(newComm) ; 128 } 129 } 130 else 131 { 132 srvSndLeader = it->second; 133 } 134 } 135 136 CClient::initializeClientOnServer(rank, intraComm, srvSndLeader); 137 } 138 139 else // secondary server pool 140 { 141 int clientLeader; 142 for(it=leaders.begin();it!=leaders.end();it++) 143 { 144 if (it->first == hashServer1) 145 { 146 // no changes needed here to create one context per process of the secondary server pool 147 clientLeader=it->second ; 148 int intraCommSize, intraCommRank ; 149 MPI_Comm_size(intraComm,&intraCommSize) ; 150 MPI_Comm_rank(intraComm,&intraCommRank) ; 151 info(50)<<"intercommCreate::server "<<rank<<" intraCommSize : "<<intraCommSize 152 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< clientLeader<<endl ; 153 154 MPI_Intercomm_create(intraComm, 0, CXios::globalComm, clientLeader, 0, &newComm) ; 155 interComm.push_back(newComm) ; 156 157 break; 158 } 159 } 160 } 161 162 delete [] hashAll ; 163 102 164 } 103 165 // using OASIS … … 145 207 void CServer::finalize(void) 146 208 { 209 if (CXios::serverLevel == 1) 210 { 211 CClient::finalize(); 212 } 213 147 214 CTimer::get("XIOS").suspend() ; 148 215 … … 151 218 for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 152 219 MPI_Comm_free(&(*it)); 220 153 221 for (std::list<MPI_Comm>::iterator it = interComm.begin(); it != interComm.end(); it++) 154 222 MPI_Comm_free(&(*it)); 223 155 224 MPI_Comm_free(&intraComm); 156 225 … … 172 241 while(!stop) 173 242 { 243 174 244 if (isRoot) 175 245 { … … 186 256 if (finished && contextList.empty()) stop=true ; 187 257 eventScheduler->checkEvent() ; 258 188 259 } 189 260 CTimer::get("XIOS server").suspend() ; … … 288 359 void CServer::recvContextMessage(void* buff,int count) 289 360 { 290 static map<string,contextMessage> recvContextId ; 361 static map<string,contextMessage> recvContextId; 362 291 363 map<string,contextMessage>::iterator it ; 292 364 … … 362 434 MPI_Get_count(&status,MPI_CHAR,&count) ; 363 435 registerContext(buffer,count) ; 436 364 437 delete [] buffer ; 365 438 recept=false ; … … 373 446 CBufferIn buffer(buff, count); 374 447 buffer >> contextId; 448 CContext* context; 375 449 376 450 info(20) << "CServer : Register new Context : " << contextId << endl; … … 380 454 << "Context '" << contextId << "' has already been registred"); 381 455 382 MPI_Comm contextInter comm;383 MPI_Intercomm_create(intraComm,0,CXios::globalComm,leaderRank,10+leaderRank,&contextInter comm);456 MPI_Comm contextInterComm; 457 MPI_Intercomm_create(intraComm,0,CXios::globalComm,leaderRank,10+leaderRank,&contextInterComm); 384 458 385 459 MPI_Comm inter; 386 MPI_Intercomm_merge(contextInter comm,1,&inter);460 MPI_Intercomm_merge(contextInterComm,1,&inter); 387 461 MPI_Barrier(inter); 388 462 389 CContext*context=CContext::create(contextId);463 context=CContext::create(contextId); 390 464 contextList[contextId]=context; 391 context->initServer(intraComm,contextIntercomm); 392 393 contextInterComms.push_back(contextIntercomm); 465 context->initServer(intraComm,contextInterComm); 466 contextInterComms.push_back(contextInterComm); 467 468 if (CXios::serverLevel == 1) 469 { 470 CClient::registerContext(contextId, intraComm); 471 } 472 394 473 MPI_Comm_free(&inter); 474 395 475 } 396 476 … … 399 479 bool finished ; 400 480 map<string,CContext*>::iterator it ; 481 401 482 for(it=contextList.begin();it!=contextList.end();it++) 402 483 { … … 408 489 } 409 490 } 410 411 491 } 412 492
Note: See TracChangeset
for help on using the changeset viewer.