Changeset 2518 for XIOS3/trunk
- Timestamp:
- 06/12/23 15:01:16 (20 months ago)
- Location:
- XIOS3/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/event_scheduler.cpp
r2274 r2518 10 10 CEventScheduler::CEventScheduler(const MPI_Comm& comm) 11 11 { 12 MPI_Comm_dup(comm, &communicator ) ;13 MPI_Comm_size(communicator ,&mpiSize) ;14 MPI_Comm_rank(communicator ,&mpiRank);12 MPI_Comm_dup(comm, &communicator_) ; 13 MPI_Comm_size(communicator_,&mpiSize_) ; 14 MPI_Comm_rank(communicator_,&mpiRank_); 15 15 16 16 … … 23 23 maxChild=maxChild+1 ; 24 24 for(int i=0;i<maxChild;i++) m=m*maxChild ; 25 } while(m<mpiSize ) ;25 } while(m<mpiSize_) ; 26 26 27 27 28 28 int maxLevel=0 ; 29 for(int size=1; size<=mpiSize ; size*=maxChild) maxLevel++ ;29 for(int size=1; size<=mpiSize_; size*=maxChild) maxLevel++ ; 30 30 31 31 int begin, end, nb ; 32 32 int pos, n ; 33 33 34 parent =vector<int>(maxLevel+1) ;35 child =vector<vector<int> >(maxLevel+1,vector<int>(maxChild)) ;36 nbChild =vector<int> (maxLevel+1) ;34 parent_=vector<int>(maxLevel+1) ; 35 child_=vector<vector<int> >(maxLevel+1,vector<int>(maxChild)) ; 36 nbChild_=vector<int> (maxLevel+1) ; 37 37 38 level =0 ;38 level_=0 ; 39 39 begin=0 ; 40 end=mpiSize -1 ;40 end=mpiSize_-1 ; 41 41 nb=end-begin+1 ; 42 42 … … 45 45 n=0 ; 46 46 pos=begin ; 47 nbChild [level]=0 ;48 parent [level+1]=begin ;47 nbChild_[level_]=0 ; 48 parent_[level_+1]=begin ; 49 49 for(int i=0;i<maxChild && i<nb ;i++) 50 50 { … … 52 52 else n = nb/maxChild ; 53 53 54 if (mpiRank >=pos && mpiRank<pos+n)54 if (mpiRank_>=pos && mpiRank_<pos+n) 55 55 { 56 56 begin=pos ; 57 57 end=pos+n-1 ; 58 58 } 59 child [level][i]=pos ;59 child_[level_][i]=pos ; 60 60 pos=pos+n ; 61 nbChild [level]++ ;61 nbChild_[level_]++ ; 62 62 } 63 63 nb=end-begin+1 ; 64 level =level+1 ;64 level_=level_+1 ; 65 65 } while (nb>1) ; 66 66 … … 70 70 CEventScheduler::~CEventScheduler() 71 71 { 72 while (!pendingSentParentRequest .empty() || !pendingRecvParentRequest.empty() || !pendingRecvChildRequest.empty() || !pendingSentChildRequest.empty())72 while (!pendingSentParentRequest_.empty() || !pendingRecvParentRequest_.empty() || !pendingRecvChildRequest_.empty() || !pendingSentChildRequest_.empty()) 73 73 { 74 74 checkEvent() ; … … 78 78 void CEventScheduler::registerEvent(const size_t timeLine, const size_t contextHashId) 79 79 { 80 registerEvent(timeLine, contextHashId, level ) ;80 registerEvent(timeLine, contextHashId, level_) ; 81 81 checkEvent() ; 82 82 } … … 91 91 sentRequest->buffer[2]=lev-1 ; 92 92 93 pendingSentParentRequest .push(sentRequest) ;94 MPI_Isend(sentRequest->buffer,3, MPI_UNSIGNED_LONG, parent [lev], 0, communicator, &sentRequest->request) ;93 pendingSentParentRequest_.push(sentRequest) ; 94 MPI_Isend(sentRequest->buffer,3, MPI_UNSIGNED_LONG, parent_[lev], 0, communicator_, &sentRequest->request) ; 95 95 traceOn() ; 96 96 } … … 99 99 { 100 100 checkEvent() ; 101 if (! eventStack .empty() && eventStack.front().first==timeLine && eventStack.front().second==contextHashId)102 { 103 //eventStack .pop() ;101 if (! eventStack_.empty() && eventStack_.front().first==timeLine && eventStack_.front().second==contextHashId) 102 { 103 //eventStack_.pop() ; 104 104 return true ; 105 105 } … … 125 125 126 126 // check sent request to parent 127 while (! pendingSentParentRequest .empty() && completed)128 { 129 MPI_Test( & pendingSentParentRequest .front()->request, &completed, &status) ;127 while (! pendingSentParentRequest_.empty() && completed) 128 { 129 MPI_Test( & pendingSentParentRequest_.front()->request, &completed, &status) ; 130 130 if (completed) 131 131 { 132 delete pendingSentParentRequest .front() ;133 pendingSentParentRequest .pop() ;132 delete pendingSentParentRequest_.front() ; 133 pendingSentParentRequest_.pop() ; 134 134 } 135 135 } … … 139 139 while(received) 140 140 { 141 MPI_Iprobe(MPI_ANY_SOURCE,1,communicator ,&received, &status) ;141 MPI_Iprobe(MPI_ANY_SOURCE,1,communicator_,&received, &status) ; 142 142 if (received) 143 143 { 144 144 recvRequest=new SPendingRequest ; 145 MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, MPI_ANY_SOURCE, 1, communicator , &(recvRequest->request)) ;146 pendingRecvParentRequest .push(recvRequest) ;145 MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, MPI_ANY_SOURCE, 1, communicator_, &(recvRequest->request)) ; 146 pendingRecvParentRequest_.push(recvRequest) ; 147 147 } 148 148 } … … 150 150 // check sent request from parent 151 151 completed=true ; 152 while (! pendingRecvParentRequest .empty() && completed)153 { 154 recvRequest=pendingRecvParentRequest .front() ;152 while (! pendingRecvParentRequest_.empty() && completed) 153 { 154 recvRequest=pendingRecvParentRequest_.front() ; 155 155 MPI_Test( &(recvRequest->request), &completed, &status) ; 156 156 if (completed) … … 160 160 size_t lev=recvRequest->buffer[2] ; 161 161 delete recvRequest ; 162 pendingRecvParentRequest .pop() ;163 164 if (lev==level ) eventStack.push(pair<size_t,size_t>(timeLine,hashId)) ;162 pendingRecvParentRequest_.pop() ; 163 164 if (lev==level_) eventStack_.push(pair<size_t,size_t>(timeLine,hashId)) ; 165 165 else bcastEvent(timeLine, hashId, lev) ; 166 166 } … … 181 181 while(received) 182 182 { 183 MPI_Iprobe(MPI_ANY_SOURCE,0,communicator ,&received, &status) ;183 MPI_Iprobe(MPI_ANY_SOURCE,0,communicator_,&received, &status) ; 184 184 if (received) 185 185 { 186 186 recvRequest=new SPendingRequest ; 187 MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, MPI_ANY_SOURCE, 0, communicator , &recvRequest->request) ;188 pendingRecvChildRequest .push_back(recvRequest) ;187 MPI_Irecv(recvRequest->buffer, 3, MPI_UNSIGNED_LONG, MPI_ANY_SOURCE, 0, communicator_, &recvRequest->request) ; 188 pendingRecvChildRequest_.push_back(recvRequest) ; 189 189 } 190 190 } … … 192 192 // check if receive request is achieved 193 193 194 for(list<SPendingRequest*>::iterator it=pendingRecvChildRequest .begin(); it!=pendingRecvChildRequest.end() ; )194 for(list<SPendingRequest*>::iterator it=pendingRecvChildRequest_.begin(); it!=pendingRecvChildRequest_.end() ; ) 195 195 { 196 196 MPI_Test(&((*it)->request),&received,&status) ; … … 203 203 SEvent event={timeLine,hashId,lev} ; 204 204 delete *it ; // free mem 205 it=pendingRecvChildRequest .erase(it) ; // get out of the list205 it=pendingRecvChildRequest_.erase(it) ; // get out of the list 206 206 207 map< SEvent,int>::iterator itEvent=recvEvent .find(event) ;208 if (itEvent==recvEvent .end())207 map< SEvent,int>::iterator itEvent=recvEvent_.find(event) ; 208 if (itEvent==recvEvent_.end()) 209 209 { 210 itEvent=(recvEvent .insert(pair< SEvent ,int > (event,1))).first ;210 itEvent=(recvEvent_.insert(pair< SEvent ,int > (event,1))).first ; 211 211 212 212 } 213 213 else (itEvent->second)++ ; 214 if (itEvent->second==nbChild [lev])214 if (itEvent->second==nbChild_[lev]) 215 215 { 216 216 if (lev==0) 217 217 { 218 218 bcastEvent(timeLine,hashId,lev) ; 219 recvEvent .erase(itEvent) ;219 recvEvent_.erase(itEvent) ; 220 220 } 221 221 else 222 222 { 223 223 registerEvent( timeLine,hashId,lev) ; 224 recvEvent .erase(itEvent) ;224 recvEvent_.erase(itEvent) ; 225 225 } 226 226 } … … 231 231 // check if bcast request is achieved 232 232 233 for(list<SPendingRequest*>::iterator it=pendingSentChildRequest .begin(); it!=pendingSentChildRequest.end() ; )233 for(list<SPendingRequest*>::iterator it=pendingSentChildRequest_.begin(); it!=pendingSentChildRequest_.end() ; ) 234 234 { 235 235 MPI_Test(&(*it)->request,&received,&status) ; … … 237 237 { 238 238 delete *it ; // free memory 239 it = pendingSentChildRequest .erase(it) ; // get out of the list239 it = pendingSentChildRequest_.erase(it) ; // get out of the list 240 240 241 241 } … … 250 250 251 251 252 for(int i=0; i<nbChild [lev];i++)252 for(int i=0; i<nbChild_[lev];i++) 253 253 { 254 254 sentRequest=new SPendingRequest ; … … 256 256 sentRequest->buffer[1]=contextHashId ; 257 257 sentRequest->buffer[2]=lev+1 ; 258 MPI_Isend(sentRequest->buffer,3, MPI_UNSIGNED_LONG, child [lev][i], 1, communicator, & sentRequest->request) ;259 pendingSentChildRequest .push_back(sentRequest) ;258 MPI_Isend(sentRequest->buffer,3, MPI_UNSIGNED_LONG, child_[lev][i], 1, communicator_, & sentRequest->request) ; 259 pendingSentChildRequest_.push_back(sentRequest) ; 260 260 } 261 261 } -
XIOS3/trunk/src/event_scheduler.hpp
r2230 r2518 52 52 */ 53 53 bool queryEvent(const size_t timeLine, const size_t contextHashId) ; 54 void popEvent() { eventStack .pop() ; }54 void popEvent() { eventStack_.pop() ; } 55 55 56 56 … … 155 155 } ; 156 156 157 MPI_Comm communicator ; /*!< Internal MPI communicator */158 int mpiRank ; /*!< Rank in the communicator */159 int mpiSize ; /*!< Size of the communicator */157 MPI_Comm communicator_ ; /*!< Internal MPI communicator */ 158 int mpiRank_ ; /*!< Rank in the communicator */ 159 int mpiSize_ ; /*!< Size of the communicator */ 160 160 161 queue< pair<size_t, size_t> > eventStack ;162 queue<SPendingRequest* > pendingSentParentRequest ; /*!< Pending request sent to parent */163 queue<SPendingRequest*> pendingRecvParentRequest ; /*!< Pending request recv from parent */164 list<SPendingRequest* > pendingRecvChildRequest ; /*!< Pending request recv from child */165 list<SPendingRequest*> pendingSentChildRequest ; /*!< Pending request sent to child */166 map< SEvent, int > recvEvent ; /*!< list of event received from children. Contains the currnet number children that have already post the same event */161 queue< pair<size_t, size_t> > eventStack_ ; 162 queue<SPendingRequest* > pendingSentParentRequest_ ; /*!< Pending request sent to parent */ 163 queue<SPendingRequest*> pendingRecvParentRequest_ ; /*!< Pending request recv from parent */ 164 list<SPendingRequest* > pendingRecvChildRequest_ ; /*!< Pending request recv from child */ 165 list<SPendingRequest*> pendingSentChildRequest_ ; /*!< Pending request sent to child */ 166 map< SEvent, int > recvEvent_ ; /*!< list of event received from children. Contains the currnet number children that have already post the same event */ 167 167 168 168 169 int level ; /*!< Number of hierachical level for communication */170 vector<int> parent ; /*!< Parent rank for each level */171 vector<vector<int> > child ; /*!< List of child rank for each level */172 vector<int> nbChild ; /*!< Number of child for each level */169 int level_ ; /*!< Number of hierachical level for communication */ 170 vector<int> parent_ ; /*!< Parent rank for each level */ 171 vector<vector<int> > child_ ; /*!< List of child rank for each level */ 172 vector<int> nbChild_ ; /*!< Number of child for each level */ 173 173 174 174 } ;
Note: See TracChangeset
for help on using the changeset viewer.