Ignore:
Timestamp:
07/10/17 18:17:04 (7 years ago)
Author:
yushan
Message:

branch merged with trunk @1200

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan_merged/src/node/context.cpp

    r1160 r1205  
    1414#include "type.hpp" 
    1515#include "xios_spl.hpp" 
     16#include "timer.hpp" 
     17#include "memtrack.hpp" 
     18 
    1619 
    1720namespace xios { 
     
    278281   void CContext::setClientServerBuffer() 
    279282   { 
    280      size_t minBufferSize = CXios::minBufferSize; 
     283     // Estimated minimum event size for small events (10 is an arbitrary constant just for safety) 
     284     const size_t minEventSize = CEventClient::headerSize + getIdServer().size() + 10 * sizeof(int); 
     285     // Ensure there is at least some room for 20 of such events in the buffers 
     286     size_t minBufferSize = std::max(CXios::minBufferSize, 20 * minEventSize); 
    281287#define DECLARE_NODE(Name_, name_)    \ 
    282288     if (minBufferSize < sizeof(C##Name_##Definition)) minBufferSize = sizeof(C##Name_##Definition); 
     
    286292#undef DECLARE_NODE_PAR 
    287293 
     294     // Compute the buffer sizes needed to send the attributes and data corresponding to fields 
    288295     std::map<int, StdSize> maxEventSize; 
    289296     std::map<int, StdSize> bufferSize = getAttributesBufferSize(maxEventSize); 
     
    294301       if (it->second > bufferSize[it->first]) bufferSize[it->first] = it->second; 
    295302 
     303     // Apply the buffer size factor and check that we are above the minimum buffer size 
    296304     ite = bufferSize.end(); 
    297305     for (it = bufferSize.begin(); it != ite; ++it) 
     
    301309     } 
    302310 
    303      // We consider that the minimum buffer size is also the minimum event size 
    304      ite = maxEventSize.end(); 
    305      for (it = maxEventSize.begin(); it != ite; ++it) 
    306        if (it->second < minBufferSize) it->second = minBufferSize; 
    307  
     311     // Leaders will have to send some control events so ensure there is some room for those in the buffers 
    308312     if (client->isServerLeader()) 
    309313     { 
    310314       const std::list<int>& ranks = client->getRanksServerLeader(); 
    311315       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    312          if (!bufferSize.count(*itRank)) bufferSize[*itRank] = maxEventSize[*itRank] = minBufferSize; 
     316       { 
     317         if (!bufferSize.count(*itRank)) 
     318         { 
     319           bufferSize[*itRank] = minBufferSize; 
     320           maxEventSize[*itRank] = minEventSize; 
     321         } 
     322       } 
    313323     } 
    314324 
     
    401411   void CContext::closeDefinition(void) 
    402412   { 
     413     CTimer::get("Context : close definition").resume() ; 
    403414     // There is nothing client need to send to server 
    404415     if (hasClient) 
     
    454465      startPrefetchingOfEnabledReadModeFiles(); 
    455466    } 
     467    CTimer::get("Context : close definition").suspend() ; 
    456468   } 
    457469 
     
    12061218   void CContext::updateCalendar(int step) 
    12071219   { 
     1220      #pragma omp critical (_output) 
     1221      {info(50) << "updateCalendar : before : " << calendar->getCurrentDate() << endl;} 
    12081222      calendar->update(step); 
    1209  
    1210  
     1223      #pragma omp critical (_output) 
     1224      {info(50) << "updateCalendar : after : " << calendar->getCurrentDate() << endl;} 
     1225#ifdef XIOS_MEMTRACK_LIGHT 
     1226      #pragma omp critical (_output) 
     1227      {info(50) << " Current memory used by XIOS : "<<  MemTrack::getCurrentMemorySize()*1.0/(1024*1024)<<" Mbyte, at timestep "<<step<<" of context "<<this->getId()<<endl ;} 
     1228#endif 
    12111229      if (hasClient) 
    12121230      { 
     
    12551273    CContext* context = CObjectFactory::CreateObject<CContext>(id).get(); 
    12561274    getRoot(); 
    1257     //if (!hasctxt) CGroupFactory::AddChild(root, context->getShared()); 
    12581275    if (!hasctxt) CGroupFactory::AddChild(*root_ptr, context->getShared()); 
    12591276 
Note: See TracChangeset for help on using the changeset viewer.