Changeset 983 for XIOS/dev/dev_olga/src/client.cpp
- Timestamp:
- 11/07/16 17:55:55 (8 years ago)
- Location:
- XIOS/dev/dev_olga
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/client.cpp
r925 r983 18 18 MPI_Comm CClient::interComm ; 19 19 std::list<MPI_Comm> CClient::contextInterComms; 20 int CClient::serverLeader 20 int CClient::serverLeader; 21 21 bool CClient::is_MPI_Initialized ; 22 22 int CClient::rank = INVALID_RANK; … … 24 24 StdOFStream CClient::m_errorStream; 25 25 26 void CClient::initialize(const string& codeId,MPI_Comm& localComm,MPI_Comm& returnComm) 26 ///--------------------------------------------------------------- 27 /*! 28 * \fn void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 29 * Function creates intraComm (CClient::intraComm) for client group with id=codeId and interComm (CClient::interComm) between client and server groups. 30 * \param [in] codeId identity of context. 31 * \param [in/out] localComm local communicator. 32 * \param [in/out] returnComm (intra)communicator of client group. 33 */ 34 35 void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 27 36 { 28 37 int initialized ; … … 34 43 if (!CXios::usingOasis) 35 44 { 36 // localComm doesn't given45 // localComm isn't given 37 46 if (localComm == MPI_COMM_NULL) 38 47 { … … 45 54 boost::hash<string> hashString ; 46 55 47 unsigned long hashClient =hashString(codeId) ;48 unsigned long hashServer =hashString(CXios::xiosCodeId);56 unsigned long hashClient = hashString(codeId) ; 57 unsigned long hashServer = hashString(CXios::xiosCodeIdPrm); 49 58 unsigned long* hashAll ; 50 59 int size ; … … 58 67 hashAll=new unsigned long[size] ; 59 68 60 MPI_Allgather(&hashClient, 1,MPI_LONG,hashAll,1,MPI_LONG,CXios::globalComm) ;69 MPI_Allgather(&hashClient, 1, MPI_LONG, hashAll, 1, MPI_LONG, CXios::globalComm) ; 61 70 62 71 map<unsigned long, int> colors ; … … 77 86 for (i=0; i < size; ++i) 78 87 { 79 if (hashServer == hashAll[i]) 88 if ((hashAll[i] == hashString(CXios::xiosCodeId)) 89 || (hashAll[i] == hashString(CXios::xiosCodeIdPrm)) 90 || (hashAll[i] == hashString(CXios::xiosCodeIdSnd))) 80 91 { 81 92 CXios::setUsingServer(); … … 85 96 86 97 myColor=colors[hashClient] ; 87 88 98 MPI_Comm_split(CXios::globalComm,myColor,rank,&intraComm) ; 89 99 … … 92 102 int clientLeader=leaders[hashClient] ; 93 103 serverLeader=leaders[hashServer] ; 94 95 104 int intraCommSize, intraCommRank ; 96 105 MPI_Comm_size(intraComm,&intraCommSize) ; 97 106 MPI_Comm_rank(intraComm,&intraCommRank) ; 98 107 info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 99 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< serverLeader<<endl ;100 MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ;108 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< serverLeader<<endl ; 109 MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 101 110 } 102 111 else … … 123 132 else 124 133 { 125 // localComm doesn't given134 // localComm isn't given 126 135 if (localComm == MPI_COMM_NULL) 127 136 { … … 150 159 } 151 160 152 153 void CClient::registerContext(const string& id,MPI_Comm contextComm) 161 void CClient::initializeClientOnServer(const int rank, MPI_Comm& intraCommPrmSrv, const int srvSndLeader) 162 { 163 MPI_Comm_dup(intraCommPrmSrv, &intraComm) ; 164 serverLeader = srvSndLeader; 165 int intraCommSize, intraCommRank ; 166 MPI_Comm_size(intraComm,&intraCommSize) ; 167 MPI_Comm_rank(intraComm,&intraCommRank) ; 168 info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 169 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< serverLeader<<endl ; 170 MPI_Intercomm_create(intraComm, 0, CXios::globalComm, serverLeader, 0, &interComm) ; 171 } 172 173 ///--------------------------------------------------------------- 174 /*! 175 * \fn void CClient::registerContext(const string& id, MPI_Comm contextComm) 176 * Function creates intraComm (CClient::intraComm) for client group with id=codeId and interComm (CClient::interComm) between client and server groups. 177 * \param [in] id id of context. 178 * \param [in] contextComm. 179 */ 180 void CClient::registerContext(const string& id, MPI_Comm contextComm) 154 181 { 155 182 CContext::setCurrent(id) ; … … 158 185 idServer += "_server"; 159 186 160 if (!CXios::isServer) 187 if (CXios::isServer && !context->hasServer) 188 // Attached mode 189 { 190 MPI_Comm contextInterComm ; 191 MPI_Comm_dup(contextComm,&contextInterComm) ; 192 CContext* contextServer = CContext::create(idServer); 193 194 // Firstly, initialize context on client side 195 context->initClient(contextComm,contextInterComm, contextServer); 196 197 // Secondly, initialize context on server side 198 contextServer->initServer(contextComm,contextInterComm, context); 199 200 // Finally, we should return current context to context client 201 CContext::setCurrent(id); 202 203 contextInterComms.push_back(contextInterComm); 204 } 205 else 161 206 { 162 207 int size,rank,globalRank ; … … 170 215 if (rank!=0) globalRank=0 ; 171 216 172 173 217 CMessage msg ; 174 218 msg<<idServer<<size<<globalRank ; … … 180 224 buffer<<msg ; 181 225 182 MPI_Send(buff, buffer.count(),MPI_CHAR,serverLeader,1,CXios::globalComm) ;226 MPI_Send(buff, buffer.count(), MPI_CHAR, serverLeader, 1, CXios::globalComm) ; 183 227 delete [] buff ; 184 228 185 MPI_Intercomm_create(contextComm, 0,CXios::globalComm,serverLeader,10+globalRank,&contextInterComm) ;229 MPI_Intercomm_create(contextComm, 0, CXios::globalComm, serverLeader, 10+globalRank, &contextInterComm) ; 186 230 info(10)<<"Register new Context : "<<id<<endl ; 187 231 … … 195 239 MPI_Comm_free(&inter); 196 240 } 197 else198 {199 MPI_Comm contextInterComm ;200 MPI_Comm_dup(contextComm,&contextInterComm) ;201 CContext* contextServer = CContext::create(idServer);202 203 // Firstly, initialize context on client side204 context->initClient(contextComm,contextInterComm, contextServer);205 206 // Secondly, initialize context on server side207 contextServer->initServer(contextComm,contextInterComm, context);208 209 // Finally, we should return current context to context client210 CContext::setCurrent(id);211 212 contextInterComms.push_back(contextInterComm);213 }214 241 } 215 242 … … 221 248 MPI_Comm_rank(intraComm,&rank) ; 222 249 223 if ( !CXios::isServer)250 if ((!CXios::isServer) || (CXios::serverLevel == 1)) 224 251 { 225 252 MPI_Comm_rank(intraComm,&rank) ; … … 252 279 report(0)<< " Memory report : Minimum buffer size required : " << CClientBuffer::maxRequestSize << " bytes" << endl ; 253 280 report(0)<< " Memory report : increasing it by a factor will increase performance, depending of the volume of data wrote in file at each time step of the file"<<endl ; 281 254 282 } 255 283
Note: See TracChangeset
for help on using the changeset viewer.