Ignore:
Timestamp:
05/15/17 15:00:24 (7 years ago)
Author:
oabramkina
Message:

Two-level server: merging new grid functionalities and changes in the communication protocol (e.g. non-blocking context finalize, registries, oasis).

Tests on curie: test_client, test_complete, nemo (test_xios2_cmip6.exe).

To do: non-structured grid, check reading, possible bug in client/server initialization (?).

File:
1 edited

Legend:

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

    r1077 r1130  
    6767 
    6868        boost::hash<string> hashString ; 
    69 //        unsigned long hashServer1 = hashString(CXios::xiosCodeIdPrm); 
    70 //        unsigned long hashServer2 = hashString(CXios::xiosCodeIdSnd); 
    71 //        unsigned long hashServer = (CXios::serverLevel < 2)  ? hashServer1 : hashServer2; 
    7269        unsigned long hashServer = hashString(CXios::xiosCodeId); 
    7370 
     
    193190      else 
    194191      { 
    195 //        int rank ,size; 
    196         int size; 
     192        int size, rank; 
     193        int myColor; 
    197194        if (!is_MPI_Initialized) oasis_init(CXios::xiosCodeId); 
    198195 
     
    200197        MPI_Comm localComm; 
    201198        oasis_get_localcomm(localComm); 
    202         MPI_Comm_dup(localComm, &intraComm); 
    203  
     199 
     200        // Create server intraComm 
     201        if (!CXios::usingServer2) 
     202          MPI_Comm_dup(localComm, &intraComm); 
     203        else 
     204        { 
     205          MPI_Comm_rank(localComm,&rank) ; 
     206          MPI_Comm_size(localComm,&serverSize_) ; 
     207          nbPools = serverSize_ * CXios::ratioServer2 / 100; 
     208          if ( rank < (serverSize_ - nbPools) ) 
     209          { 
     210            serverLevel = 1; 
     211            myColor = 0; 
     212          } 
     213          else 
     214          { 
     215            serverLevel = 2; 
     216            poolId = rank - serverSize_ + nbPools; 
     217            myColor = rank; 
     218          } 
     219          MPI_Comm_split(localComm, myColor, rank, &intraComm) ; 
     220 
     221        } 
    204222        MPI_Comm_rank(intraComm,&rank_) ; 
    205223        MPI_Comm_size(intraComm,&size) ; 
     224 
    206225        string codesId=CXios::getin<string>("oasis_codes_id") ; 
    207226 
     
    217236        { 
    218237          oasis_get_intercomm(newComm,*it) ; 
    219           if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ; 
    220           MPI_Comm_remote_size(newComm,&size); 
    221 //          interComm.push_back(newComm) ; 
    222           interCommLeft.push_back(newComm) ; 
     238//        interComm.push_back(newComm) ; 
     239          if ( !CXios::usingServer2) 
     240            interCommLeft.push_back(newComm) ; 
     241          else 
     242          { 
     243            if (serverLevel == 1) 
     244            { 
     245              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<size 
     246                       <<" intraCommRank :"<<rank_<<"  clientLeader "<< rank<<endl ; 
     247              MPI_Intercomm_create(intraComm, 0, localComm, rank, 0, &newComm) ; 
     248              interCommRight.push_back(newComm) ; 
     249 
     250            } 
     251            else if (serverLevel == 2) 
     252            { 
     253              info(50)<<"intercommCreate::server "<<rank_<<" intraCommSize : "<<size 
     254                       <<" intraCommRank :"<<rank_<<"  clientLeader "<< 0<<endl ; 
     255              MPI_Intercomm_create(intraComm, 0, localComm, 0, 0, &newComm) ; 
     256              interCommLeft.push_back(newComm) ; 
     257 
     258            } 
     259 
     260          } 
     261//          if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,newComm) ; 
     262//          MPI_Comm_remote_size(newComm,&size); 
     263          // Send serverLeader to client 
     264          if (rank_==0) MPI_Send(&globalRank,1,MPI_INT,0,0,interCommLeft.back()) ; 
    223265        } 
    224266              oasis_enddef() ; 
     
    286328 
    287329         contextEventLoop() ; 
    288 //         if (finished && contextList.empty()) stop=true ; 
    289330         if (finished && contextList.empty()) stop=true ; 
    290331         eventScheduler->checkEvent() ; 
     
    510551         contextInterComms.push_back(inter); 
    511552         context->initServer(intraComm, contextInterComms.back()); 
    512 //         context->initServer(intraComm, interCommLeft.front()); 
    513553       } 
    514554 
     
    535575           contextIntraComms.push_back(inter); 
    536576           context->initClient(contextIntraComms.back(), contextInterComms.back()) ; 
    537 //           context->initClient(intraComm, contextPrimInterComms.back()) ; 
    538 //           context->initClient(intraComm, *it) ; 
    539577           delete [] buff ; 
    540578         } 
     
    545583     void CServer::contextEventLoop(void) 
    546584     { 
    547        bool finished ; 
     585       bool isFinalized ; 
    548586 
    549587       map<string,CContext*>::iterator it ; 
     
    551589       for(it=contextList.begin();it!=contextList.end();it++) 
    552590       { 
    553          finished=it->second->isFinalized(); 
    554          if (finished) 
    555          { 
    556            it->second->freeComms();  // deallocate internally allocated context communicators 
     591         isFinalized=it->second->isFinalized(); 
     592         if (isFinalized) 
     593         { 
     594           it->second->postFinalize(); 
    557595           contextList.erase(it) ; 
    558596           break ; 
    559597         } 
    560598         else 
    561            finished=it->second->checkBuffersAndListen(); 
     599         { 
     600           isFinalized=it->second->checkBuffersAndListen(); 
     601         } 
    562602       } 
    563603     } 
Note: See TracChangeset for help on using the changeset viewer.