Checkpoint Z4C CUDA throttling progress

This commit is contained in:
2026-05-02 10:04:23 +08:00
parent fcd98649f6
commit ba61702fc0
2 changed files with 34 additions and 1 deletions

View File

@@ -5319,6 +5319,10 @@ int Parallel::data_packer(double *data, MyList<Parallel::gridseg> *src, MyList<P
MPI_Abort(MPI_COMM_WORLD, 1);
}
}
else if (z4c_cuda_has_resident_state(dst->data->Bg) != 0)
{
z4c_cuda_release_step_ctx(dst->data->Bg);
}
}
else
#endif

View File

@@ -567,6 +567,34 @@ bool z4c_cuda_refresh_constraint_level(MyList<Patch> *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)
{