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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 tools/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 {
 20   typedef base_pntuple_row_wise parent;
 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 
 69     tools_vforcit(base_leaf*,m_row_wise_branch.leaves(),pit) {
 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:
101   uint32 m_id;
102 };
103 
104 }}
105 
106 #endif