Ignore:
Timestamp:
06/14/17 15:24:43 (4 years ago)
Author:
oabramkina
Message:

Two server levels: merging registries of secondary server pools into one and then writing the merged one.

Tested on curie with toy_cmip6.

File:
1 edited

Legend:

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

    r1158 r1168  
    184184 
    185185    // Finalize 
    186      if (CServer::getRank()==0) 
    187      { 
    188        info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
    189        globalRegistry->toFile("xios_registry.bin") ; 
    190        delete globalRegistry ; 
    191      } 
     186    if (!usingServer2) 
     187    { 
     188      if (CServer::getRank()==0) 
     189      { 
     190        info(80)<<"Write data base Registry"<<endl<<globalRegistry->toString()<<endl ; 
     191        globalRegistry->toFile("xios_registry.bin") ; 
     192        delete globalRegistry ; 
     193      } 
     194    } 
     195    else 
     196    { 
     197      // If using two server levels, first merge globalRegistry of each server pool into one registry on the first pool 
     198      if (CServer::serverLevel == 2) 
     199      { 
     200        vector<int>& secondaryServerGlobalRanks = CServer::getSecondaryServerGlobalRanks(); 
     201        int firstPoolGlobalRank = secondaryServerGlobalRanks[0]; 
     202        int rankGlobal; 
     203        MPI_Comm_rank(globalComm, &rankGlobal); 
     204 
     205        // All pools (except the first): send globalRegistry to the first pool 
     206        if (rankGlobal != firstPoolGlobalRank) 
     207        { 
     208          int registrySize = globalRegistry->size(); 
     209          MPI_Send(&registrySize,1,MPI_LONG,firstPoolGlobalRank,15,CXios::globalComm) ; 
     210          CBufferOut buffer(registrySize) ; 
     211          globalRegistry->toBuffer(buffer) ; 
     212          MPI_Send(buffer.start(),registrySize,MPI_CHAR,firstPoolGlobalRank,15,CXios::globalComm) ; 
     213        } 
     214 
     215        // First pool: receive globalRegistry of all secondary server pools, merge and write the resultant registry 
     216        else 
     217        { 
     218          MPI_Status status; 
     219          char* recvBuff; 
     220 
     221          CRegistry globalRegistrySndServers (CServer::intraComm); 
     222          globalRegistrySndServers.mergeRegistry(*globalRegistry) ; 
     223 
     224          for (int i=1; i< secondaryServerGlobalRanks.size(); i++) 
     225          { 
     226            int rank = secondaryServerGlobalRanks[i]; 
     227            int registrySize = 0; 
     228            MPI_Recv(&registrySize, 1, MPI_LONG, rank, 15, CXios::globalComm, &status); 
     229            recvBuff = new char[registrySize]; 
     230            MPI_Recv(recvBuff, registrySize, MPI_CHAR, rank, 15, CXios::globalComm, &status); 
     231            CBufferIn buffer(recvBuff, registrySize) ; 
     232            CRegistry recvRegistry; 
     233            recvRegistry.fromBuffer(buffer) ; 
     234            globalRegistrySndServers.mergeRegistry(recvRegistry) ; 
     235            delete[] recvBuff; 
     236          } 
     237 
     238          info(80)<<"Write data base Registry"<<endl<<globalRegistrySndServers.toString()<<endl ; 
     239          globalRegistrySndServers.toFile("xios_registry.bin") ; 
     240 
     241        } 
     242      } 
     243      delete globalRegistry; 
     244    } 
    192245    CServer::finalize(); 
    193246 
Note: See TracChangeset for help on using the changeset viewer.