diff --git a/include/aare/hist/PedestalTrackingPixelHistogram.hpp b/include/aare/hist/PedestalTrackingPixelHistogram.hpp index 685f3ba..02bb0ce 100644 --- a/include/aare/hist/PedestalTrackingPixelHistogram.hpp +++ b/include/aare/hist/PedestalTrackingPixelHistogram.hpp @@ -101,7 +101,7 @@ class PedestalTrackingPixelHistogram { void update_mean(); NDArray pedestal_mean() const; - void fill_async(NDArray image); + void fill_async(NDArray &&image); void fill_from_file(const std::filesystem::path &fname, ssize_t max_frames = -1, bool verbose = false); @@ -119,9 +119,6 @@ class PedestalTrackingPixelHistogram { // is already drained. void flush() const; - // Number of items either queued or currently being processed. - std::size_t pending() const; - // Implicitly flushes pending async fills first so the snapshot is // consistent with everything that was submitted up to the call. NDArray values() const; diff --git a/include/aare/hist/PixelHistogram.hpp b/include/aare/hist/PixelHistogram.hpp index 15fb4ac..aff9078 100644 --- a/include/aare/hist/PixelHistogram.hpp +++ b/include/aare/hist/PixelHistogram.hpp @@ -79,9 +79,6 @@ class PixelHistogram { // is already drained. void flush() const; - // Number of items either queued or currently being processed. - std::size_t pending() const; - // Implicitly flushes pending async fills first so the snapshot is // consistent with everything that was submitted up to the call. NDArray values() const; diff --git a/python/src/bind_PedestalTrackingPixelHistogram.hpp b/python/src/bind_PedestalTrackingPixelHistogram.hpp index 8e640dd..a9e8a14 100644 --- a/python/src/bind_PedestalTrackingPixelHistogram.hpp +++ b/python/src/bind_PedestalTrackingPixelHistogram.hpp @@ -185,14 +185,6 @@ void define_pedestal_tracking_pixel_histogram_bindings(py::module &m) { )", py::call_guard()) - .def("pending", &PedestalTrackingPixelHistogram::pending, - R"( - Return the number of images either waiting in the queue or - currently being processed by the background thread (i.e. - still in flight after fill_async()). Useful - for monitoring/diagnostics. - )") - .def( "values", [](const PedestalTrackingPixelHistogram &self) { diff --git a/python/src/bind_PixelHistogram.hpp b/python/src/bind_PixelHistogram.hpp index 7c8c7a5..4b24f7f 100644 --- a/python/src/bind_PixelHistogram.hpp +++ b/python/src/bind_PixelHistogram.hpp @@ -67,13 +67,6 @@ void define_pixel_histogram_bindings(py::module &m) { )", py::call_guard()) - .def("pending", &PixelHistogram::pending, - R"( - Return the number of images either waiting in the queue or - currently being processed by the background thread. Useful - for monitoring/diagnostics. - )") - .def( "values", [](const PixelHistogram &self) { diff --git a/src/hist/PedestalTrackingPixelHistogram.cpp b/src/hist/PedestalTrackingPixelHistogram.cpp index b6cf17a..b0f11c9 100644 --- a/src/hist/PedestalTrackingPixelHistogram.cpp +++ b/src/hist/PedestalTrackingPixelHistogram.cpp @@ -216,9 +216,10 @@ void PedestalTrackingPixelHistogram::worker_loop(int thread_id) { // histogram gate lives inside PixelHistogramImpl::fill. auto &my_std = partial_std_[thread_id]; const double n_sigma = n_sigma_.load(std::memory_order_relaxed); + const auto cols = image->shape(1); for (int local_row = 0; local_row < local_rows; ++local_row) { const auto row = static_cast(first_row + local_row); - for (ssize_t col = 0; col < image->shape(1); ++col) { + for (ssize_t col = 0; col < cols; ++col) { const FrameType raw = (*image)(row, col); const AxisType val = static_cast(raw) - static_cast(my_pedestal.mean( @@ -325,7 +326,7 @@ void PedestalTrackingPixelHistogram::fill_with_threshold_( dispatch_(WorkKind::FillWithThreshold, &image); } -void PedestalTrackingPixelHistogram::fill_async(NDArray image) { +void PedestalTrackingPixelHistogram::fill_async(NDArray &&image) { if (image.shape(0) != rows_ || image.shape(1) != cols_) { throw std::invalid_argument( "PedestalTrackingPixelHistogram image shape does not match " @@ -355,14 +356,6 @@ void PedestalTrackingPixelHistogram::flush() const { } } -std::size_t PedestalTrackingPixelHistogram::pending() const { - // sizeGuess() counts the items still in the queue; the coordinator - // does `read()` (which pops) before setting `coordinator_busy_`, so an - // in-flight item lives only in the busy flag. - return async_queue_->sizeGuess() + - (coordinator_busy_.load(std::memory_order_acquire) ? 1u : 0u); -} - void PedestalTrackingPixelHistogram::coordinator_loop() { NDArray item; while (!stop_coordinator_.load(std::memory_order_acquire) || @@ -409,7 +402,7 @@ void PedestalTrackingPixelHistogram::fill_from_file( for (ssize_t i = 0; i < n_frames; ++i) { aare::NDArray frame({rows_, cols_}); f.read_into(reinterpret_cast(frame.data())); - fill_async(frame); + fill_async(std::move(frame)); // print progress if (verbose && diff --git a/src/hist/PixelHistogram.cpp b/src/hist/PixelHistogram.cpp index 2c2e088..5e8baec 100644 --- a/src/hist/PixelHistogram.cpp +++ b/src/hist/PixelHistogram.cpp @@ -120,9 +120,10 @@ void PixelHistogram::worker_loop(int thread_id) { // Do the work: fill this thread's partial histogram. The // [xmin, xmax) range gate lives inside PixelHistogramImpl::fill. auto &my_hist = partial_hists_[thread_id]; + const auto cols = image.shape(1); for (int local_row = 0; local_row < local_rows; ++local_row) { const auto row = static_cast(first_row + local_row); - for (ssize_t col = 0; col < image.shape(1); ++col) { + for (ssize_t col = 0; col < cols; ++col) { const auto val = image(row, col); my_hist.fill_unchecked(local_row, static_cast(col), val); } @@ -218,14 +219,6 @@ void PixelHistogram::flush() const { } } -std::size_t PixelHistogram::pending() const { - // sizeGuess() counts the items still in the queue; the coordinator - // does `read()` (which pops) before setting `coordinator_busy_`, so an - // in-flight item lives only in the busy flag. - return async_queue_->sizeGuess() + - (coordinator_busy_.load(std::memory_order_acquire) ? 1u : 0u); -} - void PixelHistogram::coordinator_loop() { NDArray item; while (!stop_coordinator_.load(std::memory_order_acquire) || diff --git a/src/hist/PixelHistogram.test.cpp b/src/hist/PixelHistogram.test.cpp index ebedec9..135c730 100644 --- a/src/hist/PixelHistogram.test.cpp +++ b/src/hist/PixelHistogram.test.cpp @@ -256,7 +256,6 @@ TEST_CASE("Streamed async fill matches per-frame flushed fill") { } // values() calls flush() internally, but exercise the explicit path too. async_hist.flush(); - CHECK(async_hist.pending() == 0); auto a = async_hist.values(); auto s = sync_hist.values();