gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
VertexBufferNumeric1D_HDF5.hpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
21 
22 #ifndef __VertexBufferNumeric1D_HDF5_hpp__
23 #define __VertexBufferNumeric1D_HDF5_hpp__
24 
25 #include <cstddef>
26 #include <sstream>
27 
28 // HDF5 C bindings
29 #include <hdf5.h>
30 
31 // Gambit
35 #include "gambit/Logs/logger.hpp"
36 
37 // MPI bindings
39 
40 //#define HDF5_BUF_DEBUG /* Triggers debugging output */
41 //#define MONITOR_BUF "pointID" /* String ID of buffer to monitor. */
42 
43 namespace Gambit {
44 
45  namespace Printers {
46 
48  template<class T, std::size_t CHUNKLENGTH>
49  class VertexBufferNumeric1D_HDF5 : public VertexBufferNumeric1D<T,CHUNKLENGTH>
50  {
51  private:
55 
59 
63  std::vector<std::pair<T,PPIDpair>> postpone_write_queue_and_locs;
64 
66  unsigned long nextemptyslab = 0;
67 
72  unsigned long target_sync_pos = 0;
73 
74  public:
77  #ifdef WITH_MPI
79  ( hid_t location_id
80  , const std::string& name
81  , const int vID
82  , const unsigned int i
83  , const bool sync
84  , const bool silence
85  , const bool resume
86  , const BuffTags& tags
87  , const GMPI::Comm& pComm
88  );
89  #endif
90 
91  // No MPI constructor
93  ( hid_t location_id
94  , const std::string& name
95  , const int vID
96  , const unsigned int i
97  , const bool sync
98  , const bool silence
99  , const bool resume
100  , const char access
101  );
102 
106 
109  virtual unsigned long dset_head_pos() { return nextemptyslab + this->get_head_position(); }
110 
111  // Print to std::cout a report on the sync status of this buffer
112  virtual void sync_report();
113 
115  virtual void write_to_disk();
116 
118  virtual void write_external_to_disk(const T (&values)[CHUNKLENGTH], const bool (&isvalid)[CHUNKLENGTH]);
119 
121  virtual void reset(bool force=false);
122 
123  // Finalise writing to underlying output. Do not do any more writing after this!
124  virtual void finalise();
125 
127  virtual void RA_write_to_disk(const std::map<PPIDpair, ulong>& PPID_to_dsetindex);
128 
130  void attempt_postponed_RA_write_to_disk(const std::map<PPIDpair, ulong>& PPID_to_dsetindex);
131 
134  virtual void update_dset_head_pos()
135  {
136  if(this->myRank==0 or not this->MPI_mode()) // Only the master process has access to this information, unless we are in non-MPI mode
137  {
138  if(dsetvalid().get_nextemptyslab() != dsetdata().get_nextemptyslab())
139  {
140  // The two datasets controlled by this buffer should always remain synchronised!
141  std::ostringstream errmsg;
142  errmsg << "rank "<<this->myRank<<": Error! Validity and Data datasets have gone out of sync in buffer with label '"<<this->get_label()<<"'! This is a bug in the VertexBufferNumeric1D_HDF5 class. Please report it.";
143  printer_error().raise(LOCAL_INFO, errmsg.str());
144  }
145  nextemptyslab = dsetvalid().get_nextemptyslab();
146  }
147  }
148 
153 
156  std::size_t postponed_RA_queue_length() { return postpone_write_queue_and_locs.size(); }
157 
158  // Needed for checking that dataset sizes on disk are consistent
160 
161  };
162 
163 
164 
166 
168  template<class T, std::size_t CHUNKLENGTH>
170  : VertexBufferNumeric1D<T,CHUNKLENGTH>()
171  , _dsetvalid()
172  , _dsetdata()
174  {}
175 
176  #ifdef WITH_MPI
177  template<class T, std::size_t CHUNKLENGTH>
179  hid_t location_id
180  , const std::string& name
181  , const int vID
182  , const unsigned int i
183  , const bool sync
184  , const bool silence
185  , const bool resume
186  , const BuffTags& tags
187  , const GMPI::Comm& pComm
188  )
190  name
191  , vID
192  , i
193  , sync
194  , silence
195  , resume
196  , tags
197  , pComm
198  )
199  , _dsetvalid()
200  , _dsetdata()
202  {
203  if(this->MPI_mode() and location_id==-1 and this->myRank==0)
204  {
205  std::ostringstream errmsg;
206  errmsg << "rank "<<this->myRank<<": Error! Tried to create buffer '"<<this->get_label()<<"', but supplied HDF5 location pointer was -1 (and we are the rank 0 process, who needs this pointer)";
207  printer_error().raise(LOCAL_INFO, errmsg.str());
208  }
209  else if(not silence)
210  {
211  if(resume)
212  {
213  logger()<<LogTags::printers<<"Attempting to resume writing to dataset '"<<name<<"_isvalid'...";
214  }
215  else
216  {
217  logger()<<LogTags::printers<<"Creating new dataset '"<<name<<"_isvalid'...";
218  }
219  _dsetvalid = DataSetInterfaceScalar<bool,CHUNKLENGTH>(location_id, name+"_isvalid", resume);
220 
221  if(resume)
222  {
223  logger()<<std::endl<<LogTags::printers<<"Attempting to resume writing to dataset '"<<name<<"'...";
224  }
225  else
226  {
227  logger()<<std::endl<<LogTags::printers<<"Creating new dataset '"<<name<<"'...";
228  }
230 
231  logger()<<EOM; // Leave this to calling function
232  }
233  }
234  #endif
235 
236  // No MPI constructor
237  template<class T, std::size_t CHUNKLENGTH>
239  hid_t location_id
240  , const std::string& name
241  , const int vID
242  , const unsigned int i
243  , const bool sync
244  , const bool silence
245  , const bool resume
246  , char access
247  )
248  : VertexBufferNumeric1D<T,CHUNKLENGTH>(
249  name
250  , vID
251  , i
252  , sync
253  , silence
254  , resume
255  , access
256  )
257  , _dsetvalid()
258  , _dsetdata()
260  {
261  if(this->MPI_mode() and location_id==-1 and this->myRank==0)
262  {
263  std::ostringstream errmsg;
264  errmsg << "rank "<<this->myRank<<": Error! Tried to create buffer '"<<this->get_label()<<"', but supplied HDF5 location pointer was NULL (and we are the rank 0 process, who needs this pointer)";
265  printer_error().raise(LOCAL_INFO, errmsg.str());
266  }
267  else if(not silence)
268  {
269  if(resume)
270  {
271  logger()<<LogTags::printers<<"Attempting to resume writing to dataset '"<<name<<"_isvalid'...";
272  }
273  else
274  {
275  logger()<<LogTags::printers<<"Creating new dataset '"<<name<<"_isvalid'...";
276  }
277  _dsetvalid = DataSetInterfaceScalar<bool,CHUNKLENGTH>(location_id, name+"_isvalid", resume, this->access_mode());
278 
279  if(resume)
280  {
281  logger()<<std::endl<<LogTags::printers<<"Attempting to resume writing to dataset '"<<name<<"'...";
282  }
283  else
284  {
285  logger()<<std::endl<<LogTags::printers<<"Creating new dataset '"<<name<<"'...";
286  }
287  _dsetdata = DataSetInterfaceScalar<T,CHUNKLENGTH>(location_id, name, resume, this->access_mode());
288 
289  logger()<<EOM; // Leave this to calling function
290  }
291  }
292 
294  template<class T, std::size_t L>
296  {
297  //TODO: Do this in some more controlled way
298  //if(this->is_synchronised()) { write_to_disk(); }
299  //else
300  //{
301  // RA_write_to_disk();
302  //}
303  }
304 
305  // Print out report on buffer sync status
306  template<class T, std::size_t L>
308  {
309  std::cout<<"rank "<<this->myRank<<":-----------------------------------------"<<std::endl;
310  std::cout<<"rank "<<this->myRank<<": Begin sync report for buffer "<<this->get_label()<<std::endl;
311  std::cout<<"rank "<<this->myRank<<": Synchronised? = "<<this->is_synchronised()<<std::endl;
312  std::cout<<"rank "<<this->myRank<<": nextemptyslab = "<<nextemptyslab<<std::endl;
313  std::cout<<"rank "<<this->myRank<<": head_position = "<<this->get_head_position()<<std::endl;
314  std::cout<<"rank "<<this->myRank<<": dset_head_pos = "<<this->dset_head_pos()<<std::endl;
315  std::cout<<"rank "<<this->myRank<<": donepoint() = "<<this->donepoint()<<std::endl;
316  std::cout<<"rank "<<this->myRank<<": sync_buffer_full() = "<<this->sync_buffer_full<<std::endl;
317  std::cout<<"rank "<<this->myRank<<": End sync report for buffer "<<this->get_label()<<std::endl;
318  std::cout<<"rank "<<this->myRank<<":-----------------------------------------"<<std::endl;
319 
320  }
321 
323  template<class T, std::size_t L>
325  {
326  #ifdef WITH_MPI
327  if(this->MPI_mode() and this->myRank!=0)
328  {
329  std::ostringstream errmsg;
330  errmsg << "rank "<<this->myRank<<": Error! VertexBuffer (HDF5 type) in non-master process tried to access dsetvalid! This doesn't exist except on the master process (buffer is "<<this->get_label()<<")";
331  printer_error().raise(LOCAL_INFO, errmsg.str());
332  }
333  #endif
334  return _dsetvalid;
335  }
336 
337  template<class T, std::size_t L>
339  {
340  #ifdef WITH_MPI
341  if(this->MPI_mode() and this->myRank!=0)
342  {
343  std::ostringstream errmsg;
344  errmsg << "rank "<<this->myRank<<"Error! VertexBuffer (HDF5 type) in non-master process tried to access dsetdata! This doesn't exist except on the master process (buffer is "<<this->get_label()<<")";
345  printer_error().raise(LOCAL_INFO, errmsg.str());
346  }
347  #endif
348  return _dsetdata;
349  }
351 
353  template<class T, std::size_t L>
355  {
356  if(this->is_synchronised()) {
357  // Check if buffer is empty, and whether we really want to write an
358  // empty buffer to disk.
359  if( not this->sync_buffer_is_empty() or
360  this->dset_head_pos() >= dsetvalid().dset_length()
361  ) // Should only have to check one of the datasets... perhaps add error checking for this.
362  {
364  dsetdata().writenewchunk(this->buffer_entries);
365  // Update the head tracking variables to reflect the new dset chunk
367  }
368  }
369  else {
370  std::ostringstream errmsg;
371  errmsg << "rank "<<this->myRank<<": Error! Tried to write_to_disk() synchronised write buffer of buffer with name "<<this->get_label()<<", but buffer is not flagged as running in synchronised mode! Please report this bug.";
372  printer_error().raise(LOCAL_INFO, errmsg.str());
373  }
374  }
375 
377  template<class T, std::size_t CHUNKLENGTH>
378  void VertexBufferNumeric1D_HDF5<T,CHUNKLENGTH>::write_external_to_disk(const T (&values)[CHUNKLENGTH], const bool (&isvalid)[CHUNKLENGTH])
379  {
380  if(not this->is_silenced()) {
381  dsetvalid().writenewchunk(isvalid);
382  dsetdata().writenewchunk(values);
383  // Update sync information to reflect the presence of the new chunk
385  }
386  }
387 
389  template<class T, std::size_t L>
391  {
392  if(not force and this->is_synchronised())
393  {
394  std::ostringstream errmsg;
395  errmsg << "rank "<<this->myRank<<": Error! Tried to reset() a synchronised buffer! This is forbidden unless force=true. (buffer name = "<<this->get_label()<<")";
396  printer_error().raise(LOCAL_INFO, errmsg.str());
397  }
398 
399  // Clear the sync buffers
400  this->clear();
401 
405 
406  if(this->myRank==0 or not this->MPI_mode()) // Can only touch datasets on master process (unless we are in non-MPI mode)
407  {
410  dsetvalid().zero();
411  //dsetdata().zero(); // Should work fine, but should be unneccesary.
412 
413  // Point the write head (or "cursor") back at the beginning of the output datasets.
415  dsetdata().reset_nextemptyslab();
416  }
417  }
418 
420  template<class T, std::size_t CHUNKLENGTH>
421  void VertexBufferNumeric1D_HDF5<T,CHUNKLENGTH>::attempt_postponed_RA_write_to_disk(const std::map<PPIDpair, ulong>& PPID_to_dsetindex)
422  {
426  bool valid[CHUNKLENGTH];
427  T now_write_queue[CHUNKLENGTH];
428  hsize_t now_abs_write_locations[CHUNKLENGTH];
429  uint now_i=0; // queue_length
430 
432  std::vector<std::pair<T,PPIDpair>> failed;
433 
435  typedef typename std::vector<std::pair<T,PPIDpair>>::iterator it_type;
436  it_type itpp = postpone_write_queue_and_locs.begin();
437  while(itpp != postpone_write_queue_and_locs.end())
438  {
439  T& val = itpp->first;
440  PPIDpair& loc = itpp->second;
441 
442  // Convert loc to abs dataset index (if possible)
443  std::map<PPIDpair, ulong>::const_iterator it
444  = PPID_to_dsetindex.find(loc);
445 
446  if(it==PPID_to_dsetindex.end())
447  {
448  // No PPID found
449  failed.push_back(*itpp);
450  }
451  else
452  {
453  // PPID found; convert to absolute dataset index and add to "now" queue
454  now_write_queue[now_i] = val;
455  now_abs_write_locations[now_i] = it->second;
456  now_i++;
457  }
458 
459  // Increment iterator (need to do this before 'if' statement around RA_write call)
460  ++itpp;
461 
462  // Write "now" buffers to disk, if they aren't empty
463  if(now_i != 0)
464  {
465  if(now_i>CHUNKLENGTH)
466  {
467  std::ostringstream errmsg;
468  errmsg << "rank "<<this->myRank<<": Error! now_i has exceeded CHUNKLENGTH (now_i=="<<now_i<<") during attempt to perform postponed RA_writes. (buffer name = "<<this->get_label()<<")";
469  printer_error().raise(LOCAL_INFO, errmsg.str());
470  }
471 
472  // Do the write only if buffer is full or postpone queue is finished and we
473  // are about to finish looping.
474  if(now_i==CHUNKLENGTH or itpp == postpone_write_queue_and_locs.end())
475  {
476  std::fill(valid, valid+CHUNKLENGTH, false);
477  std::fill(valid, valid+now_i, true);
478  dsetvalid().RA_write(valid, now_abs_write_locations, now_i);
479  dsetdata().RA_write (now_write_queue, now_abs_write_locations, now_i);
480  //std::cout<<"Wrote "<<now_i<<" postponed RA items to disk"<<std::endl;
481  now_i = 0; // Reset buffer
482  }
483  }
484  }
485  // put failed write attempts back into the postpone queue
487  }
488 
489 
491  template<class T, std::size_t CHUNKLENGTH>
492  void VertexBufferNumeric1D_HDF5<T,CHUNKLENGTH>::RA_write_to_disk(const std::map<PPIDpair, ulong>& PPID_to_dsetindex)
493  {
494  if(this->is_synchronised())
495  {
496  std::ostringstream errmsg;
497  errmsg << "rank "<<this->myRank<<": Error! Non-synchronised buffer attempted to perform RA_write_to_disk! Only non-synchronised buffers are permitted to do this. (buffer name = "<<this->get_label()<<")";
498  printer_error().raise(LOCAL_INFO, errmsg.str());
499  }
500 
501  if(not this->is_silenced())
502  {
504  dsetdata().extend_dset(target_sync_pos);
505 
506  #ifdef DEBUG_MODE
507  std::cout<<"rank "<<this->myRank<<": Extended RA dset '"<<this->get_label()<<"' to at least size "<<target_sync_pos<<std::endl;
508  #endif
509 
510  if (this->RA_queue_length!=0 or postpone_write_queue_and_locs.size()!=0)
511  {
512  #ifdef DEBUG_MODE
513  std::cout<<"rank "<<this->myRank<<": Doing RA_write_to_disk for buffer '"<<this->get_label()<<"' (note: target_sync_pos="<<target_sync_pos<<", dset_head_pos()="<<this->dset_head_pos()<<")"<<std::endl;
514  #endif
515 
516  // Attempt to write any existing postponed RA write attempts to disk (again)
517  attempt_postponed_RA_write_to_disk(PPID_to_dsetindex);
518 
519  //std::cout<<"rank "<<this->myRank<<": Number of items remaining in postpone queue after write attempt = "<<postpone_write_queue_and_locs.size()<<"); buffer is '"<<this->get_label()<<"'"<<std::endl;
520 
524  bool valid[CHUNKLENGTH];
525  T now_write_queue[CHUNKLENGTH];
526  hsize_t now_abs_write_locations[CHUNKLENGTH];
527  uint now_i=0; // queue_length
528 
529  // Now go through the current RA_queue and try to write them to disk
530  for(ulong i=0; i<this->RA_queue_length; i++)
531  {
532  // Some write locations may not be known yet due to the original
533  // data not yet having been written to disk from its sync buffer.
534  // We will have to postpone writing these until the next RA_write
535  // attempt.
536  std::map<PPIDpair, ulong>::const_iterator it
537  = PPID_to_dsetindex.find(this->RA_write_locations[i]);
538  if(it==PPID_to_dsetindex.end())
539  {
540  // No PPID found; add to "postpone" queue
542  std::make_pair(this->RA_write_queue[i],
543  this->RA_write_locations[i])
544  );
545  }
546  else
547  {
548  // PPID found; convert to absolute dataset index and add to "now" queue
549  now_write_queue[now_i] = this->RA_write_queue[i];
550  now_abs_write_locations[now_i] = it->second;
551  now_i++;
552  }
553  }
554 
555  // Write "now" buffers to disk, if they aren't empty
556  if(now_i != 0)
557  {
558  if(now_i>CHUNKLENGTH)
559  {
560  std::ostringstream errmsg;
561  errmsg << "rank "<<this->myRank<<": Error! now_i has exceeded CHUNKLENGTH (now_i=="<<now_i<<"). (buffer name = "<<this->get_label()<<")";
562  printer_error().raise(LOCAL_INFO, errmsg.str());
563  }
564  std::fill(valid, valid+CHUNKLENGTH, false);
565  std::fill(valid, valid+now_i, true);
566  #ifdef DEBUG_MODE
567  std::cout<<"rank "<<this->myRank<<": writing buffer for "<<this->get_label()<<" to disk; now_i="<<now_i<<std::endl;
568  #endif
569  dsetvalid().RA_write(valid, now_abs_write_locations, now_i);
570  dsetdata().RA_write (now_write_queue, now_abs_write_locations, now_i);
571  }
572 
573  }
574  }
575  }
576 
584  template<class T, std::size_t L>
586  {
587  if(not this->is_silenced())
588  {
589  // Make sure the correct dset_head_pos() is known
591 
592  // Update the variable which tracks the current sync position.
593  // (do this regardless of whether this is a sync buffer or not)
594  target_sync_pos = sync_pos;
595 
596  #ifdef HDF5_BUF_DEBUG
597  std::cout<<"rank "<<this->myRank<<": Updated target_sync_pos to '"<<target_sync_pos<<" in buffer "<<this->get_label()<<std::endl;
598  #endif
599 
600  if(this->is_synchronised())
601  {
602  #ifdef HDF5_BUF_DEBUG
603  #ifdef MONITOR_BUF
604  if(this->get_label()==MONITOR_BUF) {
605  #endif
606  std::cout<<"rank "<<this->myRank<<": Synchronising buffer '"<<this->get_label()<<"' to position "<<sync_pos<<" (current dset_head_pos() = "<<this->dset_head_pos()<<")"<<std::endl;
607  #ifdef MONITOR_BUF
608  }
609  #endif
610  #endif
611 
612  // Compare target position to current sync position and see what we need to do
613  // The plus one is because the head_pos should be one larger than the sync_pos
614  // for buffers who already did an append to the sync_pos; these buffers therefore
615  // do not need to move.
616  //
617  const long movediff = sync_pos+1 - this->dset_head_pos();
618  if(movediff==1)
619  {
620  // Set the current point as having no valid data and move to the next
621  this->skip_append();
622  }
623  else if(movediff<0)
624  {
625  std::ostringstream errmsg;
626  errmsg << "rank "<<this->myRank<<": Error! Attempted to move HDF5 write position backwards in buffer with label '"<<this->get_label()<<"'! (movediff ("<<movediff<<") = sync_pos ("<<sync_pos<<")+1 - dset_head_pos() ("<<this->dset_head_pos()<<")) This is a bug in the VertexBufferNumeric1D_HDF5 class or in a class which uses it (probably HDF5Printer). Please report it. (Note, writing to old points can be done but requires using special write functions).";
627  printer_error().raise(LOCAL_INFO, errmsg.str());
628  }
629  else if (movediff==0)
630  {
631  if(this->donepoint())
632  {
633  std::ostringstream errmsg;
634  errmsg << "rank "<<this->myRank<<": Error! Attempted to move HDF5 write position by 0 slots in buffer with label '"<<this->get_label()<<"' (movediff ("<<movediff<<") = sync_pos ("<<sync_pos<<")+1 - dset_head_pos ("<<this->dset_head_pos()<<")); this part is fine, however the buffer indicates that this position has already received a write (donepoint()==true) so it should have moved forward! This is a bug in the VertexBufferNumeric1D_HDF5 class or in a class which uses it (probably HDF5Printer). Please report it.";
635  printer_error().raise(LOCAL_INFO, errmsg.str());
636  }
637  // otherwise no problem; carry on.
638  }
639  else if (movediff>1) // and movediff!=CHUNKLENGTH+1)
640  {
641  std::ostringstream errmsg;
642  errmsg << "rank "<<this->myRank<<": Error! Attempted to move HDF5 write position by >1 slots ("<<movediff<<") in buffer with label '"<<this->get_label()<<"' (movediff ("<<movediff<<") = sync_pos ("<<sync_pos<<")+1 - dset_head_pos() ("<<this->dset_head_pos()<<")). Buffer synchronisation should only happen one slot at a time. This is a bug in the VertexBufferNumeric1D_HDF5 class or in a class which uses it (probably HDF5Printer). Please report it.";
643  printer_error().raise(LOCAL_INFO, errmsg.str());
644  }
645 
646  #ifdef HDF5_BUF_DEBUG
647  #ifdef MONITOR_BUF
648  if(this->get_label()==MONITOR_BUF) {
649  #endif
650  long slots_left = L;
651  slots_left -= this->get_head_position() - this->donepoint();
652  std::cout<<"rank "<<this->myRank<<": Moved "<<movediff<<" slot(s). # unwritten slots left in buffer = "<<slots_left<<". buffer_is_full = "<<this->sync_buffer_is_full()<<std::endl;
653  std::cout<<"rank "<<this->myRank<<": Buffer length:"<<L<<std::endl;
654  std::cout<<"rank "<<this->myRank<<": head_position:"<<this->get_head_position()<<std::endl;
655  std::cout<<"rank "<<this->myRank<<": donepoint() :"<<this->donepoint()<<std::endl;
656 
657  #ifdef MONITOR_BUF
658  }
659  #endif
660  #endif
661  }
662  }
663  }
664 
665  template<class T, std::size_t L>
667  {
669  {
670  std::ostringstream errmsg;
671  errmsg << "rank "<<this->myRank<<": Error! Lengths of 'data' and 'valid' datasets for buffer "<<this->get_label()<<" are different ("<<dsetdata().dset_length()<<" and "<<dsetvalid().dset_length()<<" respectively). This should never happen.";
672  printer_error().raise(LOCAL_INFO, errmsg.str());
673  }
674  return dsetdata().dset_length();
675  }
676 
677  // Finalise writing to underlying output. Do not do any more writing after this!
678  template<class T, std::size_t L>
680  {
681  dsetdata().closeDataSet();
683  }
685  }
686 }
687 
688 #endif
689 
void extend_dset(const unsigned long i)
Extend dataset to nearest multiple of CHUNKLENGTH above supplied length.
bool resume
flag to indicate that GAMBIT is attempting to resume a run, so we need to hook into existing output s...
EXPORT_SYMBOLS error & printer_error()
Printer errors.
void closeDataSet()
Close an open dataset.
bool buffer_valid[LENGTH]
Buffer variables for sequential writing.
std::vector< std::pair< T, PPIDpair > > postpone_write_queue_and_locs
Extendible backup buffers for RA writes that need to be postponed due to the original sync writes not...
virtual void RA_write_to_disk(const std::map< PPIDpair, ulong > &PPID_to_dsetindex)
Send random access write queue to dataset interfaces for writing.
DataSetInterfaceScalar< bool, CHUNKLENGTH > & dsetvalid()
Getters for HDF5 dataset interfaces (extra error checking)
#define LOCAL_INFO
Definition: local_info.hpp:34
Logging access header for GAMBIT.
unsigned long target_sync_pos
Variable obtained from somewhere external to the buffer, used to track the synchronisation position w...
DataSetInterfaceScalar< bool, CHUNKLENGTH > _dsetvalid
Interfaces to HDF5 datasets.
Declaration of VertexBufferNumeric1D class This version of VertexBufferBase adds a series of routines...
unsigned long nextemptyslab
Dimension-0 index of the next empty hyperslab in the output datasets.
VertexBuffer for simple numerical types.
virtual void write_to_disk()
Write sync buffer to HDF5 dataset.
virtual unsigned long dset_head_pos()
(virtual for debugging purposes) Current absolute "write head" position for synchronised buffers ...
virtual void update_dset_head_pos()
Update the variables needed to tracks the currently target dset slot (really just updates the nextemp...
virtual void write_external_to_disk(const T(&values)[CHUNKLENGTH], const bool(&isvalid)[CHUNKLENGTH])
Write externally-supplied buffer to HDF5 dataset.
void synchronise_output_to_position(const ulong i)
Ensure dataset "write head" (i.e.
void attempt_postponed_RA_write_to_disk(const std::map< PPIDpair, ulong > &PPID_to_dsetindex)
Attempt to write any postponed RA_write attempts to disk.
virtual void reset(bool force=false)
Reset the output (non-synchronised datasets only, unless force=true)
PPIDpair RA_write_locations[LENGTH]
Target pointIDs for RA writes.
const Logging::endofmessage EOM
Explicit const instance of the end of message struct in Gambit namespace.
Definition: logger.hpp:99
uint RA_queue_length
Current length of the RA write queue.
Struct for a collection of MPI tags belonging to a single buffer.
Logging::LogMaster & logger()
Function to retrieve a reference to the Gambit global log object.
Definition: logger.cpp:95
VertexBuffer for simple numerical types - derived version that handles output to hdf5.
char access
flag to indicate the buffer access mode (i.e. read/write)
DataSetInterfaceScalar< T, CHUNKLENGTH > & dsetdata()
void RA_write(const T(&values)[CHUNKLENGTH], const hsize_t(&coords)[CHUNKLENGTH], std::size_t npoints)
Perform desynchronised ("random access") dataset writes to previous scan iterations from a queue...
void zero()
Set all elements of the dataset to zero.
unsigned long int ulong
A simple C++ wrapper for the MPI C bindings.
void writenewchunk(const T(&chunkdata)[CHUNKLENGTH])
Write data to a new chunk in the hosted dataset.
Declaration for class DataSetInterfaceScalar.
Exception objects required for standalone compilation.
std::size_t postponed_RA_queue_length()
Check how many RA writes are waiting in the postpone queue (mostly for debugging purposes) ...
bool sync_buffer_full
flag to indicate if the sync buffer is full (and ready for sending/dumping)
~VertexBufferNumeric1D_HDF5()
Destructor Make sure buffer contents are written to file when buffer object is destroyed.
virtual void skip_append()
No data to append this iteration; skip this slot.
pointID / process number pair Used to identify a single parameter space point
TODO: see if we can use this one:
Definition: Analysis.hpp:33
char access_mode() const
Buffer status getters.
DataSetInterfaceScalar< T, CHUNKLENGTH > _dsetdata