CliMA / Oceananigans.jl

🌊 Julia software for fast, friendly, flexible, ocean-flavored fluid dynamics on CPUs and GPUs
https://clima.github.io/OceananigansDocumentation/stable
MIT License
1k stars 196 forks source link

`set!` between `FieldTimeSeries` and `Field` #2783

Open simone-silvestri opened 2 years ago

simone-silvestri commented 2 years ago

on the GPU it is not possible to set a Field from an element of a FieldTimeSeries correctly because for a (non-halo) FieldTimeSeries field parent(field) == interior(field).

Then set! which should set the parent, displaces by the halos the data in the output field (u in this case)

u_parent = parent(u)
v_parent = parent(v)
# If u_parent is a view, we have to convert to an Array.
# If u_parent or v_parent is on the GPU, we don't expect
# SubArray.
u_parent isa SubArray && (u_parent = Array(u_parent))
v_parent isa SubArray && (v_parent = Array(v_parent))
copyto!(u_parent, v_parent) # Here u_parent and v_parent have different sizes!!! u_parent has halos, v_parent does not
glwagner commented 2 years ago

Can you link to the relevant code? Do we just need to fallback to field .= field_time_series[n] somehow?

simone-silvestri commented 2 years ago

We have to make sure that u_parent and v_parent have the same size here.

https://github.com/CliMA/Oceananigans.jl/blob/c8c5aed63c879eef00f33a61029e95ec9ff920b1/src/Fields/set!.jl#L49-L58

glwagner commented 1 year ago

Is this still an issue? Maybe an MWE would help then we can address it