Skip to content

Commit 738d172

Browse files
authored
Fix a bug for SpecifiedTimes time-step alignment (#3634)
* Fix a bug for SpecifiedTimes time-step alignment * Add a simple test for aligning the time-step with SpecifiedTimes * Approx not exact * Resolve Manifest * Update CUDA
1 parent e7bbb1b commit 738d172

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

Manifest.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# This file is machine-generated - editing it directly is not advised
22

3-
julia_version = "1.10.3"
3+
julia_version = "1.10.0"
44
manifest_format = "2.0"
5-
project_hash = "04d395caf937b0921325a77873167e8baa293a99"
5+
project_hash = "8d5da80dd05814164ee23c791edd5549b032a426"
66

77
[[deps.AbstractFFTs]]
88
deps = ["LinearAlgebra"]
@@ -103,9 +103,9 @@ version = "0.1.3"
103103

104104
[[deps.CUDA]]
105105
deps = ["AbstractFFTs", "Adapt", "BFloat16s", "CEnum", "CUDA_Driver_jll", "CUDA_Runtime_Discovery", "CUDA_Runtime_jll", "Crayons", "DataFrames", "ExprTools", "GPUArrays", "GPUCompiler", "KernelAbstractions", "LLVM", "LLVMLoopInfo", "LazyArtifacts", "Libdl", "LinearAlgebra", "Logging", "NVTX", "Preferences", "PrettyTables", "Printf", "Random", "Random123", "RandomNumbers", "Reexport", "Requires", "SparseArrays", "StaticArrays", "Statistics"]
106-
git-tree-sha1 = "abc3c845165c2d5c03ab61754a90c7f7cff0f6a4"
106+
git-tree-sha1 = "6e945e876652f2003e6ca74e19a3c45017d3e9f6"
107107
uuid = "052768ef-5323-5732-b1bb-66c8b64840ba"
108-
version = "5.4.1"
108+
version = "5.4.2"
109109

110110
[deps.CUDA.extensions]
111111
ChainRulesCoreExt = "ChainRulesCore"
@@ -166,7 +166,7 @@ weakdeps = ["Dates", "LinearAlgebra"]
166166
[[deps.CompilerSupportLibraries_jll]]
167167
deps = ["Artifacts", "Libdl"]
168168
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
169-
version = "1.1.1+0"
169+
version = "1.0.5+1"
170170

171171
[[deps.ConstructionBase]]
172172
deps = ["LinearAlgebra"]
@@ -421,9 +421,9 @@ version = "0.2.1+0"
421421

422422
[[deps.KernelAbstractions]]
423423
deps = ["Adapt", "Atomix", "InteractiveUtils", "LinearAlgebra", "MacroTools", "PrecompileTools", "Requires", "SparseArrays", "StaticArrays", "UUIDs", "UnsafeAtomics", "UnsafeAtomicsLLVM"]
424-
git-tree-sha1 = "db02395e4c374030c53dc28f3c1d33dec35f7272"
424+
git-tree-sha1 = "d0448cebd5919e06ca5edc7a264631790de810ec"
425425
uuid = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
426-
version = "0.9.19"
426+
version = "0.9.22"
427427

428428
[deps.KernelAbstractions.extensions]
429429
EnzymeExt = "EnzymeCore"
@@ -650,7 +650,7 @@ weakdeps = ["Adapt"]
650650
[[deps.OpenBLAS_jll]]
651651
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
652652
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
653-
version = "0.3.23+4"
653+
version = "0.3.23+2"
654654

655655
[[deps.OpenLibm_jll]]
656656
deps = ["Artifacts", "Libdl"]

src/Utils/schedules.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,10 @@ end
187187

188188
initialize!(st::SpecifiedTimes, model) = st(model)
189189

190-
align_time_step(schedule::SpecifiedTimes, clock, Δt) = min(Δt, next_actuation_time(schedule) - clock.time)
190+
function schedule_aligned_time_step(schedule::SpecifiedTimes, clock, Δt)
191+
δt = next_actuation_time(schedule) - clock.time
192+
return min(Δt, δt)
193+
end
191194

192195
function specified_times_str(st)
193196
str_elems = ["$(prettytime(t)), " for t in st.times]
@@ -272,8 +275,9 @@ function (as::OrSchedule)(model)
272275
return any(actuations)
273276
end
274277

275-
align_time_step(any_or_all_schedule::Union{OrSchedule, AndSchedule}, clock, Δt) =
276-
minimum(align_time_step(clock, Δt, schedule) for schedule in any_or_all_schedule.schedules)
278+
schedule_aligned_time_step(any_or_all_schedule::Union{OrSchedule, AndSchedule}, clock, Δt) =
279+
minimum(schedule_aligned_time_step(schedule, clock, Δt)
280+
for schedule in any_or_all_schedule.schedules)
277281

278282
#####
279283
##### Show methods

test/test_schedules.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include("dependencies_for_runtests.jl")
22

33
using Oceananigans.Utils: TimeInterval, IterationInterval, WallTimeInterval, SpecifiedTimes
4+
using Oceananigans.Utils: schedule_aligned_time_step
45
using Oceananigans.TimeSteppers: Clock
56
using Oceananigans: initialize!
67

@@ -74,4 +75,9 @@ using Oceananigans: initialize!
7475
# Specified times includes iteration 0
7576
st = SpecifiedTimes(0, 2, 4)
7677
@test initialize!(st, fake_model_at_iter_0)
78+
79+
fake_clock = (; time=2.1)
80+
st = SpecifiedTimes(2.5)
81+
@test 0.4 schedule_aligned_time_step(st, fake_clock, Inf)
7782
end
83+

0 commit comments

Comments
 (0)