/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/data/hdf5_writer.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/data/hdf5_writer.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
hdf5_writer.hh
Go to the documentation of this file.
1#pragma once
2
3// DiFfRG
6
7// standard library
8#include <condition_variable>
9#include <deque>
10#include <exception>
11#include <mutex>
12#include <thread>
13
14namespace DiFfRG
15{
31 {
32 public:
38 explicit HDF5FrameWriter(unsigned int queue_depth);
39 ~HDF5FrameWriter() noexcept;
40
42 HDF5FrameWriter &operator=(const HDF5FrameWriter &) = delete;
43
44 bool asynchronous() const noexcept { return depth > 0; }
45
53 void submit(HDF5Frame frame, FrameTimings *timings = nullptr);
54
56 void drain();
57
59 void finish();
60
63
64 private:
65 void loop();
67
68 const unsigned int depth;
69
70 mutable std::mutex mutex;
71 std::condition_variable producer_condition, consumer_condition;
72 std::deque<HDF5Frame> queue;
73 bool stopping = false;
74 bool writing = false;
75 bool finished = false;
76
77 std::exception_ptr stored_exception;
79
80 std::thread worker;
81 };
82} // namespace DiFfRG
Writes staged HDF5 frames on a single background thread.
Definition hdf5_writer.hh:31
bool stopping
Definition hdf5_writer.hh:73
std::condition_variable producer_condition
Definition hdf5_writer.hh:71
FrameTimings worker_totals() const
void submit(HDF5Frame frame, FrameTimings *timings=nullptr)
Hand a frame over, blocking while the queue is full.
std::deque< HDF5Frame > queue
Definition hdf5_writer.hh:72
const unsigned int depth
Definition hdf5_writer.hh:68
FrameTimings worker_timings
Definition hdf5_writer.hh:78
std::exception_ptr stored_exception
Definition hdf5_writer.hh:77
std::condition_variable consumer_condition
Definition hdf5_writer.hh:71
std::thread worker
Definition hdf5_writer.hh:80
std::mutex mutex
Definition hdf5_writer.hh:70
bool writing
a frame has been popped but not finished
Definition hdf5_writer.hh:74
bool asynchronous() const noexcept
Definition hdf5_writer.hh:44
bool finished
Definition hdf5_writer.hh:75
HDF5FrameWriter(unsigned int queue_depth)
Definition complex_math.hh:10
Wall-clock cost of producing one output frame, split by where the time went.
Definition output_timings.hh:33
Everything one output frame will write to one file, and nothing else.
Definition hdf5_frame.hh:66