Changeset 1215


Ignore:
Timestamp:
07/15/17 10:49:26 (7 years ago)
Author:
ymipsl
Message:

Distribute files on servers 2 -> Ok test_dcmip2

YM

Location:
XIOS/dev/XIOS_DEV_CMIP6/src/node
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.cpp

    r1202 r1215  
    310310     if (zoom_begin.isEmpty()) zoom_begin.setValue(begin); 
    311311   } 
     312 
     313    size_t CAxis::getGlobalWrittenSize(void) 
     314    { 
     315      if (zoomByIndex()) return  zoom_index.numElements(); 
     316      else return global_zoom_n ; 
     317    } 
    312318 
    313319   /*! 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/axis.hpp

    r1202 r1215  
    111111 
    112112         void checkEligibilityForCompressedOutput(); 
     113         size_t getGlobalWrittenSize(void) ; 
    113114 
    114115         void computeWrittenIndex(); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/context.cpp

    r1212 r1215  
    1616#include "timer.hpp" 
    1717#include "memtrack.hpp" 
    18  
     18#include <limits> 
    1919#include "server.hpp" 
    2020 
     
    822822   void CContext::distributeFiles(void) 
    823823   { 
     824     double eps=std::numeric_limits<double>::epsilon()*10 ; 
     825      
    824826     // If primary server 
    825827     if (hasServer && hasClient) 
     
    836838       // (2) Estimate the data volume for each file 
    837839       int size = this->enabledWriteModeFiles.size(); 
    838        std::vector<std::pair<StdSize, CFile*> > dataSizeMap; 
    839        StdSize dataPerPool = 0; 
     840       std::vector<std::pair<double, CFile*> > dataSizeMap; 
     841       double dataPerPool = 0; 
     842       int nfield=0 ; 
    840843       for (size_t i = 0; i < size; ++i) 
    841844       { 
    842845         CFile* file = this->enabledWriteModeFiles[i]; 
    843          StdSize dataSize; 
     846         StdSize dataSize=0; 
    844847         std::vector<CField*> enabledFields = file->getEnabledFields(); 
    845848         size_t numEnabledFields = enabledFields.size(); 
    846          for (size_t j = 0; j < numEnabledFields; ++j) 
    847          { 
    848            const std::vector<std::map<int, StdSize> > mapSize = enabledFields[j]->getGridDataBufferSize(); 
    849            for (size_t c = 0; c < mapSize.size(); ++c) 
    850            { 
    851              std::map<int, StdSize>::const_iterator it = mapSize[c].begin(), itE = mapSize[c].end(); 
    852              for (; it != itE; ++it) 
    853              { 
    854                dataSize += it->second; 
    855              } 
    856            } 
    857          } 
    858          CDuration outFreq = file->output_freq.getValue(); 
    859          if (outFreq.timestep != 0.0) 
    860          { 
    861            outFreq = calendar->getTimeStep(); 
    862          } 
    863          double outFreqSec = outFreq.second + 60.*(outFreq.minute + 60.*(outFreq.hour + 24.*(outFreq.day + outFreq.year*365.25) ) ); 
    864          dataSize /= outFreqSec; 
    865          dataSizeMap.push_back(make_pair(dataSize,file)); 
    866          dataPerPool += dataSize; 
     849         for (size_t j = 0; j < numEnabledFields; ++j) dataSize += enabledFields[j]->getGlobalWrittenSize() ; 
     850 
     851         double outFreqSec = (Time)(calendar->getCurrentDate()+file->output_freq)-(Time)(calendar->getCurrentDate()) ; 
     852         double dataSizeSec= dataSize/ outFreqSec; 
     853         nfield++ ; 
     854// add epsilon*nField to dataSizeSec in order to  preserve reproductive ordering when sorting 
     855         dataSizeMap.push_back(make_pair(dataSizeSec + dataSizeSec * eps * nfield , file)); 
     856         dataPerPool += dataSizeSec; 
    867857       } 
    868858       dataPerPool /= nbPools; 
     
    870860 
    871861       // (3) Assign contextClient to each enabled file 
    872        std::vector<StdSize> poolData(nbPools); 
    873        int lazyPool = 0; 
     862 
     863       std::multimap<double,int> poolDataSize ; 
     864// multimap is not garanty to preserve stable sorting in c++98 but it seems it does for c++11 
     865 
     866       int j; 
     867       double dataSize ; 
     868       for (j = 0 ; j < nbPools ; ++j) poolDataSize.insert(std::pair<double,int>(0.,j)) ;   
     869               
    874870       for (int i = dataSizeMap.size()-1; i >= 0; --i) 
    875871       { 
    876          bool contextSet = false; 
    877          for (int j = 0; j < nbPools; ++j) 
    878          { 
    879            if (!contextSet) 
    880            { 
    881              if (dataSizeMap[i].first + poolData[j] < dataPerPool) 
    882              { 
    883                dataSizeMap[i].second->setContextClient(clientPrimServer[j]); 
    884                poolData[j] += dataSizeMap[i].first; 
    885                contextSet = true; 
    886              } 
    887            } 
    888            if (poolData[j] < poolData[lazyPool]) 
    889              lazyPool = j; 
    890          } 
    891          if (!contextSet) 
    892          { 
    893            dataSizeMap[i].second->setContextClient(clientPrimServer[lazyPool]); 
    894            poolData[lazyPool] += dataSizeMap[i].first; 
    895          } 
    896        } 
    897  
     872         dataSize=(*poolDataSize.begin()).first ; 
     873         j=(*poolDataSize.begin()).second ; 
     874         dataSizeMap[i].second->setContextClient(clientPrimServer[j]); 
     875         dataSize+=dataSizeMap[i].first; 
     876         poolDataSize.erase(poolDataSize.begin()) ; 
     877         poolDataSize.insert(std::pair<double,int>(dataSize,j)) ;  
     878       } 
     879 
     880       for (std::multimap<double,int>:: iterator it=poolDataSize.begin() ; it!=poolDataSize.end(); ++it) info(30)<<"Load Balancing for servers (perfect=1) : "<<it->second<<" :  ratio "<<it->first*1./dataPerPool<<endl ; 
     881  
    898882       for (int i = 0; i < this->enabledReadModeFiles.size(); ++i) 
    899883         enabledReadModeFiles[i]->setContextClient(client); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.cpp

    r1202 r1215  
    876876   } 
    877877 
     878   size_t CDomain::getGlobalWrittenSize(void) 
     879   { 
     880      return global_zoom_ni*global_zoom_nj ; 
     881   } 
    878882   //---------------------------------------------------------------- 
    879883 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/domain.hpp

    r1158 r1215  
    153153         void recvArea(std::map<int, CBufferIn*>& rankBuffers);          
    154154         void recvDataIndex(std::map<int, CBufferIn*>& rankBuffers); 
    155  
     155         size_t getGlobalWrittenSize() ; 
    156156         /// Destructeur /// 
    157157         virtual ~CDomain(void); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.cpp

    r1201 r1215  
    796796   } 
    797797 
     798   size_t CField::getGlobalWrittenSize() 
     799   { 
     800     return grid->getGlobalWrittenSize(); 
     801   } 
     802 
    798803   //---------------------------------------------------------------- 
    799804 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/field.hpp

    r1158 r1215  
    127127 
    128128         void buildFilterGraph(CGarbageCollector& gc, bool enableOutput); 
     129         size_t getGlobalWrittenSize(void) ; 
     130          
     131          
    129132         boost::shared_ptr<COutputPin> getFieldReference(CGarbageCollector& gc); 
    130133         boost::shared_ptr<COutputPin> getSelfReference(CGarbageCollector& gc); 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.cpp

    r1202 r1215  
    170170         dataSizes[p].insert(std::make_pair(rank, extraSize + CArray<double,1>::size(count))); 
    171171       } 
     172        
    172173     } 
    173174 
     
    175176   } 
    176177 
     178   size_t CGrid::getGlobalWrittenSize(void) 
     179   { 
     180         std::vector<CDomain*> domainP = this->getDomains(); 
     181     std::vector<CAxis*> axisP = this->getAxis(); 
     182      
     183     size_t globalGridSize=1 ; 
     184     for (std::vector<CDomain*>::iterator it=domainP.begin(); it!=domainP.end();++it) globalGridSize*=(*it)->getGlobalWrittenSize() ; 
     185     for (std::vector<CAxis*>::iterator it=axisP.begin(); it!=axisP.end();++it) globalGridSize*=(*it)->getGlobalWrittenSize() ; 
     186     return globalGridSize ; 
     187   } 
     188    
     189    
    177190   void CGrid::checkAttributesAfterTransformation() 
    178191   { 
  • XIOS/dev/XIOS_DEV_CMIP6/src/node/grid.hpp

    r1202 r1215  
    199199         std::map<CGrid*, std::pair<bool,StdString> >& getTransGridSource(); 
    200200         bool hasTransform(); 
    201  
     201         size_t getGlobalWrittenSize(void) ; 
    202202      public: 
    203203 
Note: See TracChangeset for help on using the changeset viewer.