Changeset 1009 for XIOS/dev/dev_olga/src/client.cpp
- Timestamp:
- 12/05/16 17:47:54 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/client.cpp
r992 r1009 18 18 MPI_Comm CClient::interComm ; 19 19 std::list<MPI_Comm> CClient::contextInterComms; 20 intCClient::serverLeader;20 vector <int> CClient::serverLeader; 21 21 bool CClient::is_MPI_Initialized ; 22 22 int CClient::rank = INVALID_RANK; … … 103 103 { 104 104 int clientLeader=leaders[hashClient] ; 105 serverLeader=leaders[hashServer] ; 105 // serverLeader=leaders[hashServer] ; 106 serverLeader.push_back(leaders[hashServer]) ; 106 107 int intraCommSize, intraCommRank ; 107 108 MPI_Comm_size(intraComm,&intraCommSize) ; 108 109 MPI_Comm_rank(intraComm,&intraCommRank) ; 109 110 info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 110 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< serverLeader<<endl ; 111 MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 111 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< serverLeader.back()<<endl ; 112 MPI_Intercomm_create(intraComm, 0, CXios::globalComm, serverLeader.back(), 0, &interComm) ; 113 // info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 114 // <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< serverLeader<<endl ; 115 // MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 112 116 } 113 117 else … … 161 165 } 162 166 163 void CClient::initializeClientOnServer(const int rank, MPI_Comm& intraCommPrmSrv, const int srvSndLeader)167 void CClient::initializeClientOnServer(const int rank, const MPI_Comm& intraCommPrmSrv, const int srvSndLeader) 164 168 { 165 169 MPI_Comm_dup(intraCommPrmSrv, &intraComm) ; 166 serverLeader = srvSndLeader;170 serverLeader.push_back(srvSndLeader); 167 171 int intraCommSize, intraCommRank ; 168 172 MPI_Comm_size(intraComm,&intraCommSize) ; 169 173 MPI_Comm_rank(intraComm,&intraCommRank) ; 170 174 info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 171 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< serverLeader<<endl ; 172 MPI_Intercomm_create(intraComm, 0, CXios::globalComm, serverLeader, 0, &interComm) ; 173 } 175 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< srvSndLeader<<endl ; 176 MPI_Intercomm_create(intraComm, 0, CXios::globalComm, srvSndLeader, 0, &interComm) ; 177 } 178 174 179 175 180 ///--------------------------------------------------------------- … … 226 231 buffer<<msg ; 227 232 228 MPI_Send(buff, buffer.count(), MPI_CHAR, serverLeader, 1, CXios::globalComm) ; 233 for (int i = 0; i < serverLeader.size(); ++i) 234 { 235 MPI_Send(buff, buffer.count(), MPI_CHAR, serverLeader[i], 1, CXios::globalComm) ; 236 MPI_Intercomm_create(contextComm, 0, CXios::globalComm, serverLeader[i], 10+globalRank, &contextInterComm) ; 237 info(10)<<"Register new Context : "<<id<<endl ; 238 MPI_Comm inter ; 239 MPI_Intercomm_merge(contextInterComm,0,&inter) ; 240 MPI_Barrier(inter) ; 241 242 context->initClient(contextComm,contextInterComm) ; 243 244 contextInterComms.push_back(contextInterComm); 245 MPI_Comm_free(&inter); 246 } 229 247 delete [] buff ; 230 248 231 MPI_Intercomm_create(contextComm, 0, CXios::globalComm, serverLeader, 10+globalRank, &contextInterComm) ; 232 info(10)<<"Register new Context : "<<id<<endl ; 233 234 MPI_Comm inter ; 235 MPI_Intercomm_merge(contextInterComm,0,&inter) ; 236 MPI_Barrier(inter) ; 237 238 context->initClient(contextComm,contextInterComm) ; 239 240 contextInterComms.push_back(contextInterComm); 241 MPI_Comm_free(&inter); 242 } 243 } 249 } 250 } 251 252 ///--------------------------------------------------------------- 253 /*! 254 * \fn void CClient::registerContext(const string& id, const int poolNb, MPI_Comm contextComm) 255 * Function creates intraComm (CClient::intraComm) for client group with id=codeId and interComm (CClient::interComm) between client and server groups. 256 * \param [in] id id of context. 257 * \param [in] contextComm. 258 */ 259 void CClient::registerContextOnSrvPools(const string& id, MPI_Comm contextComm) 260 { 261 CContext::setCurrent(id) ; 262 CContext* context=CContext::create(id); 263 StdString idServer(id); 264 idServer += "_server_"; 265 266 int size,rank,globalRank ; 267 size_t message_size ; 268 int leaderRank ; 269 MPI_Comm contextInterComm ; 270 271 MPI_Comm_size(contextComm,&size) ; 272 MPI_Comm_rank(contextComm,&rank) ; 273 MPI_Comm_rank(CXios::globalComm,&globalRank) ; 274 if (rank!=0) globalRank=0 ; 275 276 CMessage msg ; 277 278 int messageSize ; 279 void * buff ; 280 281 for (int i = 0; i < serverLeader.size(); ++i) 282 { 283 StdString str = idServer + boost::lexical_cast<string>(i); 284 msg<<str<<size<<globalRank ; 285 messageSize = msg.size() ; 286 buff = new char[messageSize] ; 287 CBufferOut buffer(buff,messageSize) ; 288 buffer<<msg ; 289 290 MPI_Send(buff, buffer.count(), MPI_CHAR, serverLeader[i], 1, CXios::globalComm) ; 291 MPI_Intercomm_create(contextComm, 0, CXios::globalComm, serverLeader[i], 10+globalRank, &contextInterComm) ; 292 info(10)<<"Register new Context : "<<id<<endl ; 293 MPI_Comm inter ; 294 MPI_Intercomm_merge(contextInterComm,0,&inter) ; 295 MPI_Barrier(inter) ; 296 297 context->initClient(contextComm,contextInterComm) ; 298 299 contextInterComms.push_back(contextInterComm); 300 MPI_Comm_free(&inter); 301 delete [] buff ; 302 } 303 } 244 304 245 305 void CClient::finalize(void)
Note: See TracChangeset
for help on using the changeset viewer.