設定した stride の accepted batch で、非active slotへ完全な再開状態を書いてからindexを切り替える。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(app_config), | intent(in) | :: | app | |||
| type(mesh_type), | intent(in) | :: | mesh | |||
| type(sim_stats), | intent(in) | :: | stats | |||
| type(injection_state), | intent(in), | optional | :: | state | ||
| type(mpi_context), | intent(in) | :: | mpi | |||
| type(charge_ledger_type), | intent(in), | optional | :: | charge_ledger |
subroutine maybe_write_periodic_checkpoint(app, mesh, stats, state, mpi, charge_ledger) type(app_config), intent(in) :: app type(mesh_type), intent(in) :: mesh type(sim_stats), intent(in) :: stats type(injection_state), intent(in), optional :: state type(mpi_context), intent(in) :: mpi type(charge_ledger_type), intent(in), optional :: charge_ledger integer(i32) :: slot_values(1), inactive_slot character(len=1024) :: checkpoint_dir logical :: has_macro_residuals, has_charge_ledger if (.not. app%write_output) return if (app%checkpoint_stride <= 0_i32) return if (stats%batches <= 0_i32) return if (mod(stats%batches, app%checkpoint_stride) /= 0_i32) return slot_values = 1_i32 if (mpi_is_root(mpi)) then call read_active_slot(trim(app%output_dir), slot_values(1)) slot_values(1) = 1_i32 - slot_values(1) end if call mpi_bcast_i32_array(mpi, slot_values, 0_i32) inactive_slot = slot_values(1) checkpoint_dir = checkpoint_slot_dir(trim(app%output_dir), inactive_slot) has_macro_residuals = .false. if (present(state)) has_macro_residuals = allocated(state%macro_residual) has_charge_ledger = present(charge_ledger) if (mpi_is_root(mpi)) then call ensure_output_dir(trim(checkpoint_dir)) call write_checkpoint_state_files( & trim(checkpoint_dir), mesh, stats, app, mpi_world_size=mpi_world_size(mpi), charge_ledger=charge_ledger & ) end if ! 非root rankがslot directoryの作成より先にrank別RNGを書き始めないよう同期する。 call mpi_world_barrier(mpi) call write_rng_state_file(trim(checkpoint_dir), mpi=mpi) if (present(state)) call write_macro_residuals_file(trim(checkpoint_dir), state, mpi=mpi) ! completion manifestを全rankのファイルが閉じられた後に公開し、続けてadvisory indexを更新する。 call mpi_world_barrier(mpi) if (mpi_is_root(mpi)) then call publish_checkpoint_manifest( & trim(checkpoint_dir), stats%batches, mpi_world_size(mpi), has_macro_residuals, has_charge_ledger & ) call publish_checkpoint_index(trim(app%output_dir), inactive_slot, stats%batches) print '(a,i0,a,a)', 'periodic_checkpoint_batch=', stats%batches, ' dir=', trim(checkpoint_dir) end if call mpi_world_barrier(mpi) end subroutine maybe_write_periodic_checkpoint