Ignore:
Timestamp:
09/18/17 14:38:55 (7 years ago)
Author:
oabramkina
Message:

Correcting possible interference between contexts at the moment of registering a context.

File:
1 edited

Legend:

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

    r1244 r1270  
    613613       MPI_Status status ; 
    614614       int flag ; 
    615        static void* buffer ; 
    616        static MPI_Request request ; 
    617        static bool recept=false ; 
     615       static std::vector<void*> buffers; 
     616       static std::vector<MPI_Request> requests ; 
     617       static std::vector<bool> recept; 
     618       static std::vector<int> counts ; 
     619       MPI_Request request; 
     620 
     621//       void* buffer ; 
     622//       static MPI_Request request ; 
     623//       static bool recept=false ; 
     624//       static int count ; 
    618625       int rank ; 
    619 //       int count ; 
    620        static int count ; 
    621626       const int root=0 ; 
    622627       boost::hash<string> hashString; 
    623628       size_t hashId = hashString("RegisterContext"); 
    624629 
    625        // (1) Receive context id from the root 
    626        if (recept==false) 
     630       // (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) 
    627633       { 
    628634         traceOff() ; 
     
    631637         if (flag==true) 
    632638         { 
    633            MPI_Get_count(&status,MPI_CHAR,&count) ; 
    634            buffer=new char[count] ; 
    635            MPI_Irecv((void*)buffer,count,MPI_CHAR,root,2,intraComm,&request) ; 
    636            recept=true ; 
    637          } 
    638        } 
    639        // (2) If context id is received, save it into a buffer and register an event 
     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 
    640648       else 
    641649       { 
    642          MPI_Test(&request,&flag,&status) ; 
     650         MPI_Test(&requests[nbContexts],&flag,&status) ; 
    643651         if (flag==true) 
    644652         { 
    645            MPI_Get_count(&status,MPI_CHAR,&count) ; 
    646653           eventScheduler->registerEvent(nbContexts,hashId); 
    647 //           registerContext((void*)buffer,count) ; 
    648 //           delete [] buffer ; 
    649            recept=false ; 
     654           recept[nbContexts]=false ; 
    650655         } 
    651656       } 
     
    653658       if (eventScheduler->queryEvent(nbContexts,hashId)) 
    654659       { 
    655          registerContext(buffer,count) ; 
     660         registerContext(buffers[nbContexts],counts[nbContexts]) ; 
     661         delete [] buffers[nbContexts] ; 
    656662         ++nbContexts; 
    657          delete [] buffer ; 
    658663       } 
    659664     } 
Note: See TracChangeset for help on using the changeset viewer.