Lines Matching refs:tjsch
342 TJScheduler *tjsch = (TJScheduler *)tj->data; in StackDumpAll() local
354 PetscCall(PetscViewerFileSetName(tjsch->viewer, filename)); in StackDumpAll()
355 PetscCall(PetscViewerSetUp(tjsch->viewer)); in StackDumpAll()
357 PetscCall(PetscViewerBinaryWrite(tjsch->viewer, &ndumped, 1, PETSC_INT)); in StackDumpAll()
361 PetscCall(PetscViewerBinaryWrite(tjsch->viewer, &cptype_int, 1, PETSC_INT)); in StackDumpAll()
363 …flyaccurate, e->stepnum, e->time, e->timeprev, e->X, e->Y, stack->numY, e->cptype, tjsch->viewer)); in StackDumpAll()
371 …s->steps, ts->ptime, ts->ptime_prev, ts->vec_sol, Y, stack->numY, SOLUTION_STAGES, tjsch->viewer)); in StackDumpAll()
471 TJScheduler *tjsch = (TJScheduler *)tj->data; in DumpSingle() local
484 PetscCall(PetscViewerFileSetName(tjsch->viewer, filename)); in DumpSingle()
485 PetscCall(PetscViewerSetUp(tjsch->viewer)); in DumpSingle()
489 … stepnum, ts->ptime, ts->ptime_prev, ts->vec_sol, Y, stack->numY, SOLUTION_STAGES, tjsch->viewer)); in DumpSingle()
547 static PetscErrorCode ReCompute(TS ts, TJScheduler *tjsch, PetscInt stepnumbegin, PetscInt stepnume… in ReCompute() argument
549 Stack *stack = &tjsch->stack; in ReCompute()
553 …tjsch->recompute = PETSC_TRUE; /* hints TSTrajectorySet() that it is in … in ReCompute()
556 if (stack->solution_only && !tjsch->skip_trajectory) { /* revolve online need this */ in ReCompute()
562 if (!stack->solution_only && !tjsch->skip_trajectory) { in ReCompute()
572 tjsch->recompute = PETSC_FALSE; /* reset the flag for recompute mode */ in ReCompute()
576 static PetscErrorCode TopLevelStore(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscInt stepnum, P… in TopLevelStore() argument
578 Stack *stack = &tjsch->stack; in TopLevelStore()
579 DiskStack *diskstack = &tjsch->diskstack; in TopLevelStore()
584 stridenum = stepnum / tjsch->stride; in TopLevelStore()
589 if (tjsch->save_stack) { in TopLevelStore()
590 …if (localstepnum == tjsch->stride - 1 && stepnum < tjsch->total_steps - laststridesize) { /* curre… in TopLevelStore()
592 … if (tjsch->stype == TWO_LEVEL_TWO_REVOLVE) diskstack->container[++diskstack->top] = stridenum + 1; in TopLevelStore()
596 if (localstepnum == 0 && stepnum < tjsch->total_steps - laststridesize) { in TopLevelStore()
598 … if (tjsch->stype == TWO_LEVEL_TWO_REVOLVE) diskstack->container[++diskstack->top] = stridenum + 1; in TopLevelStore()
603 if (tjsch->save_stack) { in TopLevelStore()
604 …if (localstepnum == 0 && stepnum < tjsch->total_steps && stepnum != 0) { /* skip the first stride … in TopLevelStore()
606 … if (tjsch->stype == TWO_LEVEL_TWO_REVOLVE) diskstack->container[++diskstack->top] = stridenum; in TopLevelStore()
610 if (localstepnum == 1 && stepnum < tjsch->total_steps - laststridesize) { in TopLevelStore()
612 … if (tjsch->stype == TWO_LEVEL_TWO_REVOLVE) diskstack->container[++diskstack->top] = stridenum + 1; in TopLevelStore()
620 static PetscErrorCode TSTrajectoryMemorySet_N(TS ts, TJScheduler *tjsch, PetscInt stepnum, PetscRea… in TSTrajectoryMemorySet_N() argument
622 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_N()
630 if (stepnum != tjsch->total_steps) tjsch->total_steps = stepnum; in TSTrajectoryMemorySet_N()
638 if (stack->solution_only && tjsch->recompute) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_N()
657 static PetscErrorCode TSTrajectoryMemorySet_N_2(TS ts, TJScheduler *tjsch, PetscInt stepnum, PetscR… in TSTrajectoryMemorySet_N_2() argument
659 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_N_2()
678 static PetscErrorCode TSTrajectoryMemoryGet_N(TS ts, TJScheduler *tjsch, PetscInt stepnum) in TSTrajectoryMemoryGet_N() argument
680 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_N()
687 if (stepnum == tjsch->total_steps) { in TSTrajectoryMemoryGet_N()
697 PetscCall(ReCompute(ts, tjsch, e->stepnum, stepnum)); in TSTrajectoryMemoryGet_N()
703 static PetscErrorCode TSTrajectoryMemoryGet_N_2(TS ts, TJScheduler *tjsch, PetscInt stepnum) in TSTrajectoryMemoryGet_N_2() argument
705 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_N_2()
715 static PetscErrorCode TSTrajectoryMemorySet_TLNR(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscI… in TSTrajectoryMemorySet_TLNR() argument
717 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_TLNR()
725 if (stack->solution_only && stepnum == tjsch->total_steps) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_TLNR()
726 if (tjsch->save_stack && tjsch->recompute) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_TLNR()
728 localstepnum = stepnum % tjsch->stride; in TSTrajectoryMemorySet_TLNR()
730 laststridesize = tjsch->total_steps % tjsch->stride; in TSTrajectoryMemorySet_TLNR()
731 if (!laststridesize) laststridesize = tjsch->stride; in TSTrajectoryMemorySet_TLNR()
733 if (!tjsch->recompute) { in TSTrajectoryMemorySet_TLNR()
734 PetscCall(TopLevelStore(tj, ts, tjsch, stepnum, localstepnum, laststridesize, &done)); in TSTrajectoryMemorySet_TLNR()
735 …if (!tjsch->save_stack && stepnum < tjsch->total_steps - laststridesize) PetscFunctionReturn(PETSC… in TSTrajectoryMemorySet_TLNR()
738 …if (stack->solution_only && localstepnum == tjsch->stride - 1) PetscFunctionReturn(PETSC_SUCCESS);… in TSTrajectoryMemorySet_TLNR()
747 static PetscErrorCode TSTrajectoryMemoryGet_TLNR(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscI… in TSTrajectoryMemoryGet_TLNR() argument
749 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_TLNR()
754 if (stepnum == tjsch->total_steps) { in TSTrajectoryMemoryGet_TLNR()
759 localstepnum = stepnum % tjsch->stride; in TSTrajectoryMemoryGet_TLNR()
760 laststridesize = tjsch->total_steps % tjsch->stride; in TSTrajectoryMemoryGet_TLNR()
761 if (!laststridesize) laststridesize = tjsch->stride; in TSTrajectoryMemoryGet_TLNR()
764 if (localstepnum == 0 && tjsch->total_steps - stepnum >= laststridesize) { in TSTrajectoryMemoryGet_TLNR()
765 id = stepnum / tjsch->stride; in TSTrajectoryMemoryGet_TLNR()
766 if (tjsch->save_stack) { in TSTrajectoryMemoryGet_TLNR()
768 tjsch->skip_trajectory = PETSC_TRUE; in TSTrajectoryMemoryGet_TLNR()
770 PetscCall(ReCompute(ts, tjsch, id * tjsch->stride - 1, id * tjsch->stride)); in TSTrajectoryMemoryGet_TLNR()
771 tjsch->skip_trajectory = PETSC_FALSE; in TSTrajectoryMemoryGet_TLNR()
775 PetscCall(ReCompute(ts, tjsch, (id - 1) * tjsch->stride, id * tjsch->stride)); in TSTrajectoryMemoryGet_TLNR()
782 tjsch->skip_trajectory = PETSC_TRUE; in TSTrajectoryMemoryGet_TLNR()
784 PetscCall(ReCompute(ts, tjsch, e->stepnum, stepnum)); in TSTrajectoryMemoryGet_TLNR()
785 tjsch->skip_trajectory = PETSC_FALSE; in TSTrajectoryMemoryGet_TLNR()
789 if (localstepnum == 0 && tjsch->total_steps - stepnum >= laststridesize) { in TSTrajectoryMemoryGet_TLNR()
790 id = stepnum / tjsch->stride; in TSTrajectoryMemoryGet_TLNR()
791 if (tjsch->save_stack) { in TSTrajectoryMemoryGet_TLNR()
796 PetscCall(ElementSet(ts, stack, &e, (id - 1) * tjsch->stride + 1, ts->ptime, ts->vec_sol)); in TSTrajectoryMemoryGet_TLNR()
799 PetscCall(ReCompute(ts, tjsch, e->stepnum, id * tjsch->stride)); in TSTrajectoryMemoryGet_TLNR()
974 static PetscErrorCode TSTrajectoryMemorySet_ROF(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemorySet_ROF() argument
976 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_ROF()
984 if (stack->solution_only && stepnum == tjsch->total_steps) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_ROF()
985 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemorySet_ROF()
987 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rstepnum, rstepnum, P… in TSTrajectoryMemorySet_ROF()
998 static PetscErrorCode TSTrajectoryMemoryGet_ROF(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemoryGet_ROF() argument
1000 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_ROF()
1006 if (stepnum == 0 || stepnum == tjsch->total_steps) { in TSTrajectoryMemoryGet_ROF()
1008 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_ROF()
1014 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemoryGet_ROF()
1017 tjsch->rctx->capo = rstepnum; in TSTrajectoryMemoryGet_ROF()
1018 tjsch->rctx->oldcapo = tjsch->rctx->capo; in TSTrajectoryMemoryGet_ROF()
1020 … = revolve_action(&tjsch->rctx->check, &tjsch->rctx->capo, &tjsch->rctx->fine, tjsch->rctx->sna… in TSTrajectoryMemoryGet_ROF()
1021 PetscCall(printwhattodo(tj->monitor, whattodo, tjsch->rctx, shift)); in TSTrajectoryMemoryGet_ROF()
1023 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rstepnum, rstepnum, P… in TSTrajectoryMemoryGet_ROF()
1026 …the step from %d to %d (stage values already checkpointed)\n", tjsch->rctx->oldcapo, tjsch->rctx->… in TSTrajectoryMemoryGet_ROF()
1029 if (!tjsch->rctx->reverseonestep && tjsch->rctx->stepsleft > 0) tjsch->rctx->stepsleft--; in TSTrajectoryMemoryGet_ROF()
1033 PetscCall(ReCompute(ts, tjsch, e->stepnum, stepnum)); in TSTrajectoryMemoryGet_ROF()
1036 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_ROF()
1040 static PetscErrorCode TSTrajectoryMemorySet_RON(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemorySet_RON() argument
1042 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_RON()
1047 RevolveCTX *rctx = tjsch->rctx; in TSTrajectoryMemorySet_RON()
1053 if (stack->solution_only && stepnum == tjsch->total_steps) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_RON()
1054 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemorySet_RON()
1056 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, rctx, rtotal_steps, rstepnum, rstepnum, PETSC_FA… in TSTrajectoryMemorySet_RON()
1080 static PetscErrorCode TSTrajectoryMemoryGet_RON(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemoryGet_RON() argument
1082 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_RON()
1087 if (stepnum == 0 || stepnum == tjsch->total_steps) { in TSTrajectoryMemoryGet_RON()
1089 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_RON()
1093 tjsch->rctx->capo = rstepnum; in TSTrajectoryMemoryGet_RON()
1094 tjsch->rctx->oldcapo = tjsch->rctx->capo; in TSTrajectoryMemoryGet_RON()
1096 … = revolve_action(&tjsch->rctx->check, &tjsch->rctx->capo, &tjsch->rctx->fine, tjsch->rctx->sna… in TSTrajectoryMemoryGet_RON()
1098 PetscCall(printwhattodo(tj->monitor, whattodo, tjsch->rctx, shift)); in TSTrajectoryMemoryGet_RON()
1100 PetscCall(StackFind(stack, &e, tjsch->rctx->check)); in TSTrajectoryMemoryGet_RON()
1104 tjsch->rctx->oldcapo = tjsch->rctx->capo; in TSTrajectoryMemoryGet_RON()
1105 … = revolve_action(&tjsch->rctx->check, &tjsch->rctx->capo, &tjsch->rctx->fine, tjsch->rctx->sna… in TSTrajectoryMemoryGet_RON()
1106 PetscCall(printwhattodo(tj->monitor, whattodo, tjsch->rctx, shift)); in TSTrajectoryMemoryGet_RON()
1107 if (whattodo == 3 || whattodo == 4) tjsch->rctx->reverseonestep = PETSC_TRUE; in TSTrajectoryMemoryGet_RON()
1108 if (whattodo == 1) tjsch->rctx->stepsleft = tjsch->rctx->capo - tjsch->rctx->oldcapo; in TSTrajectoryMemoryGet_RON()
1111 …the step from %d to %d (stage values already checkpointed)\n", tjsch->rctx->oldcapo, tjsch->rctx->… in TSTrajectoryMemoryGet_RON()
1114 if (!tjsch->rctx->reverseonestep && tjsch->rctx->stepsleft > 0) tjsch->rctx->stepsleft--; in TSTrajectoryMemoryGet_RON()
1118 PetscCall(ReCompute(ts, tjsch, e->stepnum, stepnum)); in TSTrajectoryMemoryGet_RON()
1120 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_RON()
1124 static PetscErrorCode TSTrajectoryMemorySet_TLR(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemorySet_TLR() argument
1126 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_TLR()
1135 if (stack->solution_only && stepnum == tjsch->total_steps) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_TLR()
1137 localstepnum = stepnum % tjsch->stride; in TSTrajectoryMemorySet_TLR()
1138 laststridesize = tjsch->total_steps % tjsch->stride; in TSTrajectoryMemorySet_TLR()
1139 if (!laststridesize) laststridesize = tjsch->stride; in TSTrajectoryMemorySet_TLR()
1141 if (!tjsch->recompute) { in TSTrajectoryMemorySet_TLR()
1142 PetscCall(TopLevelStore(tj, ts, tjsch, stepnum, localstepnum, laststridesize, &done)); in TSTrajectoryMemorySet_TLR()
1144 …if (!stack->solution_only && !tjsch->save_stack && stepnum <= tjsch->total_steps - laststridesize)… in TSTrajectoryMemorySet_TLR()
1145 …if (stack->solution_only && !tjsch->save_stack && stepnum < tjsch->total_steps - laststridesize) P… in TSTrajectoryMemorySet_TLR()
1147 if (tjsch->save_stack && done) { in TSTrajectoryMemorySet_TLR()
1148 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemorySet_TLR()
1151 if (laststridesize < tjsch->stride) { in TSTrajectoryMemorySet_TLR()
1152 …if (stack->solution_only && stepnum == tjsch->total_steps - laststridesize && !tjsch->recompute) {… in TSTrajectoryMemorySet_TLR()
1153 PetscCall(InitRevolve(laststridesize, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemorySet_TLR()
1155 …if (!stack->solution_only && stepnum == tjsch->total_steps - laststridesize + 1 && !tjsch->recompu… in TSTrajectoryMemorySet_TLR()
1156 PetscCall(InitRevolve(laststridesize, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemorySet_TLR()
1159 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemorySet_TLR()
1162 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rstepnum, rlocalstepn… in TSTrajectoryMemorySet_TLR()
1173 static PetscErrorCode TSTrajectoryMemoryGet_TLR(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemoryGet_TLR() argument
1175 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_TLR()
1182 localstepnum = stepnum % tjsch->stride; in TSTrajectoryMemoryGet_TLR()
1183 stridenum = stepnum / tjsch->stride; in TSTrajectoryMemoryGet_TLR()
1184 if (stepnum == tjsch->total_steps) { in TSTrajectoryMemoryGet_TLR()
1186 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_TLR()
1189 laststridesize = tjsch->total_steps % tjsch->stride; in TSTrajectoryMemoryGet_TLR()
1190 if (!laststridesize) laststridesize = tjsch->stride; in TSTrajectoryMemoryGet_TLR()
1191 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemoryGet_TLR()
1196 if (localstepnum == 0 && stepnum <= tjsch->total_steps - laststridesize) { in TSTrajectoryMemoryGet_TLR()
1197 if (tjsch->save_stack) { in TSTrajectoryMemoryGet_TLR()
1199 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLR()
1200 PetscCall(FastForwardRevolve(tjsch->rctx)); in TSTrajectoryMemoryGet_TLR()
1201 tjsch->skip_trajectory = PETSC_TRUE; in TSTrajectoryMemoryGet_TLR()
1203 PetscCall(ReCompute(ts, tjsch, stridenum * tjsch->stride - 1, stridenum * tjsch->stride)); in TSTrajectoryMemoryGet_TLR()
1204 tjsch->skip_trajectory = PETSC_FALSE; in TSTrajectoryMemoryGet_TLR()
1207 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLR()
1209 PetscCall(ReCompute(ts, tjsch, (stridenum - 1) * tjsch->stride, stridenum * tjsch->stride)); in TSTrajectoryMemoryGet_TLR()
1217 tjsch->rctx->capo = rstepnum; in TSTrajectoryMemoryGet_TLR()
1218 tjsch->rctx->oldcapo = tjsch->rctx->capo; in TSTrajectoryMemoryGet_TLR()
1220 … = revolve_action(&tjsch->rctx->check, &tjsch->rctx->capo, &tjsch->rctx->fine, tjsch->rctx->sna… in TSTrajectoryMemoryGet_TLR()
1221 PetscCall(printwhattodo(tj->monitor, whattodo, tjsch->rctx, shift)); in TSTrajectoryMemoryGet_TLR()
1223 PetscCall(ReCompute(ts, tjsch, e->stepnum, stepnum)); in TSTrajectoryMemoryGet_TLR()
1227 if (localstepnum == 0 && tjsch->total_steps - stepnum >= laststridesize) { in TSTrajectoryMemoryGet_TLR()
1228 if (tjsch->save_stack) { in TSTrajectoryMemoryGet_TLR()
1230 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLR()
1231 PetscCall(FastForwardRevolve(tjsch->rctx)); in TSTrajectoryMemoryGet_TLR()
1235 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLR()
1236 PetscCall(PetscRevolveIntCast((stridenum - 1) * tjsch->stride + 1, &rnum)); in TSTrajectoryMemoryGet_TLR()
1237 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rnum, 1, PETSC_FALSE,… in TSTrajectoryMemoryGet_TLR()
1241 …y checkpointed)\n", (stridenum - 1) * tjsch->stride + tjsch->rctx->oldcapo, (stridenum - 1) * tjsc… in TSTrajectoryMemoryGet_TLR()
1246 … PetscCall(ElementSet(ts, stack, &e, (stridenum - 1) * tjsch->stride + 1, ts->ptime, ts->vec_sol)); in TSTrajectoryMemoryGet_TLR()
1249 PetscCall(ReCompute(ts, tjsch, e->stepnum, stridenum * tjsch->stride)); in TSTrajectoryMemoryGet_TLR()
1257 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rstepnum, rlocalstepn… in TSTrajectoryMemoryGet_TLR()
1260 …lready checkpointed)\n", stepnum - localstepnum + tjsch->rctx->oldcapo, stepnum - localstepnum + t… in TSTrajectoryMemoryGet_TLR()
1263 if (!tjsch->rctx->reverseonestep && tjsch->rctx->stepsleft > 0) tjsch->rctx->stepsleft--; in TSTrajectoryMemoryGet_TLR()
1266 PetscCall(ReCompute(ts, tjsch, e->stepnum, stepnum)); in TSTrajectoryMemoryGet_TLR()
1270 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_TLR()
1274 static PetscErrorCode TSTrajectoryMemorySet_TLTR(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscI… in TSTrajectoryMemorySet_TLTR() argument
1276 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_TLTR()
1284 if (stack->solution_only && stepnum == tjsch->total_steps) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_TLTR()
1286 localstepnum = stepnum % tjsch->stride; /* index at the bottom level (inside a stride) */ in TSTrajectoryMemorySet_TLTR()
1287 stridenum = stepnum / tjsch->stride; /* index at the top level */ in TSTrajectoryMemorySet_TLTR()
1288 laststridesize = tjsch->total_steps % tjsch->stride; in TSTrajectoryMemorySet_TLTR()
1289 if (!laststridesize) laststridesize = tjsch->stride; in TSTrajectoryMemorySet_TLTR()
1290 if (stack->solution_only && localstepnum == 0 && !tjsch->rctx2->reverseonestep) { in TSTrajectoryMemorySet_TLTR()
1291 …PetscCall(PetscRevolveIntCast((tjsch->total_steps + tjsch->stride - 1) / tjsch->stride, &rtotal_st… in TSTrajectoryMemorySet_TLTR()
1293 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx2, rtotal_steps, rstepnum, rstepnum, … in TSTrajectoryMemorySet_TLTR()
1294 …tridesize < tjsch->stride && stepnum == tjsch->total_steps - laststridesize) PetscCall(InitRevolve… in TSTrajectoryMemorySet_TLTR()
1296 if (!stack->solution_only && localstepnum == 1 && !tjsch->rctx2->reverseonestep) { in TSTrajectoryMemorySet_TLTR()
1297 …PetscCall(PetscRevolveIntCast((tjsch->total_steps + tjsch->stride - 1) / tjsch->stride, &rtotal_st… in TSTrajectoryMemorySet_TLTR()
1299 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx2, rtotal_steps, rstepnum, rstepnum, … in TSTrajectoryMemorySet_TLTR()
1300 …idesize < tjsch->stride && stepnum == tjsch->total_steps - laststridesize + 1) PetscCall(InitRevol… in TSTrajectoryMemorySet_TLTR()
1302 if (tjsch->store_stride) { in TSTrajectoryMemorySet_TLTR()
1303 PetscCall(TopLevelStore(tj, ts, tjsch, stepnum, localstepnum, laststridesize, &done)); in TSTrajectoryMemorySet_TLTR()
1305 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemorySet_TLTR()
1309 if (stepnum < tjsch->total_steps - laststridesize) { in TSTrajectoryMemorySet_TLTR()
1310 …if (tjsch->save_stack && !tjsch->store_stride && !tjsch->rctx2->reverseonestep) PetscFunctionRetur… in TSTrajectoryMemorySet_TLTR()
1311 …if (!tjsch->save_stack && !tjsch->rctx2->reverseonestep) PetscFunctionReturn(PETSC_SUCCESS); … in TSTrajectoryMemorySet_TLTR()
1314 …if (!stack->solution_only && localstepnum == 0 && stepnum != tjsch->total_steps && !tjsch->recompu… in TSTrajectoryMemorySet_TLTR()
1315 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemorySet_TLTR()
1318 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rstepnum, rlocalstepn… in TSTrajectoryMemorySet_TLTR()
1330 static PetscErrorCode TSTrajectoryMemoryGet_TLTR(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscI… in TSTrajectoryMemoryGet_TLTR() argument
1332 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_TLTR()
1333 DiskStack *diskstack = &tjsch->diskstack; in TSTrajectoryMemoryGet_TLTR()
1340 localstepnum = stepnum % tjsch->stride; in TSTrajectoryMemoryGet_TLTR()
1341 stridenum = stepnum / tjsch->stride; in TSTrajectoryMemoryGet_TLTR()
1342 if (stepnum == tjsch->total_steps) { in TSTrajectoryMemoryGet_TLTR()
1344 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_TLTR()
1347 laststridesize = tjsch->total_steps % tjsch->stride; in TSTrajectoryMemoryGet_TLTR()
1348 if (!laststridesize) laststridesize = tjsch->stride; in TSTrajectoryMemoryGet_TLTR()
1356 if (localstepnum == 0 && stepnum <= tjsch->total_steps - laststridesize) { in TSTrajectoryMemoryGet_TLTR()
1359 tjsch->rctx2->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_TLTR()
1361 if (!tjsch->save_stack && stack->solution_only) { /* start with restoring a checkpoint */ in TSTrajectoryMemoryGet_TLTR()
1363 tjsch->rctx2->capo = rstepnum; in TSTrajectoryMemoryGet_TLTR()
1364 tjsch->rctx2->oldcapo = tjsch->rctx2->capo; in TSTrajectoryMemoryGet_TLTR()
1366 …= revolve2_action(&tjsch->rctx2->check, &tjsch->rctx2->capo, &tjsch->rctx2->fine, tjsch->rctx2->sn… in TSTrajectoryMemoryGet_TLTR()
1367 PetscCall(printwhattodo2(tj->monitor, whattodo, tjsch->rctx2, shift)); in TSTrajectoryMemoryGet_TLTR()
1369 …PetscCall(PetscRevolveIntCast((tjsch->total_steps + tjsch->stride - 1) / tjsch->stride, &rtotal_st… in TSTrajectoryMemoryGet_TLTR()
1371 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx2, rtotal_steps, rstepnum, rstepnum, … in TSTrajectoryMemoryGet_TLTR()
1374 … stride from %d to %d (stage values already checkpointed)\n", tjsch->rctx2->oldcapo, tjsch->rctx2-… in TSTrajectoryMemoryGet_TLTR()
1377 if (!tjsch->rctx2->reverseonestep && tjsch->rctx2->stepsleft > 0) tjsch->rctx2->stepsleft--; in TSTrajectoryMemoryGet_TLTR()
1381 if (tjsch->save_stack) { in TSTrajectoryMemoryGet_TLTR()
1388 tjsch->skip_trajectory = PETSC_TRUE; in TSTrajectoryMemoryGet_TLTR()
1390 PetscCall(ReCompute(ts, tjsch, stridenum * tjsch->stride - 1, stridenum * tjsch->stride)); in TSTrajectoryMemoryGet_TLTR()
1391 tjsch->skip_trajectory = PETSC_FALSE; in TSTrajectoryMemoryGet_TLTR()
1393 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLTR()
1395 PetscCall(ReCompute(ts, tjsch, restoredstridenum * tjsch->stride, stepnum)); in TSTrajectoryMemoryGet_TLTR()
1397 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLTR()
1398 PetscCall(FastForwardRevolve(tjsch->rctx)); in TSTrajectoryMemoryGet_TLTR()
1402 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLTR()
1404 PetscCall(ReCompute(ts, tjsch, (restoredstridenum - 1) * tjsch->stride, stepnum)); in TSTrajectoryMemoryGet_TLTR()
1407 if (tjsch->save_stack) { in TSTrajectoryMemoryGet_TLTR()
1411 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLTR()
1413 PetscCall(ReCompute(ts, tjsch, restoredstridenum * tjsch->stride, stepnum)); in TSTrajectoryMemoryGet_TLTR()
1416 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLTR()
1417 PetscCall(FastForwardRevolve(tjsch->rctx)); in TSTrajectoryMemoryGet_TLTR()
1421 PetscCall(InitRevolve(tjsch->stride, tjsch->max_cps_ram, tjsch->rctx)); in TSTrajectoryMemoryGet_TLTR()
1423 if (tjsch->store_stride || tjsch->rctx2->reverseonestep) { in TSTrajectoryMemoryGet_TLTR()
1425 shift = (restoredstridenum - 1) * tjsch->stride - localstepnum; in TSTrajectoryMemoryGet_TLTR()
1426 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemoryGet_TLTR()
1427 PetscCall(PetscRevolveIntCast((restoredstridenum - 1) * tjsch->stride + 1, &rstepnum)); in TSTrajectoryMemoryGet_TLTR()
1428 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rstepnum, 1, PETSC_FA… in TSTrajectoryMemoryGet_TLTR()
1431 … already checkpointed)\n", (restoredstridenum - 1) * tjsch->stride, (restoredstridenum - 1) * tjsc… in TSTrajectoryMemoryGet_TLTR()
1435 …PetscCall(ElementSet(ts, stack, &e, (restoredstridenum - 1) * tjsch->stride + 1, ts->ptime, ts->ve… in TSTrajectoryMemoryGet_TLTR()
1439 PetscCall(ReCompute(ts, tjsch, (restoredstridenum - 1) * tjsch->stride + 1, stepnum)); in TSTrajectoryMemoryGet_TLTR()
1443 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_TLTR()
1454 tjsch->rctx->capo = rstepnum; in TSTrajectoryMemoryGet_TLTR()
1455 tjsch->rctx->oldcapo = tjsch->rctx->capo; in TSTrajectoryMemoryGet_TLTR()
1457 … = revolve_action(&tjsch->rctx->check, &tjsch->rctx->capo, &tjsch->rctx->fine, tjsch->rctx->sna… in TSTrajectoryMemoryGet_TLTR()
1458 PetscCall(printwhattodo(tj->monitor, whattodo, tjsch->rctx, shift)); in TSTrajectoryMemoryGet_TLTR()
1460 PetscCall(ReCompute(ts, tjsch, e->stepnum, stepnum)); in TSTrajectoryMemoryGet_TLTR()
1468 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemoryGet_TLTR()
1471 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rstepnum, rlocalstepn… in TSTrajectoryMemoryGet_TLTR()
1474 …lready checkpointed)\n", stepnum - localstepnum + tjsch->rctx->oldcapo, stepnum - localstepnum + t… in TSTrajectoryMemoryGet_TLTR()
1477 if (!tjsch->rctx->reverseonestep && tjsch->rctx->stepsleft > 0) tjsch->rctx->stepsleft--; in TSTrajectoryMemoryGet_TLTR()
1480 PetscCall(ReCompute(ts, tjsch, e->stepnum, stepnum)); in TSTrajectoryMemoryGet_TLTR()
1484 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_TLTR()
1488 static PetscErrorCode TSTrajectoryMemorySet_RMS(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemorySet_RMS() argument
1490 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_RMS()
1497 if (stack->solution_only && stepnum == tjsch->total_steps) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_RMS()
1498 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rtotal_steps)); in TSTrajectoryMemorySet_RMS()
1500 …PetscCall(ApplyRevolve(tj->monitor, tjsch->stype, tjsch->rctx, rtotal_steps, rstepnum, rstepnum, P… in TSTrajectoryMemorySet_RMS()
1509 PetscCall(DumpSingle(tj, ts, stack, tjsch->rctx->check + 1)); in TSTrajectoryMemorySet_RMS()
1514 static PetscErrorCode TSTrajectoryMemoryGet_RMS(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemoryGet_RMS() argument
1516 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_RMS()
1523 if (stepnum == 0 || stepnum == tjsch->total_steps) { in TSTrajectoryMemoryGet_RMS()
1525 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_RMS()
1529 tjsch->rctx->capo = rstepnum; in TSTrajectoryMemoryGet_RMS()
1530 tjsch->rctx->oldcapo = tjsch->rctx->capo; in TSTrajectoryMemoryGet_RMS()
1532 … = revolve_action(&tjsch->rctx->check, &tjsch->rctx->capo, &tjsch->rctx->fine, tjsch->rctx->sna… in TSTrajectoryMemoryGet_RMS()
1533 PetscCall(printwhattodo(tj->monitor, whattodo, tjsch->rctx, shift)); in TSTrajectoryMemoryGet_RMS()
1535 restart = tjsch->rctx->capo; in TSTrajectoryMemoryGet_RMS()
1536 if (!tjsch->rctx->where) { in TSTrajectoryMemoryGet_RMS()
1538 PetscCall(LoadSingle(tj, ts, stack, tjsch->rctx->check + 1)); in TSTrajectoryMemoryGet_RMS()
1547 tjsch->rctx->oldcapo = tjsch->rctx->capo; in TSTrajectoryMemoryGet_RMS()
1548 … = revolve_action(&tjsch->rctx->check, &tjsch->rctx->capo, &tjsch->rctx->fine, tjsch->rctx->sna… in TSTrajectoryMemoryGet_RMS()
1549 PetscCall(printwhattodo(tj->monitor, whattodo, tjsch->rctx, shift)); in TSTrajectoryMemoryGet_RMS()
1550 if (whattodo == 3 || whattodo == 4) tjsch->rctx->reverseonestep = PETSC_TRUE; in TSTrajectoryMemoryGet_RMS()
1551 if (whattodo == 1) tjsch->rctx->stepsleft = tjsch->rctx->capo - tjsch->rctx->oldcapo; in TSTrajectoryMemoryGet_RMS()
1554 …the step from %d to %d (stage values already checkpointed)\n", tjsch->rctx->oldcapo, tjsch->rctx->… in TSTrajectoryMemoryGet_RMS()
1557 if (!tjsch->rctx->reverseonestep && tjsch->rctx->stepsleft > 0) tjsch->rctx->stepsleft--; in TSTrajectoryMemoryGet_RMS()
1562 PetscCall(ReCompute(ts, tjsch, restart, stepnum)); in TSTrajectoryMemoryGet_RMS()
1565 tjsch->rctx->reverseonestep = PETSC_FALSE; in TSTrajectoryMemoryGet_RMS()
1572 static PetscErrorCode TSTrajectoryMemorySet_AOF(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemorySet_AOF() argument
1574 Stack *stack = &tjsch->stack; in TSTrajectoryMemorySet_AOF()
1579 if (tjsch->actx->nextcheckpointstep == -1) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_AOF()
1582 …PetscCallExternal(offline_ca, tjsch->actx->lastcheckpointstep, tjsch->actx->num_units_avail, tjsch… in TSTrajectoryMemorySet_AOF()
1585 …tjsch->actx->lastcheckpointstep, tjsch->actx->lastcheckpointtype, tjsch->actx->num_units_avail, tj… in TSTrajectoryMemorySet_AOF()
1589 if (stack->solution_only && stepnum == tjsch->total_steps) PetscFunctionReturn(PETSC_SUCCESS); in TSTrajectoryMemorySet_AOF()
1591 if (tjsch->actx->nextcheckpointstep == stepnum) { in TSTrajectoryMemorySet_AOF()
1594 if (tjsch->actx->nextcheckpointtype == 2) { /* solution + stage values */ in TSTrajectoryMemorySet_AOF()
1599 if (tjsch->actx->nextcheckpointtype == 1) { in TSTrajectoryMemorySet_AOF()
1604 if (tjsch->actx->nextcheckpointtype == 0) { /* solution only */ in TSTrajectoryMemorySet_AOF()
1611 tjsch->actx->lastcheckpointstep = stepnum; in TSTrajectoryMemorySet_AOF()
1613 …PetscCallExternal(offline_ca, tjsch->actx->lastcheckpointstep, tjsch->actx->num_units_avail, tjsch… in TSTrajectoryMemorySet_AOF()
1614 tjsch->actx->num_units_avail--; in TSTrajectoryMemorySet_AOF()
1616 tjsch->actx->lastcheckpointtype = tjsch->actx->nextcheckpointtype; in TSTrajectoryMemorySet_AOF()
1617 …tjsch->actx->lastcheckpointstep, tjsch->actx->lastcheckpointtype, tjsch->actx->num_units_avail, tj… in TSTrajectoryMemorySet_AOF()
1618 …if (tjsch->actx->lastcheckpointtype == 2) tjsch->actx->num_units_avail -= tjsch->actx->num_stages … in TSTrajectoryMemorySet_AOF()
1619 … if (tjsch->actx->lastcheckpointtype == 1) tjsch->actx->num_units_avail -= tjsch->actx->num_stages; in TSTrajectoryMemorySet_AOF()
1620 if (tjsch->actx->lastcheckpointtype == 0) tjsch->actx->num_units_avail--; in TSTrajectoryMemorySet_AOF()
1626 static PetscErrorCode TSTrajectoryMemoryGet_AOF(TSTrajectory tj, TS ts, TJScheduler *tjsch, PetscIn… in TSTrajectoryMemoryGet_AOF() argument
1628 Stack *stack = &tjsch->stack; in TSTrajectoryMemoryGet_AOF()
1633 if (stepnum == 0 || stepnum == tjsch->total_steps) { in TSTrajectoryMemoryGet_AOF()
1642 tjsch->actx->num_units_avail++; in TSTrajectoryMemoryGet_AOF()
1649 if (e->cptype == STAGESONLY) tjsch->actx->num_units_avail += tjsch->actx->num_stages; in TSTrajectoryMemoryGet_AOF()
1650 if (e->cptype == SOLUTION_STAGES) tjsch->actx->num_units_avail += tjsch->actx->num_stages + 1; in TSTrajectoryMemoryGet_AOF()
1653 tjsch->actx->num_units_avail++; in TSTrajectoryMemoryGet_AOF()
1657 tjsch->actx->lastcheckpointstep = estepnum; in TSTrajectoryMemoryGet_AOF()
1658 tjsch->actx->endstep = stepnum; in TSTrajectoryMemoryGet_AOF()
1660 …PetscCallExternal(offline_ca, tjsch->actx->lastcheckpointstep, tjsch->actx->num_units_avail, tjsch… in TSTrajectoryMemoryGet_AOF()
1662 tjsch->actx->lastcheckpointtype = e->cptype; in TSTrajectoryMemoryGet_AOF()
1663 …tjsch->actx->lastcheckpointstep, tjsch->actx->lastcheckpointtype, tjsch->actx->num_units_avail, tj… in TSTrajectoryMemoryGet_AOF()
1670 if (e->cptype == STAGESONLY) tjsch->actx->num_units_avail -= tjsch->actx->num_stages; in TSTrajectoryMemoryGet_AOF()
1671 if (e->cptype == SOLUTION_STAGES) tjsch->actx->num_units_avail -= tjsch->actx->num_stages + 1; in TSTrajectoryMemoryGet_AOF()
1677 tjsch->actx->num_units_avail--; in TSTrajectoryMemoryGet_AOF()
1683 PetscCall(ReCompute(ts, tjsch, estepnum, stepnum)); in TSTrajectoryMemoryGet_AOF()
1691 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySet_Memory() local
1694 if (!tjsch->recompute) { /* use global stepnum in the forward sweep */ in TSTrajectorySet_Memory()
1698 if (!tjsch->recompute && stepnum == 0) ts->ptime_prev = ts->ptime - ts->time_step; in TSTrajectorySet_Memory()
1699 switch (tjsch->stype) { in TSTrajectorySet_Memory()
1702 PetscCall(TSTrajectoryMemorySet_N(ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1704 PetscCall(TSTrajectoryMemorySet_N_2(ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1709 PetscCall(TSTrajectoryMemorySet_TLNR(tj, ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1714 PetscCall(TSTrajectoryMemorySet_TLR(tj, ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1718 PetscCall(TSTrajectoryMemorySet_TLTR(tj, ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1722 PetscCall(TSTrajectoryMemorySet_ROF(tj, ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1726 PetscCall(TSTrajectoryMemorySet_RON(tj, ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1730 PetscCall(TSTrajectoryMemorySet_RMS(tj, ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1736 PetscCall(TSTrajectoryMemorySet_AOF(tj, ts, tjsch, stepnum, time, X)); in TSTrajectorySet_Memory()
1747 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectoryGet_Memory() local
1754 switch (tjsch->stype) { in TSTrajectoryGet_Memory()
1757 PetscCall(TSTrajectoryMemoryGet_N(ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1759 PetscCall(TSTrajectoryMemoryGet_N_2(ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1764 PetscCall(TSTrajectoryMemoryGet_TLNR(tj, ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1769 PetscCall(TSTrajectoryMemoryGet_TLR(tj, ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1773 PetscCall(TSTrajectoryMemoryGet_TLTR(tj, ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1777 PetscCall(TSTrajectoryMemoryGet_ROF(tj, ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1781 PetscCall(TSTrajectoryMemoryGet_RON(tj, ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1785 PetscCall(TSTrajectoryMemoryGet_RMS(tj, ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1791 PetscCall(TSTrajectoryMemoryGet_AOF(tj, ts, tjsch, stepnum)); in TSTrajectoryGet_Memory()
1802 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetStride_Memory() local
1805 tjsch->stride = stride; in TSTrajectorySetStride_Memory()
1811 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetMaxCpsRAM_Memory() local
1814 tjsch->max_cps_ram = max_cps_ram; in TSTrajectorySetMaxCpsRAM_Memory()
1820 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetMaxCpsDisk_Memory() local
1823 tjsch->max_cps_disk = max_cps_disk; in TSTrajectorySetMaxCpsDisk_Memory()
1829 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetMaxUnitsRAM_Memory() local
1832 …PetscCheck(tjsch->max_cps_ram, PetscObjectComm((PetscObject)tj), PETSC_ERR_ARG_INCOMP, "Conflict w… in TSTrajectorySetMaxUnitsRAM_Memory()
1833 tjsch->max_units_ram = max_units_ram; in TSTrajectorySetMaxUnitsRAM_Memory()
1839 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetMaxUnitsDisk_Memory() local
1842 …PetscCheck(tjsch->max_cps_disk, PetscObjectComm((PetscObject)tj), PETSC_ERR_ARG_INCOMP, "Conflict … in TSTrajectorySetMaxUnitsDisk_Memory()
1843 tjsch->max_units_ram = max_units_disk; in TSTrajectorySetMaxUnitsDisk_Memory()
1849 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectoryMemorySetType_Memory() local
1853 tjsch->tj_memory_type = tj_memory_type; in TSTrajectoryMemorySetType_Memory()
1860 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetRevolveOnline() local
1863 tjsch->use_online = use_online; in TSTrajectorySetRevolveOnline()
1870 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetSaveStack() local
1873 tjsch->save_stack = save_stack; in TSTrajectorySetSaveStack()
1879 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetUseDRAM() local
1882 tjsch->stack.use_dram = use_dram; in TSTrajectorySetUseDRAM()
1999 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetFromOptions_Memory() local
2007 …ram", "Maximum number of checkpoints in RAM", "TSTrajectorySetMaxCpsRAM", tjsch->max_cps_ram, &max… in TSTrajectorySetFromOptions_Memory()
2009 …k", "Maximum number of checkpoints on disk", "TSTrajectorySetMaxCpsDisk", tjsch->max_cps_disk, &ma… in TSTrajectorySetFromOptions_Memory()
2011 …imum number of checkpointing units in RAM", "TSTrajectorySetMaxUnitsRAM", tjsch->max_units_ram, &m… in TSTrajectorySetFromOptions_Memory()
2013 …um number of checkpointing units on disk", "TSTrajectorySetMaxUnitsDisk", tjsch->max_units_disk, &… in TSTrajectorySetFromOptions_Memory()
2015 …", "Stride to save checkpoints to file", "TSTrajectorySetStride", tjsch->stride, &tjsch->stride, N… in TSTrajectorySetFromOptions_Memory()
2017 … using online mode of revolve", "TSTrajectorySetRevolveOnline", tjsch->use_online, &tjsch->use_onl… in TSTrajectorySetFromOptions_Memory()
2019 …e_stack", "Save all stack to disk", "TSTrajectorySetSaveStack", tjsch->save_stack, &tjsch->save_st… in TSTrajectorySetFromOptions_Memory()
2020 …ram", "Use DRAM for checkpointing", "TSTrajectorySetUseDRAM", tjsch->stack.use_dram, &tjsch->stack… in TSTrajectorySetFromOptions_Memory()
2021 …e", "TSTrajectoryMemorySetType", TSTrajectoryMemoryTypes, (PetscEnum)(int)tjsch->tj_memory_type, &… in TSTrajectorySetFromOptions_Memory()
2030 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectorySetUp_Memory() local
2031 Stack *stack = &tjsch->stack; in TSTrajectorySetUp_Memory()
2034 DiskStack *diskstack = &tjsch->diskstack; in TSTrajectorySetUp_Memory()
2048 if (fixedtimestep) tjsch->total_steps = PetscMin(ts->max_steps, total_steps); in TSTrajectorySetUp_Memory()
2050 tjsch->stack.solution_only = tj->solution_only; in TSTrajectorySetUp_Memory()
2053 if (tjsch->max_units_ram) tjsch->max_cps_ram = tjsch->max_units_ram; in TSTrajectorySetUp_Memory()
2054 else tjsch->max_units_ram = tjsch->max_cps_ram; in TSTrajectorySetUp_Memory()
2055 if (tjsch->max_units_disk) tjsch->max_cps_disk = tjsch->max_units_disk; in TSTrajectorySetUp_Memory()
2057 …if (tjsch->max_units_ram) tjsch->max_cps_ram = (ts->stifflyaccurate) ? tjsch->max_units_ram / numY… in TSTrajectorySetUp_Memory()
2058 …else tjsch->max_units_ram = (ts->stifflyaccurate) ? numY * tjsch->max_cps_ram : (numY + 1) * tjsch… in TSTrajectorySetUp_Memory()
2059 …if (tjsch->max_units_disk) tjsch->max_cps_disk = (ts->stifflyaccurate) ? tjsch->max_units_disk / n… in TSTrajectorySetUp_Memory()
2060 …else tjsch->max_units_disk = (ts->stifflyaccurate) ? numY * tjsch->max_cps_disk : (numY + 1) * tjs… in TSTrajectorySetUp_Memory()
2062 …if (tjsch->max_cps_ram > 0) stack->stacksize = tjsch->max_units_ram; /* maximum stack size. Could … in TSTrajectorySetUp_Memory()
2065 if (tjsch->stride > 1) { /* two level mode */ in TSTrajectorySetUp_Memory()
2066 …PetscCheck(!tjsch->save_stack || tjsch->max_cps_disk <= 1 || tjsch->max_cps_disk > tjsch->max_cps_… in TSTrajectorySetUp_Memory()
2067 …if (tjsch->max_cps_disk <= 1 && tjsch->max_cps_ram > 1 && tjsch->max_cps_ram <= tjsch->stride - 1)… in TSTrajectorySetUp_Memory()
2068 …if (tjsch->max_cps_disk > 1 && tjsch->max_cps_ram > 1 && tjsch->max_cps_ram <= tjsch->stride - 1) … in TSTrajectorySetUp_Memory()
2069 …if (tjsch->max_cps_disk <= 1 && (tjsch->max_cps_ram >= tjsch->stride || tjsch->max_cps_ram == -1))… in TSTrajectorySetUp_Memory()
2072 …if (tjsch->max_cps_ram >= tjsch->total_steps - 1 || tjsch->max_cps_ram == -1) tjsch->stype = NONE;… in TSTrajectorySetUp_Memory()
2073 …else { /* choose the schedule software for offline checkpointing */ switch (tjsch->tj_memory_type)… in TSTrajectorySetUp_Memory()
2075 tjsch->stype = NONE; in TSTrajectorySetUp_Memory()
2078 tjsch->stype = CAMS_OFFLINE; in TSTrajectorySetUp_Memory()
2081 tjsch->stype = (tjsch->max_cps_disk > 1) ? REVOLVE_MULTISTAGE : REVOLVE_OFFLINE; in TSTrajectorySetUp_Memory()
2087 } else tjsch->stype = NONE; /* checkpoint all for adaptive time step */ in TSTrajectorySetUp_Memory()
2089 …if (tjsch->use_online) tjsch->stype = REVOLVE_ONLINE; /* trick into online (for testing purpose on… in TSTrajectorySetUp_Memory()
2091 …PetscCheck(tjsch->stype == NONE || tjsch->max_cps_ram >= 1 || tjsch->max_cps_disk >= 1, PetscObjec… in TSTrajectorySetUp_Memory()
2093 if (tjsch->stype >= CAMS_OFFLINE) { in TSTrajectorySetUp_Memory()
2100 offline_ca_create(tjsch->total_steps, tjsch->max_cps_ram); in TSTrajectorySetUp_Memory()
2103 offline_cams_create(tjsch->total_steps, tjsch->max_units_ram, ns, ts->stifflyaccurate); in TSTrajectorySetUp_Memory()
2108 actx->endstep = tjsch->total_steps; in TSTrajectorySetUp_Memory()
2109 actx->num_units_avail = tjsch->max_units_ram; in TSTrajectorySetUp_Memory()
2111 tjsch->actx = actx; in TSTrajectorySetUp_Memory()
2113 } else if (tjsch->stype > TWO_LEVEL_NOREVOLVE) { in TSTrajectorySetUp_Memory()
2119 switch (tjsch->stype) { in TSTrajectorySetUp_Memory()
2121 PetscCall(PetscRevolveIntCast(tjsch->stride, &rfine)); in TSTrajectorySetUp_Memory()
2122 PetscCall(PetscRevolveIntCast(tjsch->max_cps_ram, &rsnaps)); in TSTrajectorySetUp_Memory()
2126 …diskblocks = tjsch->save_stack ? tjsch->max_cps_disk / (tjsch->max_cps_ram + 1) : tjsch-… in TSTrajectorySetUp_Memory()
2128 PetscCall(PetscRevolveIntCast(tjsch->stride, &rfine)); in TSTrajectorySetUp_Memory()
2129 PetscCall(PetscRevolveIntCast(tjsch->max_cps_ram, &rsnaps)); in TSTrajectorySetUp_Memory()
2131 … PetscCall(PetscRevolveIntCast((tjsch->total_steps + tjsch->stride - 1) / tjsch->stride, &rfine)); in TSTrajectorySetUp_Memory()
2142 tjsch->rctx2 = rctx2; in TSTrajectorySetUp_Memory()
2147 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rfine)); in TSTrajectorySetUp_Memory()
2148 PetscCall(PetscRevolveIntCast(tjsch->max_cps_ram, &rsnaps)); in TSTrajectorySetUp_Memory()
2152 stack->stacksize = tjsch->max_cps_ram; in TSTrajectorySetUp_Memory()
2153 PetscCall(PetscRevolveIntCast(tjsch->max_cps_ram, &rsnaps)); in TSTrajectorySetUp_Memory()
2157 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rfine)); in TSTrajectorySetUp_Memory()
2158 PetscCall(PetscRevolveIntCast(tjsch->max_cps_ram, &rsnaps)); in TSTrajectorySetUp_Memory()
2159 PetscCall(PetscRevolveIntCast(tjsch->max_cps_ram + tjsch->max_cps_disk, &rsnaps2)); in TSTrajectorySetUp_Memory()
2166 PetscCall(PetscRevolveIntCast(tjsch->max_cps_ram, &rsnaps)); in TSTrajectorySetUp_Memory()
2173 if (tjsch->stride > 1) { in TSTrajectorySetUp_Memory()
2174 PetscCall(PetscRevolveIntCast(tjsch->stride, &rfine)); in TSTrajectorySetUp_Memory()
2176 PetscCall(PetscRevolveIntCast(tjsch->total_steps, &rfine)); in TSTrajectorySetUp_Memory()
2179 tjsch->rctx = rctx; in TSTrajectorySetUp_Memory()
2180 if (tjsch->stype == REVOLVE_ONLINE) rctx->fine = -1; in TSTrajectorySetUp_Memory()
2183 …if (tjsch->stype == TWO_LEVEL_NOREVOLVE) stack->stacksize = tjsch->stride - 1; /* need tjsch->stri… in TSTrajectorySetUp_Memory()
2184 if (tjsch->stype == NONE) { in TSTrajectorySetUp_Memory()
2185 …if (fixedtimestep) stack->stacksize = stack->solution_only ? tjsch->total_steps : tjsch->total_ste… in TSTrajectorySetUp_Memory()
2187 …if (tjsch->max_cps_ram == -1) stack->stacksize = ts->max_steps < PETSC_INT_MAX ? ts->max_steps : 1… in TSTrajectorySetUp_Memory()
2188 …tjsch->total_steps = stack->solution_only ? stack->stacksize : stack->stacksize + 1; /* will be up… in TSTrajectorySetUp_Memory()
2193 …if ((tjsch->stype >= TWO_LEVEL_NOREVOLVE && tjsch->stype < REVOLVE_OFFLINE) || tjsch->stype == REV… in TSTrajectorySetUp_Memory()
2198 tjsch->recompute = PETSC_FALSE; in TSTrajectorySetUp_Memory()
2206 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectoryReset_Memory() local
2211 if (tjsch->stype > TWO_LEVEL_NOREVOLVE) { in TSTrajectoryReset_Memory()
2213 if (tjsch->stype == TWO_LEVEL_TWO_REVOLVE) { in TSTrajectoryReset_Memory()
2215 PetscCall(PetscFree(tjsch->diskstack.container)); in TSTrajectoryReset_Memory()
2218 if (tjsch->stype > TWO_LEVEL_NOREVOLVE) { in TSTrajectoryReset_Memory()
2219 PetscCall(PetscFree(tjsch->rctx)); in TSTrajectoryReset_Memory()
2220 PetscCall(PetscFree(tjsch->rctx2)); in TSTrajectoryReset_Memory()
2224 if (tjsch->stype == CAMS_OFFLINE) { in TSTrajectoryReset_Memory()
2225 if (tjsch->stack.solution_only) offline_ca_destroy(); in TSTrajectoryReset_Memory()
2227 PetscCall(PetscFree(tjsch->actx)); in TSTrajectoryReset_Memory()
2235 TJScheduler *tjsch = (TJScheduler *)tj->data; in TSTrajectoryDestroy_Memory() local
2238 PetscCall(StackDestroy(&tjsch->stack)); in TSTrajectoryDestroy_Memory()
2239 PetscCall(PetscViewerDestroy(&tjsch->viewer)); in TSTrajectoryDestroy_Memory()
2245 PetscCall(PetscFree(tjsch)); in TSTrajectoryDestroy_Memory()
2258 TJScheduler *tjsch; in TSTrajectoryCreate_Memory() local
2268 PetscCall(PetscNew(&tjsch)); in TSTrajectoryCreate_Memory()
2269 tjsch->stype = NONE; in TSTrajectoryCreate_Memory()
2270 tjsch->max_cps_ram = -1; /* -1 indicates that it is not set */ in TSTrajectoryCreate_Memory()
2271 tjsch->max_cps_disk = -1; /* -1 indicates that it is not set */ in TSTrajectoryCreate_Memory()
2272 tjsch->stride = 0; /* if not zero, two-level checkpointing will be used */ in TSTrajectoryCreate_Memory()
2274 tjsch->use_online = PETSC_FALSE; in TSTrajectoryCreate_Memory()
2276 tjsch->save_stack = PETSC_TRUE; in TSTrajectoryCreate_Memory()
2278 tjsch->stack.solution_only = tj->solution_only; in TSTrajectoryCreate_Memory()
2279 PetscCall(PetscViewerCreate(PetscObjectComm((PetscObject)tj), &tjsch->viewer)); in TSTrajectoryCreate_Memory()
2280 PetscCall(PetscViewerSetType(tjsch->viewer, PETSCVIEWERBINARY)); in TSTrajectoryCreate_Memory()
2281 PetscCall(PetscViewerPushFormat(tjsch->viewer, PETSC_VIEWER_NATIVE)); in TSTrajectoryCreate_Memory()
2282 PetscCall(PetscViewerFileSetMode(tjsch->viewer, FILE_MODE_WRITE)); in TSTrajectoryCreate_Memory()
2289 tj->data = tjsch; in TSTrajectoryCreate_Memory()