Changeset 1328 for XIOS/dev/branch_openmp/src/client.cpp
- Timestamp:
- 11/15/17 12:14:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/client.cpp
r1205 r1328 11 11 #include "timer.hpp" 12 12 #include "buffer_client.hpp" 13 #include "log.hpp" 14 13 using namespace ep_lib; 15 14 16 15 namespace xios 17 16 { 18 extern int test_omp_rank;19 #pragma omp threadprivate(test_omp_rank)20 17 21 18 MPI_Comm CClient::intraComm ; 22 19 MPI_Comm CClient::interComm ; 20 //std::list<MPI_Comm> CClient::contextInterComms; 23 21 std::list<MPI_Comm> *CClient::contextInterComms_ptr = 0; 24 22 int CClient::serverLeader ; … … 28 26 StdOFStream CClient::m_errorStream; 29 27 30 StdOFStream CClient::array_infoStream[16]; 31 32 void CClient::initialize(const string& codeId, MPI_Comm& localComm, MPI_Comm& returnComm) 28 void CClient::initialize(const string& codeId,MPI_Comm& localComm,MPI_Comm& returnComm) 33 29 { 34 30 int initialized ; … … 41 37 { 42 38 // localComm doesn't given 43 44 39 if (localComm == MPI_COMM_NULL) 45 40 { 46 41 if (!is_MPI_Initialized) 47 42 { 48 //MPI_Init(NULL, NULL); 49 int return_level; 50 MPI_Init_thread(NULL, NULL, 3, &return_level); 51 assert(return_level == 3); 43 MPI_Init(NULL, NULL); 52 44 } 53 45 CTimer::get("XIOS").resume() ; … … 61 53 int myColor ; 62 54 int i,c ; 63 64 MPI_Comm_size(CXios::globalComm,&size); 55 MPI_Comm newComm ; 56 57 MPI_Comm_size(CXios::globalComm,&size) ; 65 58 MPI_Comm_rank(CXios::globalComm,&rank); 66 67 59 68 60 hashAll=new unsigned long[size] ; … … 106 98 MPI_Comm_size(intraComm,&intraCommSize) ; 107 99 MPI_Comm_rank(intraComm,&intraCommRank) ; 108 109 #pragma omp critical(_output) 110 { 111 info(10)<<"intercommCreate::client "<<test_omp_rank<< " "<< &test_omp_rank <<" intraCommSize : "<<intraCommSize 112 <<" intraCommRank :"<<intraCommRank<<" serverLeader "<< serverLeader 113 <<" globalComm : "<< &(CXios::globalComm) << endl ; 114 } 115 116 117 //test_sendrecv(CXios::globalComm); 100 info(50)<<"intercommCreate::client "<<rank<<" intraCommSize : "<<intraCommSize 101 <<" intraCommRank :"<<intraCommRank<<" clientLeader "<< serverLeader<<endl ; 118 102 MPI_Intercomm_create(intraComm,0,CXios::globalComm,serverLeader,0,&interComm) ; 119 120 103 } 121 104 else … … 140 123 } 141 124 // using OASIS 142 else125 /* else 143 126 { 144 127 // localComm doesn't given … … 165 148 else MPI_Comm_dup(intraComm,&interComm) ; 166 149 } 167 150 */ 168 151 MPI_Comm_dup(intraComm,&returnComm) ; 169 170 152 } 171 153 … … 174 156 { 175 157 CContext::setCurrent(id) ; 176 CContext* context = CContext::create(id); 177 178 int tmp_rank; 179 MPI_Comm_rank(contextComm,&tmp_rank) ; 180 158 CContext* context=CContext::create(id); 181 159 StdString idServer(id); 182 160 idServer += "_server"; … … 185 163 { 186 164 int size,rank,globalRank ; 187 //size_t message_size ;188 //int leaderRank ;165 size_t message_size ; 166 int leaderRank ; 189 167 MPI_Comm contextInterComm ; 190 168 … … 197 175 CMessage msg ; 198 176 msg<<idServer<<size<<globalRank ; 199 177 // msg<<id<<size<<globalRank ; 200 178 201 179 int messageSize=msg.size() ; … … 208 186 209 187 MPI_Intercomm_create(contextComm,0,CXios::globalComm,serverLeader,10+globalRank,&contextInterComm) ; 210 211 #pragma omp critical(_output) 212 info(10)<<" RANK "<< tmp_rank<<" Register new Context : "<<id<<endl ; 213 188 info(10)<<"Register new Context : "<<id<<endl ; 214 189 215 190 MPI_Comm inter ; … … 217 192 MPI_Barrier(inter) ; 218 193 219 220 194 context->initClient(contextComm,contextInterComm) ; 221 195 222 196 //contextInterComms.push_back(contextInterComm); 223 197 if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 224 198 contextInterComms_ptr->push_back(contextInterComm); 225 226 199 MPI_Comm_free(&inter); 227 200 } … … 240 213 // Finally, we should return current context to context client 241 214 CContext::setCurrent(id); 242 215 216 //contextInterComms.push_back(contextInterComm); 243 217 if(contextInterComms_ptr == NULL) contextInterComms_ptr = new std::list<MPI_Comm>; 244 218 contextInterComms_ptr->push_back(contextInterComm); 245 246 219 } 247 220 } … … 253 226 254 227 MPI_Comm_rank(intraComm,&rank) ; 255 228 256 229 if (!CXios::isServer) 257 230 { … … 263 236 } 264 237 265 for (std::list<MPI_Comm>::iterator it = contextInterComms_ptr->begin(); it != contextInterComms_ptr->end(); ++it) 238 //for (std::list<MPI_Comm>::iterator it = contextInterComms.begin(); it != contextInterComms.end(); it++) 239 for (std::list<MPI_Comm>::iterator it = contextInterComms_ptr->begin(); it != contextInterComms_ptr->end(); it++) 266 240 MPI_Comm_free(&(*it)); 267 268 241 MPI_Comm_free(&interComm); 269 242 MPI_Comm_free(&intraComm); … … 274 247 if (!is_MPI_Initialized) 275 248 { 276 if (CXios::usingOasis) oasis_finalize(); 277 else MPI_Finalize(); 249 //if (CXios::usingOasis) oasis_finalize(); 250 //else 251 MPI_Finalize() ; 278 252 } 279 253 280 #pragma omp critical (_output) 281 info(20) << "Client "<<rank<<" : Client side context is finalized "<< endl ; 282 283 /*#pragma omp critical (_output) 284 { 254 info(20) << "Client side context is finalized"<<endl ; 285 255 report(0) <<" Performance report : Whole time from XIOS init and finalize: "<< CTimer::get("XIOS init/finalize").getCumulatedTime()<<" s"<<endl ; 286 256 report(0) <<" Performance report : total time spent for XIOS : "<< CTimer::get("XIOS").getCumulatedTime()<<" s"<<endl ; … … 292 262 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 ; 293 263 report(100)<<CTimer::getAllCumulatedTime()<<endl ; 294 }*/295 296 264 } 297 265 … … 322 290 323 291 fileNameClient << fileName << "_" << std::setfill('0') << std::setw(numDigit) << getRank() << ext; 324 325 292 fb->open(fileNameClient.str().c_str(), std::ios::out); 326 293 if (!fb->is_open()) 327 294 ERROR("void CClient::openStream(const StdString& fileName, const StdString& ext, std::filebuf* fb)", 328 << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s).");295 << std::endl << "Can not open <" << fileNameClient << "> file to write the client log(s)."); 329 296 } 330 297 … … 337 304 void CClient::openInfoStream(const StdString& fileName) 338 305 { 339 //std::filebuf* fb = m_infoStream.rdbuf(); 340 341 info_FB[omp_get_thread_num()] = array_infoStream[omp_get_thread_num()].rdbuf(); 342 343 openStream(fileName, ".out", info_FB[omp_get_thread_num()]); 344 345 info.write2File(info_FB[omp_get_thread_num()]); 346 report.write2File(info_FB[omp_get_thread_num()]); 347 306 std::filebuf* fb = m_infoStream.rdbuf(); 307 openStream(fileName, ".out", fb); 308 309 info.write2File(fb); 310 report.write2File(fb); 348 311 } 349 312
Note: See TracChangeset
for help on using the changeset viewer.