source: XIOS/trunk/src/event_client.cpp @ 756

Last change on this file since 756 was 731, checked in by rlacroix, 9 years ago

Correctly estimate the needed buffer sizes.

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

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
  • Property svn:eol-style set to native
File size: 1.5 KB
RevLine 
[591]1#include "xios_spl.hpp"
[300]2#include "event_client.hpp"
3#include "buffer_out.hpp"
4#include "message.hpp"
5#include "type.hpp"
[382]6#include "mpi.hpp"
[300]7
[335]8namespace xios
[300]9{
[731]10   const size_t CEventClient::headerSize = sizeof(int) + sizeof(size_t) + sizeof(int) + sizeof(classId) + sizeof(typeId);
11
12   CEventClient::CEventClient(int classId_, int typeId_)
[300]13   {
[731]14     classId = classId_;
15     typeId = typeId_;
[300]16   }
[731]17
18   void CEventClient::push(int rank, int nbSender, CMessage& msg)
[300]19   {
[731]20     nbSenders.push_back(nbSender);
21     ranks.push_back(rank);
22     messages.push_back(&msg);
[300]23   }
24
25   bool CEventClient::isEmpty(void)
26   {
[731]27     return ranks.empty();
[300]28   }
29
[731]30   std::list<int> CEventClient::getRanks(void)
[300]31   {
[731]32     return ranks;
[300]33   }
[731]34
35   std::list<int> CEventClient::getSizes(void)
[300]36   {
[731]37     std::list<CMessage*>::iterator it;
38     std::list<int> sizes;
39
40     for (it = messages.begin(); it != messages.end(); ++it) sizes.push_back((*it)->size() + headerSize);
41     return sizes;
[300]42   }
[731]43
44   void CEventClient::send(size_t timeLine, const std::list<int>& sizes, std::list<CBufferOut*>& buffers)
[300]45   {
[731]46     std::list<CBufferOut*>::iterator itBuff = buffers.begin();
47     std::list<int>::const_iterator itSizes = sizes.begin(), itSenders = nbSenders.begin();
48     std::list<CMessage*>::iterator itMsg = messages.begin();
49
50     for (; itBuff != buffers.end(); ++itBuff, ++itSizes, ++itSenders, ++itMsg)
[300]51     {
[731]52       **itBuff << *itSizes << timeLine << *itSenders << classId << typeId << **itMsg;
[300]53     }
54   }
55}
Note: See TracBrowser for help on using the repository browser.