-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set a default Clock depending on the grid #4096
Conversation
I believe this is our error now: Reactant Super Simple Simulation Tests: Error During Test at /Users/gregorywagner/Projects/dev/OC1.jl/test/test_reactant.jl:154
Got exception outside of a @test
MethodError: no method matching rem(::Reactant.TracedRNumber{Int64}, ::Int64)
Closest candidates are:
rem(::Any, ::Any, ::RoundingMode{:FromZero})
@ Base div.jl:103
rem(::Any, ::Any, ::RoundingMode{:Nearest})
@ Base div.jl:100
rem(::Any, ::Any, ::RoundingMode{:Up})
@ Base div.jl:99
...
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/Reactant/qEA3Y/src/utils.jl:0 [inlined]
[2] call_with_reactant(::typeof(rem), ::Reactant.TracedRNumber{Int64}, ::Int64)
@ Reactant ~/.julia/packages/Reactant/qEA3Y/src/utils.jl:767
[3] IterationInterval
@ ~/Projects/dev/OC1.jl/src/Utils/schedules.jl:109 [inlined] @wsmoses can we add support for |
@giordano @wsmoses I'm hitting a road block and trying to figure out what is going wrong. I put together a very simple prototype of a function that iterates until a stopping criteria: using Reactant
mutable struct TestClock{I}
iteration :: I
end
mutable struct Stopper{I}
iteration :: I
end
function iterate_until!(clock, stopper)
iterate = true
while iterate
@trace if clock.iteration >= stopper.iteration
iterate = false
else
clock.iteration += 1
end
end
return nothing
end
clock = TestClock(ConcreteRNumber(0))
#stopper = Stopper(ConcreteRNumber(2))
stopper = Stopper(2)
r_iterate! = @compile sync=true iterate_until!(clock, stopper)
r_iterate!(clock, stopper)
@show clock.iteration This fails with ERROR: LoadError: TypeError: non-boolean (Reactant.TracedRNumber{Bool}) used in boolean context
Stacktrace:
[1] macro expansion
@ ~/.julia/packages/ReactantCore/t40zc/src/ReactantCore.jl:378 [inlined]
[2] iterate_until!
@ ~/Projects/Oceananigans.jl/test/test_reactant.jl:31 [inlined]
[3] iterate_until!(none::TestClock{Reactant.TracedRNumber{Int64}}, none::Stopper{Int64})
@ Reactant ./<missing>:0
[4] iterate_until!
@ ~/Projects/Oceananigans.jl/test/test_reactant.jl:30 [inlined] where line 31 is I'm also wondering whether the I think getting this prototype to work will show me how to get this PR merged |
Couple issues open to work on stuff that's come up: |
@giordano I think we've made progress on this and now ![]() |
Note running the tests requires adding using TestEnv; TestEnv.activate()
using Pkg; Pkg.add("Reactant", rev="glw-wm/traced-set-path")
include("test/test_reactant.jl") |
…igans.jl into glw/arch-dep-clock
This is ready and tests will hopefully pass soon @wsmoses @simone-silvestri @giordano . I've updated the top post to describe what we've done. |
This PR adds a constructor for
Clock
which depends ongrid
, and therefore architecture. This allows the clock to be traced when usingarch = ReactantState()
.In addition to that, this PR discontinues support for
run!
witharch = ReactantState()
. Our rationale is that we cannot yet support theSimulation
paradigm, which executes time-steps in awhile
loop until!(simulation.running)
, wheresimulation.running
is typically controlled byif
statements that depend, for example, onclock.iteration
. Basically we're deciding not to try to use@trace if
, yet.As a result, time step loops with
Reactant
should be managed manually. To facilitate this, this PR also adds a functionfirst_time_step!
which firstinitialize!(model)
andupdate_state!(model)
before taking a time-step (which is limited to Euler step for AB2).cc @giordano