设置开关关闭内存打印统计

This commit is contained in:
2026-03-03 15:15:06 +08:00
parent 05851b2c59
commit b35e1b289f

View File

@@ -41,6 +41,12 @@ using namespace std;
#include "derivatives.h" #include "derivatives.h"
#include "ricci_gamma.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 // define bssn_class
@@ -2129,8 +2135,10 @@ void bssn_class::Evolve(int Steps)
#endif #endif
*/ */
#if BSSN_ENABLE_MEM_USAGE_LOG
perf bssn_perf; perf bssn_perf;
size_t current_min, current_avg, current_max, peak_min, peak_avg, peak_max; size_t current_min, current_avg, current_max, peak_min, peak_avg, peak_max;
#endif
for (int lev = 0; lev < GH->levels; lev++) for (int lev = 0; lev < GH->levels; lev++)
GH->Lt[lev] = PhysTime; GH->Lt[lev] = PhysTime;
@@ -2224,6 +2232,7 @@ void bssn_class::Evolve(int Steps)
// fgt(PhysTime-dT_mon,StartTime,dT_mon/2),ErrorMonitor); // fgt(PhysTime-dT_mon,StartTime,dT_mon/2),ErrorMonitor);
#endif #endif
#if BSSN_ENABLE_MEM_USAGE_LOG
// Retrieve memory usage information used during computation; master process prints it // Retrieve memory usage information used during computation; master process prints it
bssn_perf.MemoryUsage(&current_min, &current_avg, &current_max, bssn_perf.MemoryUsage(&current_min, &current_avg, &current_max,
&peak_min, &peak_avg, &peak_max, nprocs); &peak_min, &peak_avg, &peak_max, nprocs);
@@ -2239,6 +2248,7 @@ void bssn_class::Evolve(int Steps)
(double)peak_max / (1024.0 * 1024.0)); (double)peak_max / (1024.0 * 1024.0));
cout << endl; cout << endl;
} }
#endif
// Output puncture positions at each step // Output puncture positions at each step
if (myrank == 0) if (myrank == 0)