Skip to content

Commit d59ac82

Browse files
Reduce latency in stencil operators
1 parent 6279ea4 commit d59ac82

File tree

8 files changed

+3712
-278
lines changed

8 files changed

+3712
-278
lines changed

.buildkite/Manifest.toml

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

3-
julia_version = "1.10.8"
3+
julia_version = "1.10.9"
44
manifest_format = "2.0"
55
project_hash = "6ab89829ea190189b0319a6f8e22b3515e5283c2"
66

@@ -327,7 +327,7 @@ weakdeps = ["CUDA", "MPI"]
327327
ClimaCommsMPIExt = "MPI"
328328

329329
[[deps.ClimaCore]]
330-
deps = ["Adapt", "BandedMatrices", "BlockArrays", "ClimaComms", "CubedSphere", "DataStructures", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LinearAlgebra", "MultiBroadcastFusion", "NVTX", "PkgVersion", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "StaticArrays", "Statistics", "UnrolledUtilities"]
330+
deps = ["Adapt", "BandedMatrices", "BlockArrays", "ClimaComms", "CubedSphere", "DataStructures", "ForwardDiff", "GaussQuadrature", "GilbertCurves", "HDF5", "InteractiveUtils", "IntervalSets", "KrylovKit", "LinearAlgebra", "MultiBroadcastFusion", "NVTX", "PkgVersion", "PrecompileTools", "RecursiveArrayTools", "RootSolvers", "SparseArrays", "StaticArrays", "Statistics", "UnrolledUtilities"]
331331
path = ".."
332332
uuid = "d414da3d-4745-48bb-8d80-42e94e092884"
333333
version = "0.14.26"
@@ -1538,7 +1538,7 @@ version = "0.3.23+4"
15381538
[[deps.OpenLibm_jll]]
15391539
deps = ["Artifacts", "Libdl"]
15401540
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
1541-
version = "0.8.1+2"
1541+
version = "0.8.1+4"
15421542

15431543
[[deps.OpenMPI_jll]]
15441544
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2121
MultiBroadcastFusion = "c3c07f87-98de-43f2-a76f-835b330b2cbb"
2222
NVTX = "5da4648a-3479-48b8-97b9-01cb529c0a1f"
2323
PkgVersion = "eebad327-c553-4316-9ea0-9fa01ccd7688"
24+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2425
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
2526
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
2627
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

src/ClimaCore.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ include("CommonSpaces/CommonSpaces.jl")
2929

3030
include("deprecated.jl")
3131
include("to_device.jl")
32+
include("precompile.jl")
3233

3334
end # module

src/DataLayouts/struct.jl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ Base.@propagate_inbounds @generated function get_struct(
179179
::Val{D},
180180
start_index::CartesianIndex,
181181
) where {T, S, D}
182+
# recursion base case: hit array type is the same as the struct leaf type
183+
if T === S # Use Union-splitting for better latency
184+
return quote
185+
Base.@_propagate_inbounds_meta
186+
@inbounds return array[start_index]
187+
end
188+
end
182189
tup = :(())
183190
for i in 1:fieldcount(S)
184191
push!(
@@ -201,16 +208,6 @@ Base.@propagate_inbounds @generated function get_struct(
201208
end
202209
end
203210

204-
# recursion base case: hit array type is the same as the struct leaf type
205-
Base.@propagate_inbounds function get_struct(
206-
array::AbstractArray{S},
207-
::Type{S},
208-
::Val{D},
209-
start_index::CartesianIndex,
210-
) where {S, D}
211-
@inbounds return array[start_index]
212-
end
213-
214211
"""
215212
set_struct!(array, val::S, Val(D), start_index)
216213

0 commit comments

Comments
 (0)