From 31f9598bf31cfb7d463eb2189e81596a252b4fc5 Mon Sep 17 00:00:00 2001 From: pordyna Date: Fri, 15 Mar 2024 05:32:08 -0700 Subject: [PATCH 1/2] fix unfreed host buffer and missing iteration and series close in ParticleHistogram2D --- Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp b/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp index 473a53715e6..02859928269 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp @@ -138,6 +138,7 @@ void ParticleHistogram2D::ComputeDiags (int step) Array tlo{0,0}; // lower bounds Array thi{m_bin_num_abs-1, m_bin_num_ord-1}; // inclusive upper bounds amrex::TableData d_data_2D(tlo, thi); + m_h_data_2D.clear(); m_h_data_2D = amrex::TableData (tlo, thi, The_Pinned_Arena()); auto const& h_table_data = m_h_data_2D.table(); @@ -314,6 +315,8 @@ void ParticleHistogram2D::WriteToFile (int step) const {static_cast(m_bin_num_ord), static_cast(m_bin_num_abs)}); series.flush(); + i.close(); + series.close(); #else amrex::ignore_unused(step); WARPX_ABORT_WITH_MESSAGE("ParticleHistogram2D: Needs openPMD-api compiled into WarpX, but was not found!"); From a55d358f680b724a7c0ee7f0970e730ba2364107 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Thu, 21 Mar 2024 06:41:16 -0700 Subject: [PATCH 2/2] More efficient resize Co-authored-by: Weiqun Zhang --- Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp b/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp index 02859928269..b3a42745cb0 100644 --- a/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp +++ b/Source/Diagnostics/ReducedDiags/ParticleHistogram2D.cpp @@ -138,8 +138,7 @@ void ParticleHistogram2D::ComputeDiags (int step) Array tlo{0,0}; // lower bounds Array thi{m_bin_num_abs-1, m_bin_num_ord-1}; // inclusive upper bounds amrex::TableData d_data_2D(tlo, thi); - m_h_data_2D.clear(); - m_h_data_2D = amrex::TableData (tlo, thi, The_Pinned_Arena()); + m_h_data_2D.resize(tlo, thi, The_Pinned_Arena()); auto const& h_table_data = m_h_data_2D.table(); // Initialize data on the host