From fa645d91c61b766012a92e6f2b0ee4d897eb9eae Mon Sep 17 00:00:00 2001
From: David Immel <d.immel@fz-juelich.de>
Date: Mon, 3 Apr 2023 17:28:23 +0200
Subject: [PATCH] bugfix for work_new_dimension calculation

---
 include/ALL_Histogram.hpp | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/include/ALL_Histogram.hpp b/include/ALL_Histogram.hpp
index 7df4604..903891f 100644
--- a/include/ALL_Histogram.hpp
+++ b/include/ALL_Histogram.hpp
@@ -320,18 +320,13 @@ template <class T, class W> void Histogram_LB<T, W>::balance(int step) {
 
   int current_slice = 0;
 
-  double work_sum = 0.0;
-
   // TODO: compute cumulative function - up to workAvgDimension work in each
   // box
   for (int idx = 0; idx < (int)work_collection.size(); ++idx) {
-    // work_new_dimension.at(current_slice) += work_collection.at(idx);
-    work_sum += work_collection.at(idx);
+    work_new_dimension.at(current_slice) += work_collection.at(idx);
     if (idx < (int)work_collection.size() - 1 &&
-        // work_new_dimension.at(current_slice) + work_collection.at(idx+1)
-        //    > workAvgDimension
-        work_sum + work_collection.at(idx + 1) >
-            (current_slice + 1) * workAvgDimension) {
+        work_new_dimension.at(current_slice) + work_collection.at(idx+1)
+           > workAvgDimension) {
       histogramSlices.at(current_slice) = idx;
       if (current_slice == (this->global_dims.at(i) - 1)) {
         histogramSlices.at(current_slice) = work_collection.size();
-- 
GitLab