Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/wroot/mpi_ntuple_row_wise is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_wroot_mpi_ntuple_row_wise
0005 #define tools_wroot_mpi_ntuple_row_wise
0006 
0007 // MPI pntuple. It uses the tools/impi interface.
0008 
0009 #include "base_pntuple_row_wise"
0010 #include "mpi_basket_add"
0011 #include "impi_ntuple"
0012 
0013 #include "../S_STRING"
0014 #include "../forit"
0015 
0016 namespace tools {
0017 namespace wroot {
0018 
0019 class mpi_ntuple_row_wise : public base_pntuple_row_wise, public virtual impi_ntuple {
0020   typedef base_pntuple_row_wise parent;
0021 public:
0022   virtual bool add_row(impi& a_mpi,int a_dest,int a_tag) {
0023     if(m_cols.empty()) return false;
0024     tools_vforit(icol*,m_cols,it) (*it)->add();
0025     mpi_basket_add _badd(a_mpi,a_dest,a_tag,m_id,0);
0026     if(!m_row_wise_branch.pfill(_badd,0)) return false;
0027     tools_vforit(icol*,m_cols,it) (*it)->set_def();
0028     return true;
0029   }
0030 
0031   virtual bool end_fill(impi& a_mpi,int a_dest,int a_tag) {
0032     mpi_basket_add _badd(a_mpi,a_dest,a_tag,m_id,0);
0033     if(!m_row_wise_branch.end_pfill(_badd)) return false;
0034 
0035     a_mpi.pack_reset();
0036     if(!a_mpi.pack(mpi_protocol_end_fill())) return false;
0037     if(!a_mpi.pack(m_id)) return false;
0038     if(!end_leaves(a_mpi)) return false;
0039     if(!a_mpi.send_buffer(a_dest,a_tag)) return false;
0040 
0041     return true;
0042   }
0043 
0044 public:
0045   mpi_ntuple_row_wise(uint32 a_id,std::ostream& a_out,
0046                       bool a_byte_swap,uint32 a_compression,seek a_seek_directory,
0047                       const std::string& a_name,const std::string& a_title,
0048                       uint32 a_basket_size,
0049                       bool a_verbose)
0050   :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_basket_size,a_verbose)
0051   ,m_id(a_id)
0052   {}
0053   mpi_ntuple_row_wise(uint32 a_id,std::ostream& a_out,
0054                       bool a_byte_swap,uint32 a_compression,seek a_seek_directory,
0055                       uint32 a_basket_size,
0056                       const ntuple_booking& a_bkg,bool a_verbose)
0057   :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_basket_size,a_bkg,a_verbose)
0058   ,m_id(a_id)
0059   {}
0060   virtual ~mpi_ntuple_row_wise() {}
0061 protected:
0062   mpi_ntuple_row_wise(const mpi_ntuple_row_wise& a_from):impi_ntuple(a_from),parent(a_from){}
0063   mpi_ntuple_row_wise& operator=(const mpi_ntuple_row_wise& a_from){parent::operator=(a_from);return *this;}
0064 protected:
0065   bool end_leaves(impi& a_mpi) const {
0066 
0067 #include "MPI_SET_MAX.icc"
0068 
0069     tools_vforcit(base_leaf*,m_row_wise_branch.leaves(),pit) {
0070       base_leaf* _pleaf = *pit;
0071 
0072       bool set_done = false;
0073 
0074       TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(char)
0075       TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(short)
0076       TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(int)
0077       TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(float)
0078       TOOLS_WROOT_MPI_NTUPLE_LEAF_SET_LENGTH_MAX(double)
0079 
0080       TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(char)
0081       TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(short)
0082       TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(int)
0083       TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(float)
0084       TOOLS_WROOT_MPI_NTUPLE_LEAF_STD_VECTOR_SET_LENGTH_MAX(double)
0085 
0086       TOOLS_WROOT_MPI_NTUPLE_LEAF_STRING_SET_LENGTH_MAX
0087 
0088       if(!set_done) {
0089         m_out << "tools::wroot::mpi_ntuple_column_wise::end_leaves :"
0090               << " leaf " << _pleaf->name() << " with cid " << _pleaf->id_cls() << " not treated." << std::endl;
0091         return false;
0092       }
0093     }
0094 
0095 #undef TOOLS_WROOT_MPI_NTUPLE_SET_MAX
0096 #undef TOOLS_WROOT_MPI_NTUPLE_STRING_SET_MAX
0097 
0098     return true;
0099   }
0100 protected:
0101   uint32 m_id;
0102 };
0103 
0104 }}
0105 
0106 #endif