Skip to content
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

Fix type instability in slab_index and vindex #2004

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/ClimaCorePlots/src/ClimaCorePlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import TriplotBase

import ClimaComms
# Keep in sync with definition(s) in ClimaCore.DataLayouts.
@inline slab_index(i, j) = CartesianIndex(i, j, 1, 1, 1)
@inline slab_index(i) = CartesianIndex(i, 1, 1, 1, 1)
@inline slab_index(i::T, j::T) where {T} =
CartesianIndex(i, j, T(1), T(1), T(1))
@inline slab_index(i::T) where {T} = CartesianIndex(i, T(1), T(1), T(1), T(1))

import ClimaCore:
ClimaCore,
DataLayouts,
Expand Down
7 changes: 4 additions & 3 deletions lib/ClimaCoreTempestRemap/src/ClimaCoreTempestRemap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ export write_exodus, rll_mesh, overlap_mesh, remap_weights, apply_remap
export def_time_coord, def_space_coord

# Keep in sync with definition in DataLayouts.
@inline slab_index(i, j) = CartesianIndex(i, j, 1, 1, 1)
@inline slab_index(i) = CartesianIndex(i, 1, 1, 1, 1)
@inline vindex(v) = CartesianIndex(1, 1, 1, v, 1)
@inline slab_index(i::T, j::T) where {T} =
CartesianIndex(i, j, T(1), T(1), T(1))
@inline slab_index(i::T) where {T} = CartesianIndex(i, T(1), T(1), T(1), T(1))
@inline vindex(v::T) where {T} = CartesianIndex(T(1), T(1), T(1), v, T(1))

using ClimaComms
import ClimaCore
Expand Down
6 changes: 3 additions & 3 deletions src/DataLayouts/DataLayouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1107,9 +1107,9 @@ type parameters.
@inline farray_size(data::VIFH{S, Nv, Ni, Nh}) where {S, Nv, Ni, Nh} = (Nv, Ni, ncomponents(data), Nh)

# Keep in sync with definition(s) in libs.
@inline slab_index(i, j) = CartesianIndex(i, j, 1, 1, 1)
@inline slab_index(i) = CartesianIndex(i, 1, 1, 1, 1)
@inline vindex(v) = CartesianIndex(1, 1, 1, v, 1)
@inline slab_index(i::T, j::T) where {T} = CartesianIndex(i, j, T(1), T(1), T(1))
@inline slab_index(i::T) where {T} = CartesianIndex(i, T(1), T(1), T(1), T(1))
@inline vindex(v::T) where {T} = CartesianIndex(T(1), T(1), T(1), v, T(1))

"""
parent_array_type(data::AbstractData)
Expand Down
Loading