Ignore:
Timestamp:
10/13/15 15:14:23 (9 years ago)
Author:
rlacroix
Message:

Correctly estimate the needed buffer sizes.

The attributes were not considered which could lead to incorrect estimations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/object_template_impl.hpp

    r595 r731  
    162162 
    163163   template<typename T> 
     164   std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes() 
     165   { 
     166     CContextClient* client = CContext::getCurrent()->client; 
     167     std::map<int, size_t> minimumSizes; 
     168 
     169     if (client->isServerLeader()) 
     170     { 
     171       size_t minimumSize = 0; 
     172       CAttributeMap& attrMap = *this; 
     173       CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 
     174       for (; it != itE; ++it) 
     175       { 
     176         if (!it->second->isEmpty()) 
     177         { 
     178           size_t size = it->second->getName().size() + it->second->size(); 
     179           if (size > minimumSize) 
     180             minimumSize = size; 
     181         } 
     182       } 
     183 
     184       if (minimumSize) 
     185       { 
     186         // Account for extra header info 
     187         minimumSize += CEventClient::headerSize + getIdServer().size(); 
     188 
     189         const std::list<int>& ranks = client->getRanksServerLeader(); 
     190         for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
     191           minimumSizes.insert(std::make_pair(*itRank, minimumSize)); 
     192       } 
     193     } 
     194 
     195     return minimumSizes; 
     196   } 
     197 
     198   template<typename T> 
    164199   void CObjectTemplate<T>::sendAllAttributesToServer() 
    165200   { 
     
    170205       if (!(it->second)->isEmpty()) sendAttributToServer(*(it->second)); 
    171206     } 
    172  
    173207   } 
    174208 
Note: See TracChangeset for help on using the changeset viewer.