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

This commit is contained in:
2026-03-03 15:15:06 +08:00
parent 234c4f7344
commit 51efc47c1b

View File

@@ -36,12 +36,18 @@ using namespace std;
#include "myglobal.h" #include "myglobal.h"
#endif #endif
#include "perf.h" #include "perf.h"
#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
*/ */
perf bssn_perf; #if BSSN_ENABLE_MEM_USAGE_LOG
size_t current_min, current_avg, current_max, peak_min, peak_avg, peak_max; 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++) for (int lev = 0; lev < GH->levels; lev++)
GH->Lt[lev] = PhysTime; GH->Lt[lev] = PhysTime;
@@ -2224,21 +2232,23 @@ 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
// Retrieve memory usage information used during computation; master process prints it #if BSSN_ENABLE_MEM_USAGE_LOG
bssn_perf.MemoryUsage(&current_min, &current_avg, &current_max, // Retrieve memory usage information used during computation; master process prints it
&peak_min, &peak_avg, &peak_max, nprocs); bssn_perf.MemoryUsage(&current_min, &current_avg, &current_max,
if (myrank == 0) &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", printf(" Memory usage: current %0.4lg/%0.4lg/%0.4lgMB, "
(double)current_min / (1024.0 * 1024.0), "peak %0.4lg/%0.4lg/%0.4lgMB\n",
(double)current_avg / (1024.0 * 1024.0), (double)current_min / (1024.0 * 1024.0),
(double)current_max / (1024.0 * 1024.0), (double)current_avg / (1024.0 * 1024.0),
(double)peak_min / (1024.0 * 1024.0), (double)current_max / (1024.0 * 1024.0),
(double)peak_avg / (1024.0 * 1024.0), (double)peak_min / (1024.0 * 1024.0),
(double)peak_max / (1024.0 * 1024.0)); (double)peak_avg / (1024.0 * 1024.0),
cout << endl; (double)peak_max / (1024.0 * 1024.0));
} cout << endl;
}
#endif
// Output puncture positions at each step // Output puncture positions at each step
if (myrank == 0) if (myrank == 0)