From 9e7625cd5d436ba7f8335aafbd1a379e1f7f1df8 Mon Sep 17 00:00:00 2001 From: Jun Zhu Date: Tue, 26 Sep 2023 14:38:28 +0200 Subject: [PATCH 1/3] Fix error in debug build --- recon/src/daq/std_daq_client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recon/src/daq/std_daq_client.cpp b/recon/src/daq/std_daq_client.cpp index ff468d5b..4c6a485f 100644 --- a/recon/src/daq/std_daq_client.cpp +++ b/recon/src/daq/std_daq_client.cpp @@ -35,7 +35,7 @@ StdDaqClient::parseData(const nlohmann::json& meta, const zmq::message_t& data) size_t num_cols = meta["shape"][1]; if (!isDataShapeValid(num_rows, num_cols)) return std::nullopt; - assert(update.size() == sizeof(RawDtype) * n_rows * n_cols); + assert(data.size() == sizeof(RawDtype) * num_rows * num_cols); return Projection<>{proj_type, frame, num_cols, num_rows, data.data(), data.size()}; } From d0d063314383240cedc5bd629f4dad4480724cdf Mon Sep 17 00:00:00 2001 From: Jun Zhu Date: Tue, 26 Sep 2023 15:36:55 +0200 Subject: [PATCH 2/3] Fix race condition in DaqBuffer --- recon/include/recon/daq/daq_buffer.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/recon/include/recon/daq/daq_buffer.hpp b/recon/include/recon/daq/daq_buffer.hpp index 2480248c..381234fd 100644 --- a/recon/include/recon/daq/daq_buffer.hpp +++ b/recon/include/recon/daq/daq_buffer.hpp @@ -9,6 +9,7 @@ #ifndef RECON_DAQBUFFER_H #define RECON_DAQBUFFER_H +#include #include #include #include @@ -31,7 +32,7 @@ class DaqBuffer { }; size_t max_len_; - size_t len_ {0}; + std::atomic len_ {0}; mutable std::mutex head_mtx_; std::unique_ptr head_; @@ -49,7 +50,7 @@ class DaqBuffer { std::unique_ptr popHead() { std::unique_ptr old_head = std::move(head_); head_ = std::move(old_head->next); - --len_; + len_--; return old_head; } @@ -80,7 +81,7 @@ class DaqBuffer { Item* const new_tail = new_item.get(); tail_->next = std::move(new_item); tail_ = new_tail; - ++len_; + len_++; } cv_.notify_one(); return true; @@ -93,7 +94,8 @@ class DaqBuffer { bool waitAndPop(T& value) { std::unique_lock lk(head_mtx_); - if (cv_.wait_for(lk, std::chrono::milliseconds(100), [&] { return head_.get() != tail(); })) { + if (cv_.wait_for(lk, std::chrono::milliseconds(100), + [&] { return head_.get() != tail(); })) { value = std::move(head_->data); popHead(); return true; From 44382215cdf4d6b94c6a33943e620339e04bd408 Mon Sep 17 00:00:00 2001 From: Jun Zhu Date: Tue, 26 Sep 2023 15:52:18 +0200 Subject: [PATCH 3/3] Improve messages --- recon/include/recon/daq/zmq_daq_client.hpp | 2 +- recon/src/monitor.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/recon/include/recon/daq/zmq_daq_client.hpp b/recon/include/recon/daq/zmq_daq_client.hpp index 4090d2a3..10665c98 100644 --- a/recon/include/recon/daq/zmq_daq_client.hpp +++ b/recon/include/recon/daq/zmq_daq_client.hpp @@ -38,7 +38,7 @@ class ZmqDaqClient : public DaqClientInterface { public: static constexpr size_t K_BUFFER_SIZE = 1000; - static constexpr size_t K_MONITOR_EVERY = 100; + static constexpr size_t K_MONITOR_EVERY = 1000; protected: diff --git a/recon/src/monitor.cpp b/recon/src/monitor.cpp index 98bb1534..538250c5 100644 --- a/recon/src/monitor.cpp +++ b/recon/src/monitor.cpp @@ -49,6 +49,11 @@ void Monitor::countFlat() { void Monitor::countTomogram() { ++num_tomograms_; +#if (VERBOSITY >= 1) + spdlog::info("{} tomograms reconstructed", num_tomograms_); +#endif + +#if (VERBOSITY >= 2) if (num_tomograms_ % report_tomo_throughput_every_ == 0) { // The number for the first tomograms // underestimates the throughput! @@ -57,11 +62,11 @@ void Monitor::countTomogram() { end - tomo_start_).count(); double throughput = scan_byte_size_ * report_tomo_throughput_every_ / dt; double throughput_per_tomo = 1000000. * report_tomo_throughput_every_ / dt; - spdlog::info("{} tomograms reconstructed", num_tomograms_); - spdlog::info("[Bench] Throughput (averaged over the last {} tomograms): {:.1f} (MB/s) / {:.1f} (tomo/s)", + spdlog::info("Throughput (averaged over the last {} tomograms): {:.1f} (MB/s) / {:.1f} (tomo/s)", report_tomo_throughput_every_, throughput, throughput_per_tomo); tomo_start_ = end; } +#endif } void Monitor::summarize() const {