From ba61702fc08684475638f61b674ceb274db7edb2 Mon Sep 17 00:00:00 2001 From: CGH0S7 <776459475@qq.com> Date: Sat, 2 May 2026 10:04:23 +0800 Subject: [PATCH] Checkpoint Z4C CUDA throttling progress --- AMSS_NCKU_source/Parallel.C | 4 ++++ AMSS_NCKU_source/Z4c_class.C | 31 ++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/AMSS_NCKU_source/Parallel.C b/AMSS_NCKU_source/Parallel.C index 7010186..311f4be 100644 --- a/AMSS_NCKU_source/Parallel.C +++ b/AMSS_NCKU_source/Parallel.C @@ -5319,6 +5319,10 @@ int Parallel::data_packer(double *data, MyList *src, MyList

data->Bg) != 0) + { + z4c_cuda_release_step_ctx(dst->data->Bg); + } } else #endif diff --git a/AMSS_NCKU_source/Z4c_class.C b/AMSS_NCKU_source/Z4c_class.C index 897f8fd..57c9772 100644 --- a/AMSS_NCKU_source/Z4c_class.C +++ b/AMSS_NCKU_source/Z4c_class.C @@ -567,6 +567,34 @@ bool z4c_cuda_refresh_constraint_level(MyList *PatL, return all_resident; } +long long &z4c_constraint_output_counter() +{ + static long long counter = 0; + return counter; +} + +int z4c_constraint_output_every() +{ + static int every = -1; + if (every < 0) + { + const char *env = getenv("AMSS_CUDA_Z4C_CONSTRAINT_EVERY"); + every = (env && atoi(env) > 0) ? atoi(env) : 1; + } + return every; +} + +bool z4c_constraint_output_due_now() +{ + const int every = z4c_constraint_output_every(); + return every <= 1 || (z4c_constraint_output_counter() % every) == 0; +} + +void z4c_constraint_output_advance() +{ + z4c_constraint_output_counter()++; +} + } // namespace #endif @@ -586,7 +614,8 @@ void Z4c_class::Step(int lev, int YN) int pre = 0, cor = 1; int ERROR = 0; const double dT_mon = dT * pow(0.5, Mymax(0, trfls)); - const bool need_constraint_after_step = (LastConsOut + dT_mon >= AnasTime); + const bool need_constraint_after_step = + (LastConsOut + dT_mon >= AnasTime) && z4c_constraint_output_due_now(); if (BH_num > 0 && lev == GH->levels - 1) {