Skip to content

Commit

Permalink
Demonstrate gpu inference fix
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Nov 6, 2024
1 parent a093d4a commit 7b68c99
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions test/Fields/inference_repro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@ import ClimaComms
ClimaComms.@import_required_backends
import ClimaCore: Fields, Domains, Geometry, Meshes, Spaces

macro ConstantValue(T)
quote
Base.broadcastable(x::$T) = x
Base.axes(x::$T) = ()
Base.getindex(x::$T, i...) = x
Base.getindex(x::$T, i) = x
Base.ndims(x::Type{<:$T}) = 0
end
end

struct LandParameters{FT}
ρ_cloud_ice::FT
end
Base.broadcastable(x::LandParameters) = tuple(x)
@ConstantValue LandParameters

struct vanGenuchten{FT}
α::FT
end
Base.broadcastable(x::vanGenuchten) = tuple(x)
@ConstantValue vanGenuchten

function phase_change_source(
θ_l::FT,
Expand Down Expand Up @@ -64,16 +74,5 @@ end

using Test
@testset "GPU inference failure" begin
if ClimaComms.device() isa ClimaComms.CUDADevice
@test_broken try
main(Float64)
true
catch e
@assert occursin("GPUCompiler.InvalidIRError", string(e))
@assert occursin("dynamic function invocation", e.errors[1][1])
false
end
else
main(Float64)
end
main(Float64)
end

0 comments on commit 7b68c99

Please sign in to comment.