Changeset 1271 for XIOS/dev


Ignore:
Timestamp:
09/20/17 09:41:51 (7 years ago)
Author:
oabramkina
Message:

Corrections in addition to r1270. The algorithm for registering context is improved to avoid possible interference among contexts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/server.cpp

    r1270 r1271  
    615615       static std::vector<void*> buffers; 
    616616       static std::vector<MPI_Request> requests ; 
    617        static std::vector<bool> recept; 
    618617       static std::vector<int> counts ; 
     618       static std::vector<bool> isEventRegistered ; 
    619619       MPI_Request request; 
    620620 
    621 //       void* buffer ; 
    622 //       static MPI_Request request ; 
    623 //       static bool recept=false ; 
    624 //       static int count ; 
    625621       int rank ; 
    626622       const int root=0 ; 
     
    629625 
    630626       // (1) Receive context id from the root, save it into a buffer 
    631        if (recept.size() == nbContexts) recept.push_back(false); 
    632        if (recept[nbContexts]==false) 
    633        { 
    634          traceOff() ; 
    635          MPI_Iprobe(root,2,intraComm, &flag, &status) ; 
    636          traceOn() ; 
    637          if (flag==true) 
    638          { 
    639            counts.push_back(0); 
    640            MPI_Get_count(&status,MPI_CHAR,&counts[nbContexts]) ; 
    641            requests.push_back(request); 
    642            buffers.push_back(new char[counts[nbContexts]]) ; 
    643            MPI_Irecv((void*)(buffers.back()),counts.back(),MPI_CHAR,root,2,intraComm,&(requests.back())) ; 
    644            recept[nbContexts]=true ; 
    645          } 
    646        } 
    647        // (2) If context id is received, register an event 
    648        else 
    649        { 
    650          MPI_Test(&requests[nbContexts],&flag,&status) ; 
    651          if (flag==true) 
    652          { 
    653            eventScheduler->registerEvent(nbContexts,hashId); 
    654            recept[nbContexts]=false ; 
    655          } 
    656        } 
    657        // (3) If event has been scheduled, call register context 
    658        if (eventScheduler->queryEvent(nbContexts,hashId)) 
    659        { 
    660          registerContext(buffers[nbContexts],counts[nbContexts]) ; 
    661          delete [] buffers[nbContexts] ; 
    662          ++nbContexts; 
    663        } 
     627       traceOff() ; 
     628       MPI_Iprobe(root,2,intraComm, &flag, &status) ; 
     629       traceOn() ; 
     630       if (flag==true) 
     631       { 
     632         counts.push_back(0); 
     633         MPI_Get_count(&status,MPI_CHAR,&(counts.back())) ; 
     634         buffers.push_back(new char[counts.back()]) ; 
     635         requests.push_back(request); 
     636         MPI_Irecv((void*)(buffers.back()),counts.back(),MPI_CHAR,root,2,intraComm,&(requests.back())) ; 
     637         isEventRegistered.push_back(false); 
     638         nbContexts++; 
     639       } 
     640 
     641       for (int ctxNb = 0; ctxNb < nbContexts; ctxNb++ ) 
     642       { 
     643         // (2) If context id is received, register an event 
     644         MPI_Test(&requests[ctxNb],&flag,&status) ; 
     645         if (flag==true && !isEventRegistered[ctxNb]) 
     646         { 
     647           eventScheduler->registerEvent(ctxNb,hashId); 
     648           isEventRegistered[ctxNb] = true; 
     649         } 
     650         // (3) If event has been scheduled, call register context 
     651         if (eventScheduler->queryEvent(ctxNb,hashId)) 
     652         { 
     653           registerContext(buffers[ctxNb],counts[ctxNb]) ; 
     654           delete [] buffers[ctxNb] ; 
     655         } 
     656       } 
     657 
    664658     } 
    665659 
Note: See TracChangeset for help on using the changeset viewer.