From b35e1b289f8b4197cf553b0e1850beeb69590a3d Mon Sep 17 00:00:00 2001 From: CGH0S7 <776459475@qq.com> Date: Tue, 3 Mar 2026 15:15:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=BC=80=E5=85=B3=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E5=86=85=E5=AD=98=E6=89=93=E5=8D=B0=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AMSS_NCKU_source/bssn_class.C | 56 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/AMSS_NCKU_source/bssn_class.C b/AMSS_NCKU_source/bssn_class.C index 432747e..bcd9117 100644 --- a/AMSS_NCKU_source/bssn_class.C +++ b/AMSS_NCKU_source/bssn_class.C @@ -36,12 +36,18 @@ using namespace std; #include "myglobal.h" #endif -#include "perf.h" - -#include "derivatives.h" -#include "ricci_gamma.h" - -//================================================================================================ +#include "perf.h" + +#include "derivatives.h" +#include "ricci_gamma.h" + +// Compile-time switch for per-timestep memory usage collection/printing. +// Default is OFF to reduce overhead in production runs. +#ifndef BSSN_ENABLE_MEM_USAGE_LOG +#define BSSN_ENABLE_MEM_USAGE_LOG 0 +#endif + +//================================================================================================ // define bssn_class @@ -2129,8 +2135,10 @@ void bssn_class::Evolve(int Steps) #endif */ - perf bssn_perf; - size_t current_min, current_avg, current_max, peak_min, peak_avg, peak_max; +#if BSSN_ENABLE_MEM_USAGE_LOG + perf bssn_perf; + size_t current_min, current_avg, current_max, peak_min, peak_avg, peak_max; +#endif for (int lev = 0; lev < GH->levels; lev++) GH->Lt[lev] = PhysTime; @@ -2224,21 +2232,23 @@ void bssn_class::Evolve(int Steps) // fgt(PhysTime-dT_mon,StartTime,dT_mon/2),ErrorMonitor); #endif - // Retrieve memory usage information used during computation; master process prints it - bssn_perf.MemoryUsage(¤t_min, ¤t_avg, ¤t_max, - &peak_min, &peak_avg, &peak_max, nprocs); - if (myrank == 0) - { - printf(" Memory usage: current %0.4lg/%0.4lg/%0.4lgMB, " - "peak %0.4lg/%0.4lg/%0.4lgMB\n", - (double)current_min / (1024.0 * 1024.0), - (double)current_avg / (1024.0 * 1024.0), - (double)current_max / (1024.0 * 1024.0), - (double)peak_min / (1024.0 * 1024.0), - (double)peak_avg / (1024.0 * 1024.0), - (double)peak_max / (1024.0 * 1024.0)); - cout << endl; - } +#if BSSN_ENABLE_MEM_USAGE_LOG + // Retrieve memory usage information used during computation; master process prints it + bssn_perf.MemoryUsage(¤t_min, ¤t_avg, ¤t_max, + &peak_min, &peak_avg, &peak_max, nprocs); + if (myrank == 0) + { + printf(" Memory usage: current %0.4lg/%0.4lg/%0.4lgMB, " + "peak %0.4lg/%0.4lg/%0.4lgMB\n", + (double)current_min / (1024.0 * 1024.0), + (double)current_avg / (1024.0 * 1024.0), + (double)current_max / (1024.0 * 1024.0), + (double)peak_min / (1024.0 * 1024.0), + (double)peak_avg / (1024.0 * 1024.0), + (double)peak_max / (1024.0 * 1024.0)); + cout << endl; + } +#endif // Output puncture positions at each step if (myrank == 0)