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

Public Types

typedef unsigned int num_t
 

Public Member Functions

virtual bool pack (char a_val)
 
virtual bool pack (short a_val)
 
virtual bool pack (int a_val)
 
virtual bool pack (unsigned int a_val)
 
virtual bool pack (tools::uint64 a_val)
 
virtual bool pack (tools::int64 a_val)
 
virtual bool pack (float a_val)
 
virtual bool pack (double a_val)
 
virtual bool bpack (bool a_val)
 
virtual bool spack (const std::string &a_s)
 
virtual bool vpack (const std::vector< unsigned int > &a_v)
 
virtual bool vpack (const std::vector< int > &a_v)
 
virtual bool vpack (const std::vector< double > &a_v)
 
virtual bool pack (tools::uint32 a_size, const char *a_buffer)
 
virtual bool pack (tools::uint32 a_size, const int *a_buffer)
 
virtual bool unpack (char &a_val)
 
virtual bool unpack (short &a_val)
 
virtual bool unpack (int &a_val)
 
virtual bool unpack (unsigned int &a_val)
 
virtual bool unpack (tools::uint64 &a_val)
 
virtual bool unpack (tools::int64 &a_val)
 
virtual bool unpack (float &a_val)
 
virtual bool unpack (double &a_val)
 
virtual bool bunpack (bool &a_val)
 
virtual bool vunpack (std::vector< unsigned int > &a_v)
 
virtual bool vunpack (std::vector< int > &a_v)
 
virtual bool vunpack (std::vector< double > &a_v)
 
virtual bool sunpack (std::string &a_s)
 
virtual bool unpack (tools::uint32 &a_size, char *&a_buffer)
 
virtual bool unpack (tools::uint32 &a_size, int *&a_buffer)
 
virtual void pack_reset ()
 
virtual bool send_buffer (int a_dest, int a_tag)
 
virtual bool wait_buffer (int a_rank, int a_src, int a_tag, int &a_probe_src, bool a_verbose=false)
 
virtual bool wait_buffer (int a_rank, int a_tag, int &a_probe_src, bool a_verbose=false)
 
 wrmpi (std::ostream &a_out, const MPI_Comm &a_comm, tools::uint32 a_size=128)
 
 wrmpi (std::ostream &a_out, const MPI_Comm &a_comm, tools::uint32 a_size, char *a_buffer)
 
virtual ~wrmpi ()
 
int ipos () const
 
const char * buffer () const
 
- Public Member Functions inherited from tools::impi
virtual ~impi ()
 

Protected Member Functions

 wrmpi (const wrmpi &a_from)
 
wrmpioperator= (const wrmpi &)
 
bool expand2 (tools::uint32 a_new_size)
 
bool expand (tools::uint32 a_new_size)
 

Static Protected Member Functions

static const std::string & s_class ()
 

Protected Attributes

std::ostream & m_out
 
const MPI_Commm_comm
 
tools::uint32 m_size
 
char * m_buffer
 
char * m_max
 
char * m_pos
 
int m_ipos
 

Detailed Description

Definition at line 41 of file wrmpi.

Member Typedef Documentation

◆ num_t

typedef unsigned int tools::mpi::wrmpi::num_t

Definition at line 44 of file wrmpi.

Constructor & Destructor Documentation

◆ wrmpi() [1/3]

tools::mpi::wrmpi::wrmpi ( std::ostream &  a_out,
const MPI_Comm a_comm,
tools::uint32  a_size = 128 
)
inline

Definition at line 423 of file wrmpi.

424  :m_out(a_out)
425  ,m_comm(a_comm)
426  ,m_size(0)
427  ,m_buffer(0)
428  ,m_max(0)
429  ,m_pos(0)
430  ,m_ipos(0)
431  {
432 #ifdef TOOLS_MEM
433  tools::mem::increment(s_class().c_str());
434 #endif
435  m_size = a_size;
436  m_buffer = new char[m_size];
437  //if(!m_buffer) {}
439  m_pos = m_buffer;
440  }

◆ wrmpi() [2/3]

tools::mpi::wrmpi::wrmpi ( std::ostream &  a_out,
const MPI_Comm a_comm,
tools::uint32  a_size,
char *  a_buffer 
)
inline

Definition at line 441 of file wrmpi.

442  :m_out(a_out)
443  ,m_comm(a_comm)
444  ,m_size(a_size)
445  ,m_buffer(a_buffer)
446  ,m_max(0)
447  ,m_pos(0)
448  ,m_ipos(0)
449  {
450 #ifdef TOOLS_MEM
451  tools::mem::increment(s_class().c_str());
452 #endif
454  m_pos = m_buffer;
455  }

◆ ~wrmpi()

virtual tools::mpi::wrmpi::~wrmpi ( )
inlinevirtual

Definition at line 456 of file wrmpi.

456  {
457  delete [] m_buffer;
458 #ifdef TOOLS_MEM
459  tools::mem::decrement(s_class().c_str());
460 #endif
461  }

◆ wrmpi() [3/3]

tools::mpi::wrmpi::wrmpi ( const wrmpi a_from)
inlineprotected

Definition at line 463 of file wrmpi.

464  :parent(a_from)
465  ,m_out(a_from.m_out)
466  ,m_comm(a_from.m_comm)
467  ,m_size(0)
468  ,m_buffer(0)
469  ,m_max(0)
470  ,m_pos(0)
471  ,m_ipos(0)
472  {
473 #ifdef TOOLS_MEM
474  tools::mem::increment(s_class().c_str());
475 #endif
476  }

Member Function Documentation

◆ bpack()

virtual bool tools::mpi::wrmpi::bpack ( bool  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 131 of file wrmpi.

131  {
132  tools::uint32 sz = tools::uint32(sizeof(unsigned char));
133  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
134  unsigned char val = a_val?1:0;
136  m_out << "tools::mpi::wrmpi : MPI_Pack(bool) failed." << std::endl;
137  return false;
138  }
139  m_pos += sz;
140  return true;
141  }

◆ buffer()

const char* tools::mpi::wrmpi::buffer ( ) const
inline

Definition at line 483 of file wrmpi.

483 {return m_buffer;}

◆ bunpack()

virtual bool tools::mpi::wrmpi::bunpack ( bool &  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 299 of file wrmpi.

299  {
300  typedef unsigned char bool_t;
301  bool_t val;
303  m_out << "tools::mpi::wrmpi : MPI_Unpack(bool) failed." << std::endl;
304  a_val = false;
305  return false;
306  }
307  a_val = val==1?true:false;
308  return true;
309  }

◆ expand()

bool tools::mpi::wrmpi::expand ( tools::uint32  a_new_size)
inlineprotected

Definition at line 489 of file wrmpi.

489  {
491  if(!tools::realloc<char>(m_buffer,a_new_size,m_size)) {
492  m_out << "tools::mpi::wrmpi::expand :"
493  << " can't realloc " << a_new_size << " bytes."
494  << std::endl;
495  m_size = 0;
496  m_max = 0;
497  m_pos = 0;
498  //m_wb.set_eob(m_max);
499  return false;
500  }
501  m_size = a_new_size;
502  m_max = m_buffer + m_size;
503  m_pos = m_buffer + len;
504  return true;
505  }

◆ expand2()

bool tools::mpi::wrmpi::expand2 ( tools::uint32  a_new_size)
inlineprotected

Definition at line 487 of file wrmpi.

487 {return expand(tools::mx<tools::uint32>(2*m_size,a_new_size));} //CERN-ROOT logic.

◆ ipos()

int tools::mpi::wrmpi::ipos ( ) const
inline

Definition at line 479 of file wrmpi.

479 {return m_ipos;}

◆ operator=()

wrmpi& tools::mpi::wrmpi::operator= ( const wrmpi )
inlineprotected

Definition at line 477 of file wrmpi.

477 {return *this;}

◆ pack() [1/10]

virtual bool tools::mpi::wrmpi::pack ( char  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 51 of file wrmpi.

51  {
52  tools::uint32 sz = tools::uint32(sizeof(char));
53  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
55  m_out << "tools::mpi::wrmpi : MPI_Pack(char) failed." << std::endl;
56  return false;
57  }
58  m_pos += sz;
59  return true;
60  }

◆ pack() [2/10]

virtual bool tools::mpi::wrmpi::pack ( double  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 121 of file wrmpi.

121  {
122  tools::uint32 sz = tools::uint32(sizeof(double));
123  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
125  m_out << "tools::mpi::wrmpi : MPI_Pack(double) failed." << std::endl;
126  return false;
127  }
128  m_pos += sz;
129  return true;
130  }

◆ pack() [3/10]

virtual bool tools::mpi::wrmpi::pack ( float  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 111 of file wrmpi.

111  {
112  tools::uint32 sz = tools::uint32(sizeof(float));
113  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
115  m_out << "tools::mpi::wrmpi : MPI_Pack(float) failed." << std::endl;
116  return false;
117  }
118  m_pos += sz;
119  return true;
120  }

◆ pack() [4/10]

virtual bool tools::mpi::wrmpi::pack ( int  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 71 of file wrmpi.

71  {
72  tools::uint32 sz = tools::uint32(sizeof(int));
73  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
75  m_out << "tools::mpi::wrmpi : MPI_Pack(int) failed." << std::endl;
76  return false;
77  }
78  m_pos += sz;
79  return true;
80  }

◆ pack() [5/10]

virtual bool tools::mpi::wrmpi::pack ( short  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 61 of file wrmpi.

61  {
62  tools::uint32 sz = tools::uint32(sizeof(short));
63  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
65  m_out << "tools::mpi::wrmpi : MPI_Pack(short) failed." << std::endl;
66  return false;
67  }
68  m_pos += sz;
69  return true;
70  }

◆ pack() [6/10]

virtual bool tools::mpi::wrmpi::pack ( tools::int64  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 101 of file wrmpi.

101  {
103  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
105  m_out << "tools::mpi::wrmpi : MPI_Pack(int64) failed." << std::endl;
106  return false;
107  }
108  m_pos += sz;
109  return true;
110  }

◆ pack() [7/10]

virtual bool tools::mpi::wrmpi::pack ( tools::uint32  a_size,
const char *  a_buffer 
)
inlinevirtual

Implements tools::impi.

Definition at line 203 of file wrmpi.

203  {
204  if(!pack((num_t)a_size)) return false;
205  tools::uint32 sz = (tools::uint32)(a_size*sizeof(char));
206  if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
207 #ifdef TOOLS_USE_MPI_PACK_NOT_CONST
208  if(::MPI_Pack(const_cast<char*>(a_buffer),a_size,MPI_CHAR,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
209 #else
210  if(::MPI_Pack(a_buffer,a_size,MPI_CHAR,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
211 #endif
212  m_out << "tools::mpi::wrmpi : MPI_Pack(char*) failed." << std::endl;
213  return false;
214  }
215  m_pos += sz;
216  return true;
217  }

◆ pack() [8/10]

virtual bool tools::mpi::wrmpi::pack ( tools::uint32  a_size,
const int *  a_buffer 
)
inlinevirtual

Implements tools::impi.

Definition at line 219 of file wrmpi.

219  {
220  if(!pack((num_t)a_size)) return false;
221  tools::uint32 sz = (tools::uint32)(a_size*sizeof(int));
222  if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
223 #ifdef TOOLS_USE_MPI_PACK_NOT_CONST
224  if(::MPI_Pack(const_cast<int*>(a_buffer),a_size,MPI_INT,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
225 #else
226  if(::MPI_Pack(a_buffer,a_size,MPI_INT,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
227 #endif
228  m_out << "tools::mpi::wrmpi : MPI_Pack(int*) failed." << std::endl;
229  return false;
230  }
231  m_pos += sz;
232  return true;
233  }

◆ pack() [9/10]

virtual bool tools::mpi::wrmpi::pack ( tools::uint64  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 91 of file wrmpi.

91  {
93  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
95  m_out << "tools::mpi::wrmpi : MPI_Pack(uint64) failed." << std::endl;
96  return false;
97  }
98  m_pos += sz;
99  return true;
100  }

◆ pack() [10/10]

virtual bool tools::mpi::wrmpi::pack ( unsigned int  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 81 of file wrmpi.

81  {
82  tools::uint32 sz = tools::uint32(sizeof(unsigned int));
83  if(m_pos+sz>m_max) {if(!expand2(m_size+sz)) return false;}
85  m_out << "tools::mpi::wrmpi : MPI_Pack(unsigned int) failed." << std::endl;
86  return false;
87  }
88  m_pos += sz;
89  return true;
90  }

◆ pack_reset()

virtual void tools::mpi::wrmpi::pack_reset ( )
inlinevirtual

Implements tools::impi.

Definition at line 383 of file wrmpi.

383  {
384  delete [] m_buffer;
385  m_size = 128;
386  m_buffer = new char[m_size];
387  //if(!m_buffer) {}
389  m_pos = m_buffer;
390  m_ipos = 0; //IMPORTANT
391  }

◆ s_class()

static const std::string& tools::mpi::wrmpi::s_class ( )
inlinestaticprotected

Definition at line 46 of file wrmpi.

46  {
47  static const std::string s_v("tools::mpi::wrmpi");
48  return s_v;
49  }

◆ send_buffer()

virtual bool tools::mpi::wrmpi::send_buffer ( int  a_dest,
int  a_tag 
)
inlinevirtual

Implements tools::impi.

Definition at line 393 of file wrmpi.

393  { // used in tools/mpi/pntuple.
394  if(::MPI_Send(m_buffer,m_ipos,MPI_CHAR,a_dest,a_tag,m_comm)!=MPI_SUCCESS) {
395  m_out << "tools::mpi::wrmpi::send_buffer : MPI_Send() failed for rank destination " << a_dest << "." << std::endl;
396  return false;
397  }
398  return true;
399  }

◆ spack()

virtual bool tools::mpi::wrmpi::spack ( const std::string &  a_s)
inlinevirtual

Implements tools::impi.

Definition at line 142 of file wrmpi.

142  {
143  if(!pack((num_t)a_s.size())) return false;
144  tools::uint32 sz = (tools::uint32)a_s.size();
145  if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
146 #ifdef TOOLS_USE_MPI_PACK_NOT_CONST
147  if(::MPI_Pack(const_cast<char*>(a_s.c_str()),a_s.size(),MPI_CHAR,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
148 #else
149  if(::MPI_Pack(a_s.c_str(),a_s.size(),MPI_CHAR,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
150 #endif
151  m_out << "tools::mpi::wrmpi : MPI_Pack(std::string) failed." << std::endl;
152  return false;
153  }
154  m_pos += sz;
155  return true;
156  }

◆ sunpack()

virtual bool tools::mpi::wrmpi::sunpack ( std::string &  a_s)
inlinevirtual

Implements tools::impi.

Definition at line 343 of file wrmpi.

343  {
344  num_t num;
345  if(!unpack(num)) {a_s.clear();return false;}
346  a_s.resize(num);
347  if(::MPI_Unpack(m_buffer,m_size,&m_ipos,const_cast<char*>(a_s.c_str()),a_s.size(),MPI_CHAR,m_comm)!=MPI_SUCCESS) {
348  m_out << "tools::mpi::wrmpi : MPI_Unpack(std::string) failed." << std::endl;
349  a_s.clear();
350  return false;
351  }
352  return true;
353  }

◆ unpack() [1/10]

virtual bool tools::mpi::wrmpi::unpack ( char &  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 235 of file wrmpi.

235  {
237  m_out << "tools::mpi::wrmpi : MPI_Unpack(char) failed." << std::endl;
238  a_val = 0;
239  return false;
240  }
241  return true;
242  }

◆ unpack() [2/10]

virtual bool tools::mpi::wrmpi::unpack ( double &  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 291 of file wrmpi.

291  {
293  m_out << "tools::mpi::wrmpi : MPI_Unpack(double) failed." << std::endl;
294  a_val = 0;
295  return false;
296  }
297  return true;
298  }

◆ unpack() [3/10]

virtual bool tools::mpi::wrmpi::unpack ( float &  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 283 of file wrmpi.

283  {
285  m_out << "tools::mpi::wrmpi : MPI_Unpack(float) failed." << std::endl;
286  a_val = 0;
287  return false;
288  }
289  return true;
290  }

◆ unpack() [4/10]

virtual bool tools::mpi::wrmpi::unpack ( int &  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 251 of file wrmpi.

251  {
253  m_out << "tools::mpi::wrmpi : MPI_Unpack(int) failed." << std::endl;
254  a_val = 0;
255  return false;
256  }
257  return true;
258  }

◆ unpack() [5/10]

virtual bool tools::mpi::wrmpi::unpack ( short &  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 243 of file wrmpi.

243  {
245  m_out << "tools::mpi::wrmpi : MPI_Unpack(short) failed." << std::endl;
246  a_val = 0;
247  return false;
248  }
249  return true;
250  }

◆ unpack() [6/10]

virtual bool tools::mpi::wrmpi::unpack ( tools::int64 a_val)
inlinevirtual

Implements tools::impi.

Definition at line 275 of file wrmpi.

275  {
277  m_out << "tools::mpi::wrmpi : MPI_Unpack(int64) failed." << std::endl;
278  a_val = 0;
279  return false;
280  }
281  return true;
282  }

◆ unpack() [7/10]

virtual bool tools::mpi::wrmpi::unpack ( tools::uint32 a_size,
char *&  a_buffer 
)
inlinevirtual

Implements tools::impi.

Definition at line 354 of file wrmpi.

354  {
355  num_t num;
356  if(!unpack(num)) {a_size = 0;a_buffer = 0;return false;}
357  a_buffer = new char[num];
358  if(::MPI_Unpack(m_buffer,m_size,&m_ipos,a_buffer,num,MPI_CHAR,m_comm)!=MPI_SUCCESS) {
359  m_out << "tools::mpi::wrmpi : MPI_Unpack(char*) failed." << std::endl;
360  delete [] a_buffer;
361  a_size = 0;
362  a_buffer = 0;
363  return false;
364  }
365  a_size = num;
366  return true;
367  }

◆ unpack() [8/10]

virtual bool tools::mpi::wrmpi::unpack ( tools::uint32 a_size,
int *&  a_buffer 
)
inlinevirtual

Implements tools::impi.

Definition at line 368 of file wrmpi.

368  {
369  num_t num;
370  if(!unpack(num)) {a_size = 0;a_buffer = 0;return false;}
371  a_buffer = new int[num];
372  if(::MPI_Unpack(m_buffer,m_size,&m_ipos,a_buffer,num,MPI_INT,m_comm)!=MPI_SUCCESS) {
373  m_out << "tools::mpi::wrmpi : MPI_Unpack(int*) failed." << std::endl;
374  delete [] a_buffer;
375  a_size = 0;
376  a_buffer = 0;
377  return false;
378  }
379  a_size = num;
380  return true;
381  }

◆ unpack() [9/10]

virtual bool tools::mpi::wrmpi::unpack ( tools::uint64 a_val)
inlinevirtual

Implements tools::impi.

Definition at line 267 of file wrmpi.

267  {
269  m_out << "tools::mpi::wrmpi : MPI_Unpack(uint64) failed." << std::endl;
270  a_val = 0;
271  return false;
272  }
273  return true;
274  }

◆ unpack() [10/10]

virtual bool tools::mpi::wrmpi::unpack ( unsigned int &  a_val)
inlinevirtual

Implements tools::impi.

Definition at line 259 of file wrmpi.

259  {
261  m_out << "tools::mpi::wrmpi : MPI_Unpack(unsigned int) failed." << std::endl;
262  a_val = 0;
263  return false;
264  }
265  return true;
266  }

◆ vpack() [1/3]

virtual bool tools::mpi::wrmpi::vpack ( const std::vector< double > &  a_v)
inlinevirtual

Implements tools::impi.

Definition at line 188 of file wrmpi.

188  {
189  if(!pack((num_t)a_v.size())) return false;
190  tools::uint32 sz = (tools::uint32)(a_v.size()*sizeof(double));
191  if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
192 #ifdef TOOLS_USE_MPI_PACK_NOT_CONST
193  if(::MPI_Pack(const_cast<double*>(tools::vec_data(a_v)),a_v.size(),MPI_DOUBLE,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
194 #else
196 #endif
197  m_out << "tools::mpi::wrmpi : MPI_Pack(std::vector<double>) failed." << std::endl;
198  return false;
199  }
200  m_pos += sz;
201  return true;
202  }

◆ vpack() [2/3]

virtual bool tools::mpi::wrmpi::vpack ( const std::vector< int > &  a_v)
inlinevirtual

Implements tools::impi.

Definition at line 173 of file wrmpi.

173  {
174  if(!pack((num_t)a_v.size())) return false;
175  tools::uint32 sz = (tools::uint32)(a_v.size()*sizeof(int));
176  if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
177 #ifdef TOOLS_USE_MPI_PACK_NOT_CONST
178  if(::MPI_Pack(const_cast<int*>(tools::vec_data(a_v)),a_v.size(),MPI_INT,m_buffer,m_size,&m_ipos,m_comm)!=MPI_SUCCESS) {
179 #else
181 #endif
182  m_out << "tools::mpi::wrmpi : MPI_Pack(std::vector<int>) failed." << std::endl;
183  return false;
184  }
185  m_pos += sz;
186  return true;
187  }

◆ vpack() [3/3]

virtual bool tools::mpi::wrmpi::vpack ( const std::vector< unsigned int > &  a_v)
inlinevirtual

Implements tools::impi.

Definition at line 157 of file wrmpi.

157  {
158  if(!pack((num_t)a_v.size())) return false;
159  tools::uint32 sz = (tools::uint32)(a_v.size()*sizeof(unsigned int));
160  if((m_pos+sz)>m_max) {if(!expand2(m_size+sz)) return false;}
161 #ifdef TOOLS_USE_MPI_PACK_NOT_CONST
162  if(::MPI_Pack(const_cast<unsigned int*>(tools::vec_data(a_v)),a_v.size(),
164 #else
166 #endif
167  m_out << "tools::mpi::wrmpi : MPI_Pack(std::vector<unsigned int>) failed." << std::endl;
168  return false;
169  }
170  m_pos += sz;
171  return true;
172  }

◆ vunpack() [1/3]

virtual bool tools::mpi::wrmpi::vunpack ( std::vector< double > &  a_v)
inlinevirtual

Implements tools::impi.

Definition at line 332 of file wrmpi.

332  {
333  num_t num;
334  if(!unpack(num)) {a_v.clear();return false;}
335  a_v.resize(num);
337  m_out << "tools::mpi::wrmpi : MPI_Unpack(std::vector<double>) failed." << std::endl;
338  a_v.clear();
339  return false;
340  }
341  return true;
342  }

◆ vunpack() [2/3]

virtual bool tools::mpi::wrmpi::vunpack ( std::vector< int > &  a_v)
inlinevirtual

Implements tools::impi.

Definition at line 321 of file wrmpi.

321  {
322  num_t num;
323  if(!unpack(num)) {a_v.clear();return false;}
324  a_v.resize(num);
326  m_out << "tools::mpi::wrmpi : MPI_Unpack(std::vector<int>) failed." << std::endl;
327  a_v.clear();
328  return false;
329  }
330  return true;
331  }

◆ vunpack() [3/3]

virtual bool tools::mpi::wrmpi::vunpack ( std::vector< unsigned int > &  a_v)
inlinevirtual

Implements tools::impi.

Definition at line 310 of file wrmpi.

310  {
311  num_t num;
312  if(!unpack(num)) {a_v.clear();return false;}
313  a_v.resize(num);
315  m_out << "tools::mpi::wrmpi : MPI_Unpack(std::vector<unsigned int>) failed." << std::endl;
316  a_v.clear();
317  return false;
318  }
319  return true;
320  }

◆ wait_buffer() [1/2]

virtual bool tools::mpi::wrmpi::wait_buffer ( int  a_rank,
int  a_src,
int  a_tag,
int &  a_probe_src,
bool  a_verbose = false 
)
inlinevirtual

Implements tools::impi.

Definition at line 401 of file wrmpi.

401  {
402  int buffer_size = 0;
403  char* _buffer = 0;
404  if (!mpi::wait_buffer(m_out,a_rank,a_src,a_tag,m_comm,buffer_size,_buffer,a_probe_src,a_verbose)) {
405  m_out << "tools::mpi::wrmpi::wait_buffer : failed for rank " << a_rank << " and source " << a_src <<"." << std::endl;
406  return false;
407  }
408  // we take ownership of buffer :
409  delete [] m_buffer;
410  m_size = buffer_size;
411  m_buffer = _buffer;
413  m_pos = m_buffer;
414  m_ipos = 0; //IMPORTANT
415  return true;
416  }

◆ wait_buffer() [2/2]

virtual bool tools::mpi::wrmpi::wait_buffer ( int  a_rank,
int  a_tag,
int &  a_probe_src,
bool  a_verbose = false 
)
inlinevirtual

Implements tools::impi.

Definition at line 418 of file wrmpi.

418  {
419  return wait_buffer(a_rank,MPI_ANY_SOURCE,a_tag,a_probe_src,a_verbose);
420  }

Member Data Documentation

◆ m_buffer

char* tools::mpi::wrmpi::m_buffer
protected

Definition at line 511 of file wrmpi.

◆ m_comm

const MPI_Comm& tools::mpi::wrmpi::m_comm
protected

Definition at line 509 of file wrmpi.

◆ m_ipos

int tools::mpi::wrmpi::m_ipos
protected

Definition at line 515 of file wrmpi.

◆ m_max

char* tools::mpi::wrmpi::m_max
protected

Definition at line 512 of file wrmpi.

◆ m_out

std::ostream& tools::mpi::wrmpi::m_out
protected

Definition at line 508 of file wrmpi.

◆ m_pos

char* tools::mpi::wrmpi::m_pos
protected

Definition at line 513 of file wrmpi.

◆ m_size

tools::uint32 tools::mpi::wrmpi::m_size
protected

Definition at line 510 of file wrmpi.


The documentation for this class was generated from the following file:
MPI_CHAR
#define MPI_CHAR
Definition: dummy_mpi.h:20
tools::mpi::wrmpi::s_class
static const std::string & s_class()
Definition: wrmpi:46
tools::uint64
unsigned long long uint64
Definition: typedefs:72
MPI_Send
int MPI_Send(const void *, int, MPI_Datatype, int, int, MPI_Comm)
Definition: dummy_mpi.h:52
tools::int64
long long int64
Definition: typedefs:67
tools::mpi::wrmpi::m_size
tools::uint32 m_size
Definition: wrmpi:510
MPI_INT
#define MPI_INT
Definition: dummy_mpi.h:23
tools::mpi::wrmpi::expand2
bool expand2(tools::uint32 a_new_size)
Definition: wrmpi:487
tools::vec_data
const T * vec_data(const std::vector< T > &a_vec)
Definition: vdata:18
MPI_Pack
int MPI_Pack(const void *, int, MPI_Datatype, void *, int, int *, MPI_Comm)
Definition: dummy_mpi.h:36
MPI_ANY_SOURCE
#define MPI_ANY_SOURCE
Definition: dummy_mpi.h:28
tools::mpi::wrmpi::m_out
std::ostream & m_out
Definition: wrmpi:508
tools::mpi::wrmpi::num_t
unsigned int num_t
Definition: wrmpi:44
MPI_SUCCESS
#define MPI_SUCCESS
Definition: dummy_mpi.h:30
tools::mpi::wrmpi::m_max
char * m_max
Definition: wrmpi:512
MPI_FLOAT
#define MPI_FLOAT
Definition: dummy_mpi.h:17
tools::mpi::wrmpi::m_comm
const MPI_Comm & m_comm
Definition: wrmpi:509
TOOLS_MPI_INT64
#define TOOLS_MPI_INT64
Definition: wrmpi:35
MPI_UNSIGNED
#define MPI_UNSIGNED
Definition: dummy_mpi.h:16
TOOLS_MPI_UINT64
#define TOOLS_MPI_UINT64
Definition: wrmpi:34
tools::mpi::wrmpi::m_ipos
int m_ipos
Definition: wrmpi:515
tools::mpi::wait_buffer
bool wait_buffer(std::ostream &a_out, int a_rank, int a_src, int a_tag, const MPI_Comm &a_comm, int &a_buffer_size, char *&a_buffer, int &a_probe_src, bool a_verbose=false)
Definition: wait_buffer:18
tools::diff_pointer_t
unsigned long diff_pointer_t
Definition: typedefs:76
tools::mpi::wrmpi::m_buffer
char * m_buffer
Definition: wrmpi:511
tools::mpi::wrmpi::m_pos
char * m_pos
Definition: wrmpi:513
tools::mpi::wrmpi::pack
virtual bool pack(char a_val)
Definition: wrmpi:51
MPI_UNSIGNED_CHAR
#define MPI_UNSIGNED_CHAR
Definition: dummy_mpi.h:19
MPI_DOUBLE
#define MPI_DOUBLE
Definition: dummy_mpi.h:18
tools::mpi::wrmpi::expand
bool expand(tools::uint32 a_new_size)
Definition: wrmpi:489
tools::mpi::wrmpi::wait_buffer
virtual bool wait_buffer(int a_rank, int a_src, int a_tag, int &a_probe_src, bool a_verbose=false)
Definition: wrmpi:401
tools::mpi::wrmpi::unpack
virtual bool unpack(char &a_val)
Definition: wrmpi:235
MPI_Unpack
int MPI_Unpack(const void *, int, int *, void *, int, MPI_Datatype, MPI_Comm)
Definition: dummy_mpi.h:37
tools::uint32
unsigned int uint32
Definition: typedefs:71
MPI_SHORT
#define MPI_SHORT
Definition: dummy_mpi.h:22