Skip to content

Commit

Permalink
Merge pull request #2158 from CliMA/ck/fix_2146
Browse files Browse the repository at this point in the history
Allow for re-instantiating field-style broadcasted objects
  • Loading branch information
charleskawczynski authored Jan 24, 2025
2 parents 75bf60d + 2566ad6 commit bbad885
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 32 deletions.
2 changes: 1 addition & 1 deletion benchmarks/scripts/benchmark_utils.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# import CUDA
import ClimaComms
using BenchmarkTools, Dates
using ClimaCore: @lazy
import LazyBroadcast: @lazy

"""
caller_name(@__FILE__)
Expand Down
3 changes: 0 additions & 3 deletions src/ClimaCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ using PkgVersion
const VERSION = PkgVersion.@Version
import ClimaComms

# Temporary helpers to work around https://github.com/CliMA/ClimaCore.jl/issues/2146
include("lazy_broadcast.jl")

include("DebugOnly/DebugOnly.jl")
include("interface.jl")
include("devices.jl")
Expand Down
4 changes: 3 additions & 1 deletion src/Operators/finitedifference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ function Base.Broadcast.instantiate(sbc::StencilBroadcasted)
axes = Base.axes(sbc)
else
axes = sbc.axes
Base.Broadcast.check_broadcast_axes(axes, args...)
if axes !== Base.axes(sbc)
Base.Broadcast.check_broadcast_axes(axes, args...)
end
end
Style = AbstractStencilStyle(ClimaComms.device(axes))
return StencilBroadcasted{Style}(op, args, axes)
Expand Down
4 changes: 3 additions & 1 deletion src/Operators/spectralelement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ function Base.Broadcast.instantiate(sbc::SpectralBroadcasted)
axes = Base.axes(sbc)
else
axes = sbc.axes
Base.Broadcast.check_broadcast_axes(axes, args...)
if axes !== Base.axes(sbc)
Base.Broadcast.check_broadcast_axes(axes, args...)
end
end
op = typeof(op)(axes)
Style = AbstractSpectralStyle(ClimaComms.device(axes))
Expand Down
20 changes: 0 additions & 20 deletions src/lazy_broadcast.jl

This file was deleted.

5 changes: 2 additions & 3 deletions test/DataLayouts/unit_has_uniform_datalayouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using Test
using ClimaCore.DataLayouts
import ClimaCore.Geometry
import ClimaComms
import ClimaCore: @lazy
import LazyBroadcast: @lazy
using StaticArrays
import Random
Random.seed!(1234)
Expand Down Expand Up @@ -41,6 +41,5 @@ Random.seed!(1234)
# This is not a valid broadcast expression,
# but these two datalayouts can exist in a
# valid broadcast expression (e.g., interpolation).
bc = @lazy @. data_VIJFHᶜ + data_VIJFHᶠ
@test DataLayouts.has_uniform_datalayouts(bc)
@test_throws DimensionMismatch @lazy @. data_VIJFHᶜ + data_VIJFHᶠ
end
2 changes: 1 addition & 1 deletion test/DataLayouts/unit_linear_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using ClimaComms
ClimaComms.@import_required_backends
import ClimaCore: Domains, Meshes, Topologies, Spaces, Fields, Operators
import ClimaCore.DataLayouts: get_struct
using ClimaCore: @lazy
import LazyBroadcast: @lazy

Random.seed!(1234)

Expand Down
2 changes: 1 addition & 1 deletion test/DataLayouts/unit_non_extruded_broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Revise; include(joinpath("test", "DataLayouts", "unit_non_extruded_broadca
using Test
using ClimaComms
import Base.Broadcast: broadcasted, instantiate
using ClimaCore: @lazy
import LazyBroadcast: @lazy
using ClimaCore.DataLayouts
using ClimaCore.Geometry
using ClimaCore: Geometry, Domains, Topologies, Meshes, Spaces, Fields
Expand Down
2 changes: 1 addition & 1 deletion test/MatrixFields/matrix_field_test_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using JET
import Dates
import Random: seed!
import Base.Broadcast: materialize, materialize!
import ClimaCore: @lazy
import LazyBroadcast: @lazy
import BenchmarkTools as BT

import ClimaComms
Expand Down

0 comments on commit bbad885

Please sign in to comment.