Changeset 983 for XIOS/dev/dev_olga/src
- Timestamp:
- 11/07/16 17:55:55 (8 years ago)
- Location:
- XIOS/dev/dev_olga
- Files:
-
- 23 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/buffer_client.cpp
r917 r983 86 86 if (count > 0) 87 87 { 88 MPI_Issend(buffer[current], count, MPI_CHAR, serverRank, 20, interComm, &request); 88 MPI_Comm_test_inter(interComm, &flag); 89 // if (flag) 90 MPI_Issend(buffer[current], count, MPI_CHAR, serverRank, 20, interComm, &request); 91 // else 92 // ERROR("bool CClientBuffer::checkBuffer(void)", 93 // << "Invalid intercommunicator"); 89 94 pending = true; 90 95 if (current == 1) current = 0; -
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 -
XIOS/dev/dev_olga/src/client.hpp
r655 r983 11 11 public: 12 12 static void initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm); 13 static void initializeClientOnServer(const int rank, MPI_Comm& localComm, const int srvSndLeader); 13 14 static void finalize(void); 14 15 static void registerContext(const string& id, MPI_Comm contextComm); -
XIOS/dev/dev_olga/src/config/file_attribute.conf
r878 r983 20 20 DECLARE_ATTRIBUTE(StdString, time_counter_name) 21 21 DECLARE_ATTRIBUTE(int, record_offset) 22 DECLARE_ATTRIBUTE(bool, 22 DECLARE_ATTRIBUTE(bool, cyclic) 23 23 24 24 DECLARE_ATTRIBUTE(int, compression_level) 25 DECLARE_ATTRIBUTE(bool, coupler) 25 26 26 27 DECLARE_ENUM4(timeseries, none, only, both, exclusive) -
XIOS/dev/dev_olga/src/context_client.cpp
r917 r983 18 18 \param [in] intraComm_ communicator of group client 19 19 \param [in] interComm_ communicator of group server 20 \cxtSer [in] cxtSer Pointer to context of server side. (It is only used on case of attached mode)20 \cxtSer [in] cxtSer Pointer to context of server side. (It is only used in case of attached mode). 21 21 */ 22 22 CContextClient::CContextClient(CContext* parent, MPI_Comm intraComm_, MPI_Comm interComm_, CContext* cxtSer) -
XIOS/dev/dev_olga/src/context_server.cpp
r887 r983 34 34 if (flag) MPI_Comm_remote_size(interComm,&commSize); 35 35 else MPI_Comm_size(interComm,&commSize); 36 36 37 currentTimeLine=0; 37 38 scheduled=false; … … 159 160 count=buffer.remain(); 160 161 } 161 162 162 } 163 163 … … 220 220 info(20)<<"Server Side context <"<<context->getId()<<"> finalized"<<endl; 221 221 std::map<int, StdSize>::const_iterator itbMap = mapBufferSize_.begin(), 222 222 iteMap = mapBufferSize_.end(), itMap; 223 223 StdSize totalBuf = 0; 224 224 for (itMap = itbMap; itMap != iteMap; ++itMap) 225 225 { 226 226 report(10)<< " Memory report : Context <"<<context->getId()<<"> : server side : memory used for buffer of each connection to client" << endl 227 227 << " +) With client of rank " << itMap->first << " : " << itMap->second << " bytes " << endl; 228 228 totalBuf += itMap->second; 229 229 } -
XIOS/dev/dev_olga/src/context_server.hpp
r697 r983 48 48 private: 49 49 std::map<int, StdSize> mapBufferSize_; 50 50 51 } ; 51 52 -
XIOS/dev/dev_olga/src/cxios.cpp
r956 r983 16 16 string CXios::rootFile="./iodef.xml" ; 17 17 string CXios::xiosCodeId="xios.x" ; 18 string CXios::xiosCodeIdPrm="xios.x.1" ; 19 string CXios::xiosCodeIdSnd="xios.x.2" ; 18 20 string CXios::clientFile="./xios_client"; 19 21 string CXios::serverFile="./xios_server"; 22 string CXios::serverPrimFile="./xios_server1"; 23 string CXios::serverScndFile="./xios_server2"; 20 24 21 25 bool CXios::isClient ; 22 26 bool CXios::isServer ; 27 int CXios::serverLevel = 0 ; 23 28 MPI_Comm CXios::globalComm ; 24 29 bool CXios::usingOasis ; … … 127 132 128 133 //! Initialize server then put it into listening state 129 void CXios::initServerSide( void)134 void CXios::initServerSide(int serverLvl) 130 135 { 131 136 initServer(); 132 isClient = false; 137 if (serverLvl == 1) 138 isClient = true; 139 else 140 isClient = false; 141 133 142 isServer = true; 143 serverLevel = serverLvl; 134 144 135 145 // Initialize all aspects MPI … … 139 149 if (printLogs2Files) 140 150 { 141 CServer::openInfoStream(serverFile); 142 CServer::openErrorStream(serverFile); 151 if (CXios::serverLevel == 0) 152 { 153 CServer::openInfoStream(serverFile); 154 CServer::openErrorStream(serverFile); 155 } 156 else if (CXios::serverLevel == 1) 157 { 158 CServer::openInfoStream(serverPrimFile); 159 CServer::openErrorStream(serverPrimFile); 160 } 161 else 162 { 163 CServer::openInfoStream(serverScndFile); 164 CServer::openErrorStream(serverScndFile); 165 } 143 166 } 144 167 else … … 174 197 } 175 198 199 //! Set using secondary server 200 // void CXios::setUsingSecondaryServer() 201 // { 202 // usingSecondaryServer = true; 203 // } 204 176 205 //! Unset using server 177 206 void CXios::setNotUsingServer() -
XIOS/dev/dev_olga/src/cxios.hpp
r719 r983 16 16 static void initialize(void) ; 17 17 static void initClientSide(const string & codeId, MPI_Comm& localComm, MPI_Comm& returnComm) ; 18 static void initServerSide( void) ;18 static void initServerSide(int serverLevel) ; 19 19 static void clientFinalize(void) ; 20 20 static void parseFile(const string& filename) ; … … 29 29 static string rootFile ; //!< Configuration filename 30 30 static string xiosCodeId ; //!< Identity for XIOS 31 static string clientFile; //!< Filename template for client 32 static string serverFile; //!< Filename template for server 31 static string xiosCodeIdPrm ; //!< Identity for XIOS primary server 32 static string xiosCodeIdSnd ; //!< Identity for XIOS secondary server 33 static string clientFile; //!< Filename template for client 34 static string serverFile; //!< Filename template for server 35 static string serverPrimFile; //!< Filename template for primary server in case of two server groups 36 static string serverScndFile; //!< Filename template for secondary server in case of two server groups 33 37 34 38 static bool isClient ; //!< Check if xios is client 35 static bool isServer ; //!< Check if xios is server 39 static bool isServer ; //!< Check if xios is primary server 40 41 static int serverLevel ; // 36 42 37 43 static MPI_Comm globalComm ; //!< Global communicator … … 50 56 static void setUsingServer(); 51 57 58 //! Setting xios to use secondary server mode 59 // static void setUsingSecondaryServer(); 60 52 61 //! Setting xios NOT to use server mode 53 62 static void setNotUsingServer(); -
XIOS/dev/dev_olga/src/distribution_client.cpp
r932 r983 10 10 11 11 namespace xios { 12 13 CDistributionClient::CDistributionClient(int rank, const GlobalLocalDataMap& globalLocalIndex) 14 : CDistribution(rank, 0) 15 , axisDomainOrder_() 16 , nLocal_(), nGlob_(), nBeginLocal_(), nBeginGlobal_(),nZoomBegin_(), nZoomEnd_() 17 , dataNIndex_(), dataDims_(), dataBegin_(), dataIndex_(), domainMasks_(), axisMasks_() 18 , gridMask_(), indexMap_() 19 , isDataDistributed_(true), axisNum_(0), domainNum_(0) 20 , localDataIndex_(), localMaskIndex_() 21 , globalLocalDataSendToServerMap_(globalLocalIndex) 22 , infoIndex_(), isComputed_(false) 23 , elementLocalIndex_(), elementGlobalIndex_(), elementIndexData_() 24 , elementZoomMask_(), elementNLocal_(), elementNGlobal_() 25 { 26 // numElement_ = globalLocalIndex.size(); !!! numElement_ should be calculated !!!! 27 isComputed_ = true; // my changes 28 29 30 localDataIndex_.resize(globalLocalIndex.size()); 31 localMaskIndex_.resize(globalLocalIndex.size()); 32 GlobalLocalDataMap::const_iterator it = globalLocalIndex.begin(), ite = globalLocalIndex.end(); 33 int idx = 0; 34 for (; it!=ite; ++it) 35 { 36 localMaskIndex_[idx] = localDataIndex_[idx] = it->second; 37 ++idx; 38 } 39 } 12 40 13 41 CDistributionClient::CDistributionClient(int rank, int dims, const CArray<size_t,1>& globalIndex) -
XIOS/dev/dev_olga/src/distribution_client.hpp
r930 r983 34 34 public: 35 35 /** Default constructor */ 36 CDistributionClient(int rank, const GlobalLocalDataMap& globalLocalIndex); 36 37 CDistributionClient(int rank, int dims, const CArray<size_t,1>& globalIndex = CArray<size_t,1>()); 37 38 CDistributionClient(int rank, CGrid* grid); -
XIOS/dev/dev_olga/src/distribution_server.hpp
r930 r983 37 37 const std::vector<int>& getZoomBeginServer() const; 38 38 const std::vector<int>& getZoomSizeServer() const; 39 const GlobalLocalMap& getGlobalLocalIndex() const { return globalLocalIndexMap_; } 39 40 40 41 virtual CArray<size_t,1> computeLocalIndex(const CArray<size_t,1>& globalIndex); -
XIOS/dev/dev_olga/src/interface/c/icdata.cpp
r961 r983 47 47 } 48 48 49 void cxios_init_server( void)50 { 51 CXios::initServerSide( );49 void cxios_init_server(int server_level) 50 { 51 CXios::initServerSide(server_level); 52 52 } 53 53 -
XIOS/dev/dev_olga/src/interface/fortran/idata.F90
r965 r983 7 7 INTERFACE ! Ne pas appeler directement/Interface FORTRAN 2003 <-> C99 8 8 9 SUBROUTINE cxios_init_server() BIND(C) 9 SUBROUTINE cxios_init_server(server_level) BIND(C) 10 USE ISO_C_BINDING 11 INTEGER (kind = C_INT) , VALUE :: server_level 10 12 END SUBROUTINE cxios_init_server 11 13 … … 451 453 CONTAINS ! Fonctions disponibles pour les utilisateurs. 452 454 453 SUBROUTINE xios(init_server)() 454 IMPLICIT NONE 455 CALL cxios_init_server() 455 SUBROUTINE xios(init_server)(server_level) 456 IMPLICIT NONE 457 INTEGER (kind = C_INT), INTENT(IN) :: server_level 458 CALL cxios_init_server(server_level) 456 459 END SUBROUTINE xios(init_server) 457 460 -
XIOS/dev/dev_olga/src/node/calendar_wrapper.cpp
r550 r983 7 7 namespace xios { 8 8 9 /// ////////////////////// D éfinitions ////////////////////// ///9 /// ////////////////////// Dfinitions ////////////////////// /// 10 10 11 11 CCalendarWrapper::CCalendarWrapper(void) … … 83 83 { 84 84 // Create the calendar if possible 85 if ( calendar)85 if (0 != calendar) 86 86 { 87 87 ERROR("CCalendarWrapper::createCalendar(void)", -
XIOS/dev/dev_olga/src/node/context.cpp
r958 r983 24 24 CContext::CContext(void) 25 25 : CObjectTemplate<CContext>(), CContextAttributes() 26 , calendar(), hasClient(false), hasServer(false), isPostProcessed(false), finalized(false) 27 , idServer_(), client(0), server(0) 26 , calendar(), hasClient(false), hasServer(false) 27 , isPostProcessed(false), finalized(false) 28 , idServer_(), client(0), server(0), clientPrimServer(0), serverPrimServer(0) 28 29 { /* Ne rien faire de plus */ } 29 30 30 31 CContext::CContext(const StdString & id) 31 32 : CObjectTemplate<CContext>(id), CContextAttributes() 32 , calendar(), hasClient(false), hasServer(false), isPostProcessed(false), finalized(false) 33 , idServer_(), client(0), server(0) 33 , calendar(), hasClient(false), hasServer(false) 34 , isPostProcessed(false), finalized(false) 35 , idServer_(), client(0), server(0), clientPrimServer(0), serverPrimServer(0) 34 36 { /* Ne rien faire de plus */ } 35 37 … … 38 40 delete client; 39 41 delete server; 42 delete clientPrimServer; 43 delete serverPrimServer; 40 44 } 41 45 … … 238 242 void CContext::initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer /*= 0*/) 239 243 { 240 hasClient=true; 241 client = new CContextClient(this,intraComm, interComm, cxtServer); 244 245 hasClient = true; 246 if (CXios::serverLevel != 1) // initClient is called by client pool 247 { 248 client = new CContextClient(this, intraComm, interComm, cxtServer); 249 server = new CContextServer(this, intraComm, interComm); 250 } 251 else // initClient is called by primary server pool 252 { 253 clientPrimServer = new CContextClient(this, intraComm, interComm); 254 serverPrimServer = new CContextServer(this, intraComm, interComm); 255 } 256 242 257 registryIn=new CRegistry(intraComm); 243 258 registryIn->setPath(getId()) ; … … 261 276 comms.push_back(interCommServer); 262 277 } 263 server = new CContextServer(this,intraCommServer,interCommServer);264 278 } 265 279 … … 300 314 if (!bufferSize.count(*itRank)) bufferSize[*itRank] = maxEventSize[*itRank] = minBufferSize; 301 315 } 302 303 316 client->setBufferSize(bufferSize, maxEventSize); 317 318 // If it is primary server pool, also set buffer for clientPrimServer. 319 if (hasClient && hasServer) 320 { 321 if (clientPrimServer->isServerLeader()) 322 { 323 const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 324 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 325 if (!bufferSize.count(*itRank)) bufferSize[*itRank] = maxEventSize[*itRank] = minBufferSize; 326 } 327 clientPrimServer->setBufferSize(bufferSize, maxEventSize); 328 } 329 304 330 } 305 331 … … 310 336 } 311 337 312 //! Initialize server 313 void CContext::initServer(MPI_Comm intraComm,MPI_Comm interComm, CContext* cxtClient /*= 0*/) 338 void CContext::initServer(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtClient /*= 0*/) 314 339 { 315 340 hasServer=true; 316 341 server = new CContextServer(this,intraComm,interComm); 342 client = new CContextClient(this,intraComm,interComm); 343 // client = new CContextClient(this,intraComm,interComm, cxtClient); 317 344 318 345 registryIn=new CRegistry(intraComm); … … 336 363 comms.push_back(interCommClient); 337 364 } 338 client = new CContextClient(this,intraCommClient,interCommClient, cxtClient); 365 339 366 } 340 367 … … 342 369 bool CContext::eventLoop(void) 343 370 { 344 return server->eventLoop(); 371 if (CXios::serverLevel == 0) 372 { 373 return server->eventLoop(); 374 } 375 else if (CXios::serverLevel == 1) 376 { 377 bool serverFinished = server->eventLoop(); 378 bool serverPrimFinished = serverPrimServer->eventLoop(); 379 return ( serverFinished && serverPrimFinished); 380 } 381 else 382 { 383 return server->eventLoop(); 384 } 345 385 } 346 386 … … 348 388 bool CContext::checkBuffersAndListen(void) 349 389 { 350 client->checkBuffers(); 351 return server->eventLoop(); 390 if (CXios::serverLevel == 0) 391 { 392 client->checkBuffers(); 393 return server->eventLoop(); 394 } 395 else if (CXios::serverLevel == 1) 396 { 397 client->checkBuffers(); 398 clientPrimServer->checkBuffers(); 399 bool serverFinished = server->eventLoop(); 400 bool serverPrimFinished = serverPrimServer->eventLoop(); 401 return ( serverFinished && serverPrimFinished); 402 } 403 else if (CXios::serverLevel == 2) 404 { 405 client->checkBuffers(); 406 return server->eventLoop(); 407 } 352 408 } 353 409 … … 359 415 finalized = true; 360 416 if (hasClient) sendRegistry() ; 417 418 /* if (CXios::serverLevel == 0) 419 { 420 client->finalize(); 421 while (!server->hasFinished()) 422 { 423 server->eventLoop(); 424 } 425 } 426 else if (CXios::serverLevel == 1) 427 { 428 clientPrimServer->finalize(); 429 while (!serverPrimServer->hasFinished()) 430 { 431 serverPrimServer->eventLoop(); 432 } 433 client->finalize(); 434 while (!server->hasFinished()) 435 { 436 server->eventLoop(); 437 } 438 } 439 else if (CXios::serverLevel == 2) 440 { 441 client->finalize(); 442 while (!server->hasFinished()) 443 { 444 server->eventLoop(); 445 } 446 }*/ 447 361 448 client->finalize(); 362 449 while (!server->hasFinished()) 363 450 { 364 451 server->eventLoop(); 452 } 453 454 if ((hasClient) && (hasServer)) 455 { 456 clientPrimServer->finalize(); 457 while (!serverPrimServer->hasFinished()) 458 { 459 serverPrimServer->eventLoop(); 460 } 365 461 } 366 462 … … 391 487 // There is nothing client need to send to server 392 488 if (hasClient) 489 // if (hasClient && !hasServer) 393 490 { 394 491 // After xml is parsed, there are some more works with post processing 395 492 postProcessing(); 396 493 } 494 397 495 setClientServerBuffer(); 398 496 399 if (hasClient && !hasServer) 497 // if (hasClient && !hasServer) 498 if (hasClient) 400 499 { 401 500 // Send all attributes of current context to server … … 417 516 // After that, send all grid (if any) 418 517 sendRefGrid(); 419 } 518 519 // We have a xml tree on the server side and now, it should be also processed 520 sendPostProcessing(); 521 } 522 523 // // Now tell server that it can process all messages from client 524 // // if (hasClient && !hasServer) this->sendCloseDefinition(); 525 if (hasClient) this->sendCloseDefinition(); 420 526 421 527 // We have a xml tree on the server side and now, it should be also processed 422 if (hasClient && !hasServer) sendPostProcessing();528 // if (hasClient && !hasServer) sendPostProcessing(); 423 529 424 530 // There are some processings that should be done after all of above. For example: check mask or index 425 if (hasClient) 531 if (hasClient && !hasServer) 532 // if (hasClient) 426 533 { 427 this->buildFilterGraphOfEnabledFields(); 534 this->buildFilterGraphOfEnabledFields(); // references are resolved here (access xml file) 428 535 buildFilterGraphOfFieldsWithReadAccess(); 429 536 this->solveAllRefOfEnabledFields(true); 430 537 } 431 538 432 // Now tell server that it can process all messages from client 433 if (hasClient && !hasServer) this->sendCloseDefinition(); 539 // // Now tell server that it can process all messages from client 540 //// if (hasClient && !hasServer) this->sendCloseDefinition(); 541 // if (hasClient) this->sendCloseDefinition(); 434 542 435 543 // Nettoyage de l'arborescence 436 if (hasClient && !hasServer) CleanTree(); // Only on client side?? 544 // if (hasClient && !hasServer) CleanTree(); // Only on client side?? 545 if (hasClient) CleanTree(); // Only on client side?? 437 546 438 547 if (hasClient) 439 548 { 440 549 sendCreateFileHeader(); 441 442 startPrefetchingOfEnabledReadModeFiles(); 550 if (!hasServer) startPrefetchingOfEnabledReadModeFiles(); 443 551 } 444 552 } … … 549 657 const vector<CGrid*> allGrids= CGrid::getAll(); 550 658 551 //if (hasClient && !hasServer)552 if (hasClient)659 if (hasClient && !hasServer) 660 //if (hasClient) 553 661 { 554 662 for (unsigned int i = 0; i < allFiles.size(); i++) … … 646 754 } 647 755 756 // // Only send close definition from process having hasClient 757 // void CContext::sendCloseDefinitionToServer(void) 758 // { 759 // CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION); 760 // } 761 648 762 //! Client side: Send a message to server to make it close 649 763 void CContext::sendCloseDefinition(void) 650 764 { 651 765 CEventClient event(getType(),EVENT_ID_CLOSE_DEFINITION); 652 if (client->isServerLeader()) 653 { 654 CMessage msg; 655 msg<<this->getIdServer(); 656 const std::list<int>& ranks = client->getRanksServerLeader(); 657 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 658 event.push(*itRank,1,msg); 659 client->sendEvent(event); 660 } 661 else client->sendEvent(event); 766 if (!hasServer) 767 { 768 if (client->isServerLeader()) 769 { 770 CMessage msg; 771 msg<<this->getIdServer(); 772 const std::list<int>& ranks = client->getRanksServerLeader(); 773 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 774 event.push(*itRank,1,msg); 775 client->sendEvent(event); 776 } 777 else client->sendEvent(event); 778 } 779 else 780 { 781 if (clientPrimServer->isServerLeader()) 782 { 783 CMessage msg; 784 msg<<this->getIdServer(); 785 const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 786 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 787 event.push(*itRank,1,msg); 788 clientPrimServer->sendEvent(event); 789 } 790 else clientPrimServer->sendEvent(event); 791 792 } 662 793 } 663 794 … … 675 806 void CContext::sendUpdateCalendar(int step) 676 807 { 808 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR); 677 809 if (!hasServer) 678 810 { 679 CEventClient event(getType(),EVENT_ID_UPDATE_CALENDAR);680 811 if (client->isServerLeader()) 681 812 { … … 689 820 else client->sendEvent(event); 690 821 } 822 else 823 { 824 if (clientPrimServer->isServerLeader()) 825 { 826 CMessage msg; 827 msg<<this->getIdServer()<<step; 828 const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 829 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 830 event.push(*itRank,1,msg); 831 clientPrimServer->sendEvent(event); 832 } 833 else clientPrimServer->sendEvent(event); 834 } 691 835 } 692 836 … … 712 856 { 713 857 CEventClient event(getType(),EVENT_ID_CREATE_FILE_HEADER); 714 if (client->isServerLeader()) 715 { 716 CMessage msg; 717 msg<<this->getIdServer(); 718 const std::list<int>& ranks = client->getRanksServerLeader(); 719 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 720 event.push(*itRank,1,msg) ; 721 client->sendEvent(event); 722 } 723 else client->sendEvent(event); 858 859 if (!hasServer) 860 { 861 if (client->isServerLeader()) 862 { 863 CMessage msg; 864 msg<<this->getIdServer(); 865 const std::list<int>& ranks = client->getRanksServerLeader(); 866 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 867 event.push(*itRank,1,msg) ; 868 client->sendEvent(event); 869 } 870 else client->sendEvent(event); 871 } 872 else 873 { 874 if (clientPrimServer->isServerLeader()) 875 { 876 CMessage msg; 877 msg<<this->getIdServer(); 878 const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 879 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 880 event.push(*itRank,1,msg) ; 881 clientPrimServer->sendEvent(event); 882 } 883 else clientPrimServer->sendEvent(event); 884 } 724 885 } 725 886 … … 742 903 void CContext::sendPostProcessing() 743 904 { 744 if (!hasServer) 745 { 746 CEventClient event(getType(),EVENT_ID_POST_PROCESS); 747 if (client->isServerLeader()) 748 { 749 CMessage msg; 750 msg<<this->getIdServer(); 751 const std::list<int>& ranks = client->getRanksServerLeader(); 752 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 753 event.push(*itRank,1,msg); 754 client->sendEvent(event); 755 } 756 else client->sendEvent(event); 905 if (hasClient) 906 { 907 if (!hasServer) 908 { 909 CEventClient event(getType(),EVENT_ID_POST_PROCESS); 910 if (client->isServerLeader()) 911 { 912 CMessage msg; 913 msg<<this->getIdServer(); 914 const std::list<int>& ranks = client->getRanksServerLeader(); 915 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 916 event.push(*itRank,1,msg); 917 client->sendEvent(event); 918 } 919 else client->sendEvent(event); 920 } 921 else 922 { 923 CEventClient event(getType(),EVENT_ID_POST_PROCESS); 924 if (clientPrimServer->isServerLeader()) 925 { 926 CMessage msg; 927 msg<<this->getIdServer(); 928 const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 929 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 930 event.push(*itRank,1,msg); 931 clientPrimServer->sendEvent(event); 932 } 933 else clientPrimServer->sendEvent(event); 934 } 757 935 } 758 936 } … … 806 984 this->solveAllInheritance(); 807 985 986 ShowTree(info(10)); 987 808 988 // Check if some axis, domains or grids are eligible to for compressed indexed output. 809 989 // Warning: This must be done after solving the inheritance and before the rest of post-processing … … 822 1002 this->findAllEnabledFieldsInReadModeFiles(); 823 1003 1004 // if (hasClient) 824 1005 if (hasClient && !hasServer) 825 1006 { … … 1187 1368 1188 1369 1189 1190 1370 //! Server side: Receive a message to do some post processing 1191 1371 void CContext::recvRegistry(CEventServer& event) … … 1212 1392 1213 1393 CEventClient event(CContext::GetType(), CContext::EVENT_ID_SEND_REGISTRY); 1214 if ( client->isServerLeader())1394 if (!hasServer) 1215 1395 { 1216 CMessage msg ; 1217 msg<<this->getIdServer(); 1218 if (client->clientRank==0) msg<<*registryOut ; 1219 const std::list<int>& ranks = client->getRanksServerLeader(); 1220 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1221 event.push(*itRank,1,msg); 1222 client->sendEvent(event); 1223 } 1224 else client->sendEvent(event); 1396 if (client->isServerLeader()) 1397 { 1398 CMessage msg ; 1399 msg<<this->getIdServer(); 1400 if (client->clientRank==0) msg<<*registryOut ; 1401 const std::list<int>& ranks = client->getRanksServerLeader(); 1402 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1403 event.push(*itRank,1,msg); 1404 client->sendEvent(event); 1405 } 1406 else client->sendEvent(event); 1407 } 1408 else 1409 { 1410 if (clientPrimServer->isServerLeader()) 1411 { 1412 CMessage msg ; 1413 msg<<this->getIdServer(); 1414 if (clientPrimServer->clientRank==0) msg<<*registryOut ; 1415 const std::list<int>& ranks = clientPrimServer->getRanksServerLeader(); 1416 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 1417 event.push(*itRank,1,msg); 1418 clientPrimServer->sendEvent(event); 1419 } 1420 else clientPrimServer->sendEvent(event); 1421 1422 } 1225 1423 } 1226 1424 -
XIOS/dev/dev_olga/src/node/context.hpp
r917 r983 88 88 public : 89 89 // Initialize server or client 90 void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer = 0); 90 91 void initServer(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtClient = 0); 91 void initClient(MPI_Comm intraComm, MPI_Comm interComm, CContext* cxtServer = 0);92 92 bool isInitialized(void); 93 93 … … 137 137 void sendRefGrid(); 138 138 void sendPostProcessing(); 139 void sendRegistry(void) ; //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 139 //!< after be gathered to the root process of the context, merged registry is sent to the root process of the servers 140 void sendRegistry(void) ; 141 140 142 const StdString& getIdServer(); 141 143 … … 151 153 void recvPostProcessing(CBufferIn& buffer); 152 154 static void recvRegistry(CEventServer& event) ; 153 void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the root process of theservers155 void recvRegistry(CBufferIn& buffer) ; //!< registry is received by the servers 154 156 155 157 // dispatch event … … 216 218 bool hasServer; 217 219 218 // Concrete context server219 CContextServer* server;220 221 220 // Concrete contex client 222 221 CContextClient* client; 223 222 CRegistry* registryIn ; //!< input registry which is read from file 224 223 CRegistry* registryOut ; //!< output registry which will be wrote on file at the finalize 224 225 // Concrete context server 226 CContextServer* server; 227 228 // Client-server pair in case of secondary server pool 229 CContextClient* clientPrimServer; 230 CContextServer* serverPrimServer; 225 231 226 232 private: -
XIOS/dev/dev_olga/src/node/field.cpp
r967 r983 122 122 123 123 CContext* context = CContext::getCurrent(); 124 CContextClient* client = context->client; 124 // CContextClient* client = context->client; 125 CContextClient* client = (!context->hasServer) ? context->client : context->clientPrimServer; 125 126 126 127 CEventClient event(getType(), EVENT_ID_UPDATE_DATA); … … 195 196 void CField::recvUpdateData(vector<int>& ranks, vector<CBufferIn*>& buffers) 196 197 { 198 CContext* context = CContext::getCurrent(); 199 197 200 if (data_srv.empty()) 198 201 { … … 205 208 } 206 209 207 CContext* context = CContext::getCurrent();208 210 const CDate& currDate = context->getCalendar()->getCurrentDate(); 209 211 const CDate opeDate = last_operation_srv +freq_op + freq_operation_srv - freq_op; … … 229 231 230 232 last_Write_srv = writeDate; 233 } 234 235 if (context->hasClient && context->hasServer) 236 { 237 size_t writtenSize; 238 // if (field->getUseCompressedOutput()) 239 // writtenSize = grid->getNumberWrittenIndexes(); 240 // else 241 writtenSize = grid->getWrittenDataSize(); 242 243 CArray<double,1> fieldData(writtenSize); 244 // if (!field->default_value.isEmpty()) fieldData = field->default_value; 245 246 // if (field->getUseCompressedOutput()) 247 // field->outputCompressedField(fieldData); 248 // else 249 this->outputField(fieldData); 250 sendUpdateData(fieldData); 251 } 252 if (!context->hasClient && context->hasServer) 253 { 231 254 writeField(); 232 lastlast_Write_srv = last_Write_srv; 233 } 255 } 256 257 lastlast_Write_srv = last_Write_srv; 258 234 259 } 235 260 … … 503 528 isReferenceSolved = true; 504 529 505 if (context->hasClient) 530 if (context->hasClient && !context->hasServer) 531 // if (context->hasClient) 506 532 { 507 533 solveRefInheritance(true); 508 534 if (hasDirectFieldReference()) getDirectFieldReference()->solveOnlyReferenceEnabledField(false); 509 535 } 510 else if (context->hasServer) 536 // else if (context->hasServer) 537 if (context->hasServer) 511 538 solveServerOperation(); 512 539 513 540 solveGridReference(); 514 541 515 if (context->hasClient) 542 if (context->hasClient && !context->hasServer) 543 // if (context->hasClient) 516 544 { 517 545 solveGenerateGrid(); … … 528 556 { 529 557 CContext* context = CContext::getCurrent(); 530 if (context->hasClient) 558 if (context->hasClient && !context->hasServer) 559 // if (context->hasClient) 531 560 { 532 561 if (grid && !grid->isTransformed() && hasDirectFieldReference() && grid != getDirectFieldReference()->grid) … … 543 572 { 544 573 CContext* context = CContext::getCurrent(); 545 if (context->hasClient) 574 if (context->hasClient && !context->hasServer) 575 // if (context->hasClient) 546 576 { 547 577 std::map<CGrid*,std::pair<bool,StdString> >& gridSrcMap = grid->getTransGridSource(); … … 628 658 areAllReferenceSolved = true; 629 659 630 if (context->hasClient) 660 // if (context->hasClient) 661 if (context->hasClient && !context->hasServer) 631 662 { 632 663 solveRefInheritance(true); 633 664 if (hasDirectFieldReference()) getDirectFieldReference()->solveAllReferenceEnabledField(false); 634 665 } 635 else if (context->hasServer) 666 // else if (context->hasServer) 667 if (context->hasServer && !context->hasClient) 636 668 solveServerOperation(); 637 669 … … 641 673 solveGridDomainAxisRef(doSending2Server); 642 674 643 if (context->hasClient )675 if (context->hasClient && !context->hasClient) 644 676 { 645 677 solveTransformedGrid(); -
XIOS/dev/dev_olga/src/node/grid.cpp
r968 r983 273 273 { 274 274 CContext* context = CContext::getCurrent(); 275 CContextClient* client= context->client;275 CContextClient* client= context->hasServer ? context->clientPrimServer : context->client; 276 276 277 277 if (isScalarGrid()) 278 278 { 279 if (context->hasClient) 279 if (context->hasClient && !context->hasServer) 280 // if (context->hasClient) 280 281 if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndexScalarGrid(); this->isIndexSent = true; } 281 282 282 283 if (this->isChecked) return; 283 if (context->hasClient) 284 if (context->hasClient && !context->hasServer) 285 // if (context->hasClient) 284 286 { 285 287 this->computeIndexScalarGrid(); … … 290 292 } 291 293 292 if (context->hasClient) 294 if (context->hasClient && !context->hasServer) 295 // if (context->hasClient) 293 296 if (this->isChecked && doSendingIndex && !isIndexSent) { sendIndex(); this->isIndexSent = true; } 294 297 295 298 if (this->isChecked) return; 296 299 297 if (context->hasClient) 300 if (context->hasClient && !context->hasServer) 301 // if (context->hasClient) 298 302 { 299 303 this->checkAttributesAfterTransformation(); … … 497 501 { 498 502 CContext* context = CContext::getCurrent(); 499 CContextClient* client = context->client; 503 // CContextClient* client = context->client; 504 CContextClient* client = (context->hasServer) ? context->clientPrimServer : context->client; 505 500 506 501 507 // First of all, compute distribution on client side 502 clientDistribution_ = new CDistributionClient(client->clientRank, this); 508 if (0 != serverDistribution_) 509 clientDistribution_ = new CDistributionClient(client->clientRank, serverDistribution_->getGlobalLocalIndex()); 510 else 511 clientDistribution_ = new CDistributionClient(client->clientRank, this); 512 503 513 // Get local data index on client 514 int tmp = clientDistribution_->getLocalDataIndexOnClient().size(); 504 515 storeIndex_client.resize(clientDistribution_->getLocalDataIndexOnClient().size()); 505 516 int nbStoreIndex = storeIndex_client.numElements(); … … 577 588 { 578 589 CContext* context = CContext::getCurrent(); 579 CContextClient* client = context-> client;590 CContextClient* client = context->hasServer ? context->clientPrimServer : context->client; 580 591 int serverSize = client->serverSize; 581 592 std::vector<CDomain*> domList = getDomains(); … … 975 986 { 976 987 CContext* context = CContext::getCurrent(); 977 CContextClient* client =context->client;988 CContextClient* client = context->hasServer ? context->clientPrimServer : context->client; 978 989 979 990 storeIndex_client.resize(1); … … 1031 1042 { 1032 1043 CContext* context = CContext::getCurrent(); 1033 CContextClient* client = context-> client;1044 CContextClient* client = context->hasServer ? context->clientPrimServer : context->client; 1034 1045 1035 1046 CEventClient event(getType(), EVENT_ID_INDEX); … … 1070 1081 { 1071 1082 CContext* context = CContext::getCurrent(); 1072 CContextClient* client = context->client; 1083 // CContextClient* client = context->client; 1084 CContextClient* client = context->hasServer ? context->clientPrimServer : context->client ; 1073 1085 1074 1086 CEventClient event(getType(), EVENT_ID_INDEX); … … 1178 1190 } 1179 1191 get(gridId)->recvIndex(ranks, buffers); 1192 1193 CContext* context = CContext::getCurrent(); 1194 if (context->hasClient && context->hasServer) 1195 { 1196 get(gridId)->computeIndex(); 1197 get(gridId)->sendIndex(); 1198 } 1180 1199 } 1181 1200 … … 1183 1202 { 1184 1203 CContext* context = CContext::getCurrent(); 1185 CContextServer* server = context->server; 1204 CContextServer* server = (context->hasServer) ? context->server : context->serverPrimServer; 1205 CContextClient* client = (context->hasServer) ? context->client : context->clientPrimServer; 1186 1206 numberWrittenIndexes_ = totalNumberWrittenIndexes_ = offsetWrittenIndexes_ = 0; 1187 1207 connectedServerRank_ = ranks; … … 1283 1303 totalNumberWrittenIndexes_ = numberWrittenIndexes_; 1284 1304 1285 nbSenders = CClientServerMappingDistributed::computeConnectedClients(c ontext->client->serverSize, context->client->clientSize, context->client->intraComm, ranks);1305 nbSenders = CClientServerMappingDistributed::computeConnectedClients(client->serverSize, client->clientSize, client->intraComm, ranks); 1286 1306 } 1287 1307 … … 1657 1677 { 1658 1678 CDomain* pDom = CDomain::get(*it); 1659 if (context->hasClient) 1679 if (context->hasClient && !context->hasServer) 1680 // if (context->hasClient) 1660 1681 { 1661 1682 pDom->solveRefInheritance(apply); … … 1669 1690 { 1670 1691 CAxis* pAxis = CAxis::get(*it); 1671 if (context->hasClient) 1692 if (context->hasClient && !context->hasServer) 1693 // if (context->hasClient) 1672 1694 { 1673 1695 pAxis->solveRefInheritance(apply); … … 1681 1703 { 1682 1704 CScalar* pScalar = CScalar::get(*it); 1683 if (context->hasClient) 1705 if (context->hasClient && !context->hasServer) 1706 // if (context->hasClient) 1684 1707 { 1685 1708 pScalar->solveRefInheritance(apply); -
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 -
XIOS/dev/dev_olga/src/server.hpp
r697 r983 22 22 static void listenRootContext(void); 23 23 static void listenRootFinalize(void); 24 static void registerContext(void* buff,int count, int leaderRank=0); 24 static void registerContext(void* buff,int count, int leaderRank=0); // context registered by the primary server 25 25 26 // Communicators for the primary group of servers 26 27 static MPI_Comm intraComm; 27 28 static list<MPI_Comm> interComm; 28 29 static std::list<MPI_Comm> contextInterComms; 29 30 static CEventScheduler* eventScheduler; 30 31 31 32 struct contextMessage 32 33 { … … 37 38 static bool isRoot; 38 39 39 static map<string,CContext*> contextList; 40 static map<string,CContext*> contextList; // contexts on the primary server 40 41 static bool finished; 41 42 static bool is_MPI_Initialized; -
XIOS/dev/dev_olga/src/test/test_client.f90
r794 r983 17 17 CHARACTER(len=15) :: calendar_type 18 18 TYPE(xios_context) :: ctx_hdl 19 INTEGER,PARAMETER :: ni_glo= 10020 INTEGER,PARAMETER :: nj_glo= 10021 INTEGER,PARAMETER :: llm= 519 INTEGER,PARAMETER :: ni_glo=2 20 INTEGER,PARAMETER :: nj_glo=2 21 INTEGER,PARAMETER :: llm=1 22 22 DOUBLE PRECISION :: lval(llm)=1 23 23 TYPE(xios_field) :: field_hdl … … 84 84 CALL xios_set_fieldgroup_attr("field_definition",enabled=.TRUE.) 85 85 86 CALL xios_get_handle("field_definition",fieldgroup_hdl)87 CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B")88 CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B")86 !CALL xios_get_handle("field_definition",fieldgroup_hdl) 87 !CALL xios_add_child(fieldgroup_hdl,field_hdl,"field_B") 88 !CALL xios_set_attr(field_hdl,field_ref="field_A",name="field_B") 89 89 90 CALL xios_get_handle("output",file_hdl)91 CALL xios_add_child(file_hdl,field_hdl)92 CALL xios_set_attr(field_hdl,field_ref="field_A_zoom",name="field_C")90 !CALL xios_get_handle("output",file_hdl) 91 !CALL xios_add_child(file_hdl,field_hdl) 92 !CALL xios_set_attr(field_hdl,field_ref="field_A_zoom",name="field_C") 93 93 94 94 dtime%second = 3600 -
XIOS/dev/dev_olga/src/xios_server.f90
r501 r983 4 4 INCLUDE "mpif.h" 5 5 INTEGER :: ierr 6 7 CALL xios_init_server 6 INTEGER :: server_level = 0 7 ! 0 in case of a single server pool 8 ! 1 for primary server in case of two server pools 9 ! 2 for secondary server in case of two server pools 8 10 9 END PROGRAM server_main 11 CALL xios_init_server(server_level) 12 13 END PROGRAM server_main
Note: See TracChangeset
for help on using the changeset viewer.