Changeset 1234 for XIOS/dev/XIOS_DEV_CMIP6
- Timestamp:
- 08/03/17 15:16:56 (7 years ago)
- Location:
- XIOS/dev/XIOS_DEV_CMIP6/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/XIOS_DEV_CMIP6/src/cxios.cpp
r1227 r1234 186 186 187 187 // Finalize 188 if ( !usingServer2)188 if (CServer::serverLevel == 0) 189 189 { 190 190 if (CServer::getRank()==0) -
XIOS/dev/XIOS_DEV_CMIP6/src/cxios.hpp
r1227 r1234 42 42 static bool usingOasis ; //!< Using Oasis 43 43 static bool usingServer ; //!< Using server (server mode) 44 static bool usingServer2 ; //!< Using secondary server (server mode) 44 static bool usingServer2 ; //!< Using secondary server (server mode). IMPORTANT: Use this variable ONLY in CServer::initialize(). 45 45 static int ratioServer2 ; //!< Percentage of server processors dedicated to secondary server 46 46 static double bufferSizeFactor; //!< Factor used to tune the buffer size -
XIOS/dev/XIOS_DEV_CMIP6/src/node/file.cpp
r1232 r1234 17 17 #include "mpi.hpp" 18 18 #include "timer.hpp" 19 #include "server.hpp" 19 20 20 21 namespace xios { … … 302 303 // Done by classical server or secondary server 303 304 // This condition should be changed soon 304 if ( !CXios::usingServer2 || (CXios::usingServer2 && !context->hasClient))305 if (CServer::serverLevel == 0 || CServer::serverLevel == 2) 305 306 { 306 307 if (mode.isEmpty() || mode.getValue() == mode_attr::write) … … 326 327 // Done by classical server or secondary server 327 328 // TODO: This condition should be changed soon. It only works with maximum number of level as 2 328 if ( !CXios::usingServer2 || (CXios::usingServer2 && context->hasClient))329 if (CServer::serverLevel == 0 || CServer::serverLevel == 2) 329 330 { 330 331 if (!mode.isEmpty() && mode.getValue() == mode_attr::read) -
XIOS/dev/XIOS_DEV_CMIP6/src/server.cpp
r1226 r1234 38 38 * \fn void CServer::initialize(void) 39 39 * Creates intraComm for each possible type of servers (classical, primary or secondary). 40 * In case of secondary servers intraComm is created for each secondary server pool. 41 * (For now the assumption is that there is one proc per pool.) 40 * (For now the assumption is that there is one proc per secondary server pool.) 42 41 * Creates interComm and stores them into the following lists: 43 42 * classical server -- interCommLeft 44 43 * primary server -- interCommLeft and interCommRight 45 44 * secondary server -- interCommLeft for each pool. 45 * IMPORTANT: CXios::usingServer2 should NOT be used beyond this function. Use CServer::serverLevel instead. 46 46 */ 47 47 void CServer::initialize(void) … … 85 85 86 86 // (1) Establish client leaders, distribute processes between two server levels 87 vector<int> srvRanks;87 std::vector<int> srvRanks; 88 88 for(i=0,c=0;i<size;i++) 89 89 { … … 98 98 srvRanks.push_back(i); 99 99 } 100 for (i=0; i<srvRanks.size(); i++) 101 { 102 if (i >= srvRanks.size()*(100.-CXios::ratioServer2)/100.) 103 { 104 sndServerGlobalRanks.push_back(srvRanks[i]); 105 if (rank_ == srvRanks[i]) serverLevel=2; 100 101 if (CXios::usingServer2) 102 { 103 int reqNbProc = srvRanks.size()*CXios::ratioServer2/100.; 104 if (reqNbProc<1 || reqNbProc==srvRanks.size()) 105 { 106 error(0)<<"WARNING: void CServer::initialize(void)"<<endl 107 << "It is impossible to dedicate the requested number of processes = "<<reqNbProc 108 <<" to secondary server. XIOS will run in the classical server mode."<<endl; 106 109 } 107 110 else 108 111 { 109 if (rank_ == srvRanks[i]) serverLevel=1; 110 } 111 } 112 112 for (i=0; i<srvRanks.size(); i++) 113 { 114 if (i >= srvRanks.size()*(100.-CXios::ratioServer2)/100.) 115 { 116 sndServerGlobalRanks.push_back(srvRanks[i]); 117 if (rank_ == srvRanks[i]) serverLevel=2; 118 } 119 else 120 { 121 if (rank_ == srvRanks[i]) serverLevel=1; 122 } 123 } 124 } 125 } 113 126 // (2) Create intraComm 114 127 myColor = (serverLevel == 2) ? rank_ : colors[hashServer]; … … 188 201 int size; 189 202 int myColor; 190 unsigned long* srvGlobalRanks;203 int* srvGlobalRanks; 191 204 if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId); 192 205 … … 194 207 MPI_Comm localComm; 195 208 oasis_get_localcomm(localComm); 196 197 // Create server intraComm 209 MPI_Comm_rank(localComm,&rank_) ; 210 211 // (1) Create server intraComm 198 212 if (!CXios::usingServer2) 199 213 { 200 214 MPI_Comm_dup(localComm, &intraComm); 201 MPI_Comm_rank(localComm,&rank_) ;202 215 } 203 216 else 204 217 { 205 218 int globalRank; 206 MPI_Comm_rank(localComm,&rank_) ;207 219 MPI_Comm_size(localComm,&size) ; 208 220 MPI_Comm_rank(CXios::globalComm,&globalRank) ; 209 srvGlobalRanks = new unsigned long[size] ;210 MPI_Allgather(&globalRank, 1, MPI_ LONG, srvGlobalRanks, 1, MPI_LONG, localComm) ;211 212 for (int i=size*(100.-CXios::ratioServer2)/100.; i<size; i++)213 sndServerGlobalRanks.push_back(srvGlobalRanks[i]);214 215 if ( rank_ < (size - sndServerGlobalRanks.size()) )216 {217 serverLevel = 1;218 myColor = 0;221 srvGlobalRanks = new int[size] ; 222 MPI_Allgather(&globalRank, 1, MPI_INT, srvGlobalRanks, 1, MPI_INT, localComm) ; 223 224 int reqNbProc = size*CXios::ratioServer2/100.; 225 if (reqNbProc < 1 || reqNbProc == size) 226 { 227 error(0)<<"WARNING: void CServer::initialize(void)"<<endl 228 << "It is impossible to dedicate the requested number of processes = "<<reqNbProc 229 <<" to secondary server. XIOS will run in the classical server mode."<<endl; 230 MPI_Comm_dup(localComm, &intraComm); 219 231 } 220 232 else 221 233 { 222 serverLevel = 2; 223 myColor = rank_; 224 } 225 MPI_Comm_split(localComm, myColor, rank_, &intraComm) ; 226 227 } 228 MPI_Comm_size(intraComm,&size) ; 234 for (int i=0; i<size; i++) 235 { 236 if (i >= size*(100.-CXios::ratioServer2)/100.) 237 { 238 sndServerGlobalRanks.push_back(srvGlobalRanks[i]); 239 if (globalRank == srvGlobalRanks[i]) serverLevel=2; 240 } 241 else 242 { 243 if (globalRank == srvGlobalRanks[i]) serverLevel=1; 244 } 245 } 246 myColor = (serverLevel == 2) ? globalRank : 0; 247 MPI_Comm_split(localComm, myColor, rank_, &intraComm) ; 248 } 249 } 250 229 251 string codesId=CXios::getin<string>("oasis_codes_id") ; 230 231 252 vector<string> splitted ; 232 253 boost::split( splitted, codesId, boost::is_any_of(","), boost::token_compress_on ) ; … … 237 258 MPI_Comm_rank(CXios::globalComm,&globalRank); 238 259 239 // ( 1) Create interComms with models260 // (2) Create interComms with models 240 261 for(it=splitted.begin();it!=splitted.end();it++) 241 262 { 242 263 oasis_get_intercomm(newComm,*it) ; 243 if ( !CXios::usingServer2|| serverLevel == 1)264 if ( serverLevel == 0 || serverLevel == 1) 244 265 { 245 266 interCommLeft.push_back(newComm) ; … … 248 269 } 249 270 250 // (2) Create interComms between primary and secondary servers 271 // (3) Create interComms between primary and secondary servers 272 MPI_Comm_size(intraComm,&size) ; 251 273 if (serverLevel == 1) 252 274 {
Note: See TracChangeset
for help on using the changeset viewer.