g4tools  5.4.0
mpi_ntuple_row_wise
Go to the documentation of this file.
1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
2 // See the file tools.license for terms.
3 
4 #ifndef tools_wroot_mpi_ntuple_row_wise
5 #define tools_wroot_mpi_ntuple_row_wise
6 
7 // MPI pntuple. It uses the inlib/impi interface.
8 
9 #include "base_pntuple_row_wise"
10 #include "mpi_basket_add"
11 #include "impi_ntuple"
12 
13 #include "../S_STRING"
14 #include "../forit"
15 
16 namespace tools {
17 namespace wroot {
18 
19 class mpi_ntuple_row_wise : public base_pntuple_row_wise, public virtual impi_ntuple {
21 public:
22  virtual bool add_row(impi& a_mpi,int a_dest,int a_tag) {
23  if(m_cols.empty()) return false;
24  tools_vforit(icol*,m_cols,it) (*it)->add();
25  mpi_basket_add _badd(a_mpi,a_dest,a_tag,m_id,0);
26  if(!m_row_wise_branch.pfill(_badd,0)) return false;
27  tools_vforit(icol*,m_cols,it) (*it)->set_def();
28  return true;
29  }
30 
31  virtual bool end_fill(impi& a_mpi,int a_dest,int a_tag) {
32  mpi_basket_add _badd(a_mpi,a_dest,a_tag,m_id,0);
33  if(!m_row_wise_branch.end_pfill(_badd)) return false;
34 
35  a_mpi.pack_reset();
36  if(!a_mpi.pack(mpi_protocol_end_fill())) return false;
37  if(!a_mpi.pack(m_id)) return false;
38  if(!end_leaves(a_mpi)) return false;
39  if(!a_mpi.send_buffer(a_dest,a_tag)) return false;
40 
41  return true;
42  }
43 
44 public:
45  mpi_ntuple_row_wise(uint32 a_id,std::ostream& a_out,
46  bool a_byte_swap,uint32 a_compression,seek a_seek_directory,
47  const std::string& a_name,const std::string& a_title,
48  uint32 a_basket_size,
49  bool a_verbose)
50  :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_basket_size,a_verbose)
51  ,m_id(a_id)
52  {}
53  mpi_ntuple_row_wise(uint32 a_id,std::ostream& a_out,
54  bool a_byte_swap,uint32 a_compression,seek a_seek_directory,
55  uint32 a_basket_size,
56  const ntuple_booking& a_bkg,bool a_verbose)
57  :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_basket_size,a_bkg,a_verbose)
58  ,m_id(a_id)
59  {}
60  virtual ~mpi_ntuple_row_wise() {}
61 protected:
62  mpi_ntuple_row_wise(const mpi_ntuple_row_wise& a_from):impi_ntuple(a_from),parent(a_from){}
63  mpi_ntuple_row_wise& operator=(const mpi_ntuple_row_wise& a_from){parent::operator=(a_from);return *this;}
64 protected:
65  bool end_leaves(impi& a_mpi) const {
66 
67 #include "MPI_SET_MAX.icc"
68 
70  base_leaf* _pleaf = *pit;
71 
72  bool set_done = false;
73 
74  TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(char)
75  TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(short)
76  TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(int)
77  TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(float)
78  TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(double)
79 
80  TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(char)
81  TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(short)
82  TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(int)
83  TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(float)
84  TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(double)
85 
86  TOOLS_WROOT_MPI_NTUPLE_LEAF_STRING_SET_LENGTH_MAX
87 
88  if(!set_done) {
89  m_out << "tools::wroot::mpi_ntuple_column_wise::end_leaves :"
90  << " leaf " << _pleaf->name() << " with cid " << _pleaf->id_cls() << " not treated." << std::endl;
91  return false;
92  }
93  }
94 
95 #undef TOOLS_WROOT_MPI_NTUPLE_SET_MAX
96 #undef TOOLS_WROOT_MPI_NTUPLE_STRING_SET_MAX
97 
98  return true;
99  }
100 protected:
102 };
103 
104 }}
105 
106 #endif
tools::wroot::mpi_ntuple_row_wise::end_fill
virtual bool end_fill(impi &a_mpi, int a_dest, int a_tag)
Definition: mpi_ntuple_row_wise:31
tools::wroot::seek
int64 seek
Definition: seek:16
tools::wroot::icol
Definition: icol:21
tools::wroot::mpi_ntuple_row_wise::mpi_ntuple_row_wise
mpi_ntuple_row_wise(const mpi_ntuple_row_wise &a_from)
Definition: mpi_ntuple_row_wise:62
tools::wroot::base_pntuple_row_wise::operator=
base_pntuple_row_wise & operator=(const base_pntuple_row_wise &)
Definition: base_pntuple_row_wise:156
tools::wroot::base_leaf::id_cls
virtual cid id_cls() const
Definition: base_leaf:34
tools::wroot::base_pntuple_row_wise
Definition: base_pntuple_row_wise:20
tools::wroot::base_pntuple::m_out
std::ostream & m_out
Definition: base_pntuple:122
tools::wroot::branch::pfill
bool pfill(iadd_basket &a_badd, uint32 a_nev)
Definition: branch:416
tools::wroot::branch::leaves
const std::vector< base_leaf * > & leaves() const
Definition: branch:243
tools::wroot::mpi_ntuple_row_wise
Definition: mpi_ntuple_row_wise:19
tools::wroot::mpi_ntuple_row_wise::add_row
virtual bool add_row(impi &a_mpi, int a_dest, int a_tag)
Definition: mpi_ntuple_row_wise:22
tools::wroot::mpi_ntuple_row_wise::operator=
mpi_ntuple_row_wise & operator=(const mpi_ntuple_row_wise &a_from)
Definition: mpi_ntuple_row_wise:63
tools::wroot::mpi_ntuple_row_wise::mpi_ntuple_row_wise
mpi_ntuple_row_wise(uint32 a_id, std::ostream &a_out, bool a_byte_swap, uint32 a_compression, seek a_seek_directory, const std::string &a_name, const std::string &a_title, uint32 a_basket_size, bool a_verbose)
Definition: mpi_ntuple_row_wise:45
tools::impi::pack_reset
virtual void pack_reset()=0
impi_ntuple
tools::wroot::mpi_ntuple_row_wise::end_leaves
bool end_leaves(impi &a_mpi) const
Definition: mpi_ntuple_row_wise:65
tools::wroot::branch::end_pfill
bool end_pfill(iadd_basket &a_badd)
Definition: branch:478
tools::wroot::base_leaf
Definition: base_leaf:19
MPI_SET_MAX.icc
tools::impi
Definition: impi:14
tools_vforit
#define tools_vforit(a__T, a__v, a__it)
Definition: forit:13
base_pntuple_row_wise
tools::wroot::mpi_basket_add
Definition: mpi_basket_add:13
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::wroot::base_pntuple
Definition: base_pntuple:21
tools::wroot::base_pntuple_row_wise::m_row_wise_branch
branch m_row_wise_branch
Definition: base_pntuple_row_wise:228
tools::wroot::mpi_protocol_end_fill
uint32 mpi_protocol_end_fill()
Definition: mpi_protocol:14
tools::impi::pack
virtual bool pack(char)=0
tools::wroot::base_leaf::name
const std::string & name() const
Definition: base_leaf:94
tools::wroot::base_pntuple::m_cols
std::vector< icol * > m_cols
Definition: base_pntuple:126
mpi_basket_add
tools::wroot::impi_ntuple
Definition: impi_ntuple:12
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::wroot::mpi_ntuple_row_wise::~mpi_ntuple_row_wise
virtual ~mpi_ntuple_row_wise()
Definition: mpi_ntuple_row_wise:60
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::wroot::mpi_ntuple_row_wise::mpi_ntuple_row_wise
mpi_ntuple_row_wise(uint32 a_id, std::ostream &a_out, bool a_byte_swap, uint32 a_compression, seek a_seek_directory, uint32 a_basket_size, const ntuple_booking &a_bkg, bool a_verbose)
Definition: mpi_ntuple_row_wise:53
tools::ntuple_booking
Definition: ntuple_booking:49
tools::impi::send_buffer
virtual bool send_buffer(int, int)=0
tools::wroot::mpi_ntuple_row_wise::m_id
uint32 m_id
Definition: mpi_ntuple_row_wise:101