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

Last change on this file since 773 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
Line 
1#include "xios_spl.hpp"
2#include "event_client.hpp"
3#include "buffer_out.hpp"
4#include "message.hpp"
5#include "type.hpp"
6#include "mpi.hpp"
7
8namespace xios
9{
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_)
13   {
14     classId = classId_;
15     typeId = typeId_;
16   }
17
18   void CEventClient::push(int rank, int nbSender, CMessage& msg)
19   {
20     nbSenders.push_back(nbSender);
21     ranks.push_back(rank);
22     messages.push_back(&msg);
23   }
24
25   bool CEventClient::isEmpty(void)
26   {
27     return ranks.empty();
28   }
29
30   std::list<int> CEventClient::getRanks(void)
31   {
32     return ranks;
33   }
34
35   std::list<int> CEventClient::getSizes(void)
36   {
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;
42   }
43
44   void CEventClient::send(size_t timeLine, const std::list<int>& sizes, std::list<CBufferOut*>& buffers)
45   {
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)
51     {
52       **itBuff << *itSizes << timeLine << *itSenders << classId << typeId << **itMsg;
53     }
54   }
55}
Note: See TracBrowser for help on using the repository browser.