Skip to content

Commit

Permalink
Only trigger GC in between timesteps
Browse files Browse the repository at this point in the history
  • Loading branch information
michel2323 committed Apr 17, 2023
1 parent d081b35 commit 6e8e95b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Checkpointing"
uuid = "eb46d486-4f9c-4c3d-b445-a617f2a2f1ca"
authors = ["Michel Schanen <[email protected]>", "Sri Hari Krishna Narayanan <[email protected]>"]
version = "0.7.0"
version = "0.7.1"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
4 changes: 4 additions & 0 deletions src/Schemes/Revolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ function checkpoint_struct_for(
check = 0
model_check = alg.storage
model_final = []
GC.enable(false)
while true
next_action = next_action!(alg)
if (next_action.actionflag == Checkpointing.store)
Expand All @@ -410,8 +411,10 @@ function checkpoint_struct_for(
body(model)
model_final = deepcopy(model)
Enzyme.autodiff(Reverse, body, Duplicated(model,shadowmodel))
GC.gc()
elseif (next_action.actionflag == Checkpointing.uturn)
Enzyme.autodiff(Reverse, body, Duplicated(model,shadowmodel))
GC.gc()
if haskey(storemap,next_action.iteration-1-1)
delete!(storemap,next_action.iteration-1-1)
check=check-1
Expand All @@ -426,5 +429,6 @@ function checkpoint_struct_for(
break
end
end
GC.enable(true)
return model_final
end

0 comments on commit 6e8e95b

Please sign in to comment.