g4tools  5.4.0
Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
tools::wroot::mpi_ntuple_column_wise Class Reference
Inheritance diagram for tools::wroot::mpi_ntuple_column_wise:
Inheritance graph
[legend]
Collaboration diagram for tools::wroot::mpi_ntuple_column_wise:
Collaboration graph
[legend]

Classes

class  basket_add
 

Public Member Functions

virtual bool add_row (impi &a_mpi, int a_dest, int a_tag)
 
virtual bool end_fill (impi &a_mpi, int a_dest, int a_tag)
 
 mpi_ntuple_column_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, bool a_row_mode, uint32 a_nev, bool a_verbose)
 
 mpi_ntuple_column_wise (uint32 a_id, std::ostream &a_out, bool a_byte_swap, uint32 a_compression, seek a_seek_directory, const std::vector< uint32 > &a_basket_sizes, const ntuple_booking &a_bkg, bool a_row_mode, uint32 a_nev, bool a_verbose)
 
virtual ~mpi_ntuple_column_wise ()
 
- Public Member Functions inherited from tools::wroot::base_pntuple_column_wise
 base_pntuple_column_wise (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, bool a_verbose)
 
 base_pntuple_column_wise (std::ostream &a_out, bool a_byte_swap, uint32 a_compression, seek a_seek_directory, const std::vector< uint32 > &a_basket_sizes, const ntuple_booking &a_bkg, bool a_verbose)
 
virtual ~base_pntuple_column_wise ()
 
template<class T >
column_ref< T > * create_column_ref (uint32 a_basket_size, const std::string &a_name, const T &a_ref)
 
template<class T >
column< T > * create_column (uint32 a_basket_size, const std::string &a_name, const T &a_def=T())
 
column_string_ref * create_column_string_ref (uint32 a_basket_size, const std::string &a_name, const std::string &a_ref)
 
column_string * create_column_string (uint32 a_basket_size, const std::string &a_name, const std::string &a_def=std::string())
 
column_vector_string_ref * create_column_vector_string_ref (uint32 a_basket_size, const std::string &a_name, const std::vector< std::string > &a_ref, char a_sep)
 
column_vector_string * create_column_vector_string (uint32 a_basket_size, const std::string &a_name, const std::vector< std::string > &a_def, char a_sep)
 
template<class T >
std_vector_column_ref< T > * create_column_vector_ref (uint32 a_basket_size, const std::string &a_name, const std::vector< T > &a_ref)
 
template<class T >
std_vector_column< T > * create_column_vector (uint32 a_basket_size, const std::string &a_name, const std::vector< T > &a_def=std::vector< T >())
 
- Public Member Functions inherited from tools::wroot::base_pntuple
 base_pntuple (std::ostream &a_out, seek a_seek_directory, const std::string &a_name, const std::string &a_title)
 
virtual ~base_pntuple ()
 
const std::vector< icol * > & columns () const
 
template<class T >
column_ref< T > * find_column_ref (const std::string &a_name)
 
template<class T >
column< T > * find_column (const std::string &a_name)
 
column_string_ref * find_column_string_ref (const std::string &a_name)
 
column_string * find_column_string (const std::string &a_name)
 
template<class T >
std_vector_column_ref< T > * find_column_vector_ref (const std::string &a_name)
 
template<class T >
std_vector_column< T > * find_column_vector (const std::string &a_name)
 
column_vector_string_ref * find_column_vector_string_ref (const std::string &a_name)
 
column_vector_string * find_column_vector_string (const std::string &a_name)
 
void print_columns (std::ostream &a_out)
 
- Public Member Functions inherited from tools::wroot::impi_ntuple
virtual ~impi_ntuple ()
 

Protected Member Functions

 mpi_ntuple_column_wise (const mpi_ntuple_column_wise &a_from)
 
mpi_ntuple_column_wiseoperator= (const mpi_ntuple_column_wise &a_from)
 
bool end_leaves (impi &a_mpi) const
 
- Protected Member Functions inherited from tools::wroot::base_pntuple_column_wise
 base_pntuple_column_wise (const base_pntuple_column_wise &a_from)
 
base_pntuple_column_wiseoperator= (const base_pntuple_column_wise &)
 
- Protected Member Functions inherited from tools::wroot::base_pntuple
 base_pntuple (const base_pntuple &a_from)
 
base_pntupleoperator= (const base_pntuple &)
 

Static Protected Member Functions

static bool ready_to_flush_baskets (std::vector< icol * > &a_cols)
 
static bool flush_baskets (impi &a_mpi, int a_dest, int a_tag, uint32 a_id, std::vector< icol * > &a_cols)
 
static bool flush_remaining_baskets (size_t &a_number, impi &a_mpi, int a_dest, int a_tag, uint32 a_id, std::vector< icol * > &a_cols)
 

Protected Attributes

uint32 m_id
 
bool m_row_mode
 
uint32 m_nev
 
- Protected Attributes inherited from tools::wroot::base_pntuple_column_wise
file m_file
 
std::vector< branch * > m_branches
 
- Protected Attributes inherited from tools::wroot::base_pntuple
std::ostream & m_out
 
seek m_seek_directory
 
std::string m_name
 
std::string m_title
 
std::vector< icol * > m_cols
 

Detailed Description

Definition at line 19 of file mpi_ntuple_column_wise.

Constructor & Destructor Documentation

◆ mpi_ntuple_column_wise() [1/3]

tools::wroot::mpi_ntuple_column_wise::mpi_ntuple_column_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,
bool  a_row_mode,
uint32  a_nev,
bool  a_verbose 
)
inline

Definition at line 107 of file mpi_ntuple_column_wise.

112  :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_name,a_title,a_verbose)
113  ,m_id(a_id)
114  ,m_row_mode(a_row_mode)
115  ,m_nev(a_nev)
116  {
117  if(m_row_mode) {
118  if(!m_nev) m_nev = 4000; //4000*sizeof(double) = 32000 = default basket size.
119  } else {
120  m_nev = 0;
121  }
122  }

◆ mpi_ntuple_column_wise() [2/3]

tools::wroot::mpi_ntuple_column_wise::mpi_ntuple_column_wise ( uint32  a_id,
std::ostream &  a_out,
bool  a_byte_swap,
uint32  a_compression,
seek  a_seek_directory,
const std::vector< uint32 > &  a_basket_sizes,
const ntuple_booking a_bkg,
bool  a_row_mode,
uint32  a_nev,
bool  a_verbose 
)
inline

Definition at line 124 of file mpi_ntuple_column_wise.

129  :parent(a_out,a_byte_swap,a_compression,a_seek_directory,a_basket_sizes,a_bkg,a_verbose)
130  ,m_id(a_id)
131  ,m_row_mode(a_row_mode)
132  ,m_nev(a_nev)
133  {
134  if(m_row_mode) {
135  if(!m_nev) m_nev = 4000; //4000*sizeof(double) = 32000 = default basket size.
136  } else {
137  m_nev = 0;
138  }
139  }

◆ ~mpi_ntuple_column_wise()

virtual tools::wroot::mpi_ntuple_column_wise::~mpi_ntuple_column_wise ( )
inlinevirtual

Definition at line 140 of file mpi_ntuple_column_wise.

140 {}

◆ mpi_ntuple_column_wise() [3/3]

tools::wroot::mpi_ntuple_column_wise::mpi_ntuple_column_wise ( const mpi_ntuple_column_wise a_from)
inlineprotected

Definition at line 142 of file mpi_ntuple_column_wise.

143  :impi_ntuple(a_from)
144  ,parent(a_from)
145  ,m_row_mode(a_from.m_row_mode)
146  ,m_nev(a_from.m_nev)
147  {}

Member Function Documentation

◆ add_row()

virtual bool tools::wroot::mpi_ntuple_column_wise::add_row ( impi a_mpi,
int  a_dest,
int  a_tag 
)
inlinevirtual

Implements tools::wroot::impi_ntuple.

Definition at line 65 of file mpi_ntuple_column_wise.

65  {
66  if(m_cols.empty()) return false;
67 
68  tools_vforit(icol*,m_cols,it) (*it)->add();
69 
70  uint32 _icol = 0;
71  tools_vforit(icol*,m_cols,it) {
72  basket_add _badd(a_mpi,a_dest,a_tag,m_id,_icol,(*it)->get_branch(),m_cols,m_row_mode);_icol++;
73  if(!(*it)->get_branch().pfill(_badd,m_nev)) return false;
74  }
75 
76  tools_vforit(icol*,m_cols,it) (*it)->set_def();
77  return true;
78  }

◆ end_fill()

virtual bool tools::wroot::mpi_ntuple_column_wise::end_fill ( impi a_mpi,
int  a_dest,
int  a_tag 
)
inlinevirtual

Implements tools::wroot::impi_ntuple.

Definition at line 80 of file mpi_ntuple_column_wise.

80  {
81  uint32 _icol = 0;
82  tools_vforit(icol*,m_cols,it) {
83  basket_add _badd(a_mpi,a_dest,a_tag,m_id,_icol,(*it)->get_branch(),m_cols,m_row_mode);_icol++;
84  if(!(*it)->get_branch().end_pfill(_badd)) return false;
85  }
86 
87  if(m_row_mode) {
88  size_t number;
89  bool status = flush_remaining_baskets(number,a_mpi,a_dest,a_tag,m_id,m_cols);
90  if(number) {
91  m_out << "tools::wroot::mpi_ntuple_column_wise::end_fill : it remained " << number << " baskets not written on file." << std::endl;
92  status = false;
93  }
94  if(!status) return false;
95  }
96 
97  a_mpi.pack_reset();
98  if(!a_mpi.pack(mpi_protocol_end_fill())) return false;
99  if(!a_mpi.pack(m_id)) return false;
100  if(!end_leaves(a_mpi)) return false;
101  if(!a_mpi.send_buffer(a_dest,a_tag)) return false;
102 
103  return true;
104  }

◆ end_leaves()

bool tools::wroot::mpi_ntuple_column_wise::end_leaves ( impi a_mpi) const
inlineprotected

Definition at line 198 of file mpi_ntuple_column_wise.

198  {
199 #include "MPI_SET_MAX.icc"
200  tools_vforcit(icol*,m_cols,pit) {
201  base_leaf* _pleaf = (*pit)->get_leaf();
202 
203  bool set_done = false;
204 
205  TOOLS_WROOT_MPI_NTUPLE_LEAF_STRING_SET_LENGTH_MAX
206 
207  if(!set_done) {
208  if(!a_mpi.pack((uint32)0)) return false;
209  if(!a_mpi.pack((int)0)) return false;
210  }
211  }
212 #undef TOOLS_WROOT_MPI_NTUPLE_SET_MAX
213 #undef TOOLS_WROOT_MPI_NTUPLE_STRING_SET_MAX
214  return true;
215  }

◆ flush_baskets()

static bool tools::wroot::mpi_ntuple_column_wise::flush_baskets ( impi a_mpi,
int  a_dest,
int  a_tag,
uint32  a_id,
std::vector< icol * > &  a_cols 
)
inlinestaticprotected

Definition at line 159 of file mpi_ntuple_column_wise.

159  {
160  a_mpi.pack_reset();
161  if(!a_mpi.pack(mpi_protocol_baskets())) return false;
162  if(!a_mpi.pack(a_id)) return false;
163 
164  bool status = true;
165  uint32 _icol = 0;
166  tools_vforit(icol*,a_cols,it) {
167  branch& _branch = (*it)->get_branch();
168  basket* _front_basket = _branch.m_parallel_baskets.front();
169  if(status) {
170  if(!mpi_pack_basket(a_mpi,_icol,*_front_basket)) status = false;
171  }
172  _branch.m_parallel_baskets.erase(_branch.m_parallel_baskets.begin());
173  delete _front_basket;
174  _icol++;
175  }
176  if(!status) return false;
177 
178  return a_mpi.send_buffer(a_dest,a_tag);
179  }

◆ flush_remaining_baskets()

static bool tools::wroot::mpi_ntuple_column_wise::flush_remaining_baskets ( size_t &  a_number,
impi a_mpi,
int  a_dest,
int  a_tag,
uint32  a_id,
std::vector< icol * > &  a_cols 
)
inlinestaticprotected

Definition at line 181 of file mpi_ntuple_column_wise.

181  {
182  a_number = 0;
183  while(ready_to_flush_baskets(a_cols)) {
184  if(!flush_baskets(a_mpi,a_dest,a_tag,a_id,a_cols)) return false;
185  }
186  // look for pending baskets.
187  {tools_vforit(icol*,a_cols,it) {
188  branch& _branch = (*it)->get_branch();
189  a_number += _branch.m_parallel_baskets.size();
190  }}
191  {tools_vforit(icol*,a_cols,it) {
192  branch& _branch = (*it)->get_branch();
193  safe_clear(_branch.m_parallel_baskets);
194  }}
195  return true;
196  }

◆ operator=()

mpi_ntuple_column_wise& tools::wroot::mpi_ntuple_column_wise::operator= ( const mpi_ntuple_column_wise a_from)
inlineprotected

Definition at line 148 of file mpi_ntuple_column_wise.

148 {parent::operator=(a_from);return *this;}

◆ ready_to_flush_baskets()

static bool tools::wroot::mpi_ntuple_column_wise::ready_to_flush_baskets ( std::vector< icol * > &  a_cols)
inlinestaticprotected

Definition at line 150 of file mpi_ntuple_column_wise.

150  {
151  //return true if all parallel branches have at least one basket in their m_parallel_baskets.
152  if(a_cols.empty()) return false;
153  tools_vforit(icol*,a_cols,it) {
154  branch& _branch = (*it)->get_branch();
155  if(_branch.m_parallel_baskets.empty()) return false;
156  }
157  return true;
158  }

Member Data Documentation

◆ m_id

uint32 tools::wroot::mpi_ntuple_column_wise::m_id
protected

Definition at line 217 of file mpi_ntuple_column_wise.

◆ m_nev

uint32 tools::wroot::mpi_ntuple_column_wise::m_nev
protected

Definition at line 219 of file mpi_ntuple_column_wise.

◆ m_row_mode

bool tools::wroot::mpi_ntuple_column_wise::m_row_mode
protected

Definition at line 218 of file mpi_ntuple_column_wise.


The documentation for this class was generated from the following file:
tools::wroot::mpi_ntuple_column_wise::m_id
uint32 m_id
Definition: mpi_ntuple_column_wise:217
tools::wroot::base_pntuple::m_out
std::ostream & m_out
Definition: base_pntuple:122
tools::wroot::mpi_protocol_baskets
uint32 mpi_protocol_baskets()
Definition: mpi_protocol:13
tools::wroot::mpi_ntuple_column_wise::flush_remaining_baskets
static bool flush_remaining_baskets(size_t &a_number, impi &a_mpi, int a_dest, int a_tag, uint32 a_id, std::vector< icol * > &a_cols)
Definition: mpi_ntuple_column_wise:181
tools::wroot::mpi_ntuple_column_wise::ready_to_flush_baskets
static bool ready_to_flush_baskets(std::vector< icol * > &a_cols)
Definition: mpi_ntuple_column_wise:150
tools::wroot::base_pntuple_column_wise::operator=
base_pntuple_column_wise & operator=(const base_pntuple_column_wise &)
Definition: base_pntuple_column_wise:205
tools::safe_clear
void safe_clear(std::map< K, V * > &a_m)
Definition: mapmanip:12
tools::wroot::mpi_ntuple_column_wise::flush_baskets
static bool flush_baskets(impi &a_mpi, int a_dest, int a_tag, uint32 a_id, std::vector< icol * > &a_cols)
Definition: mpi_ntuple_column_wise:159
MPI_SET_MAX.icc
tools_vforit
#define tools_vforit(a__T, a__v, a__it)
Definition: forit:13
tools::wroot::mpi_ntuple_column_wise::end_leaves
bool end_leaves(impi &a_mpi) const
Definition: mpi_ntuple_column_wise:198
tools::wroot::mpi_protocol_end_fill
uint32 mpi_protocol_end_fill()
Definition: mpi_protocol:14
tools::wroot::mpi_ntuple_column_wise::m_nev
uint32 m_nev
Definition: mpi_ntuple_column_wise:219
tools::wroot::base_pntuple::m_cols
std::vector< icol * > m_cols
Definition: base_pntuple:126
tools_vforcit
#define tools_vforcit(a__T, a__v, a__it)
Definition: forit:7
tools::wroot::mpi_pack_basket
bool mpi_pack_basket(impi &a_mpi, uint32 a_icol, const basket &a_basket)
Definition: mpi_send_basket:14
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::wroot::mpi_ntuple_column_wise::m_row_mode
bool m_row_mode
Definition: mpi_ntuple_column_wise:218