Skip to content

Commit d0a9f9d

Browse files
Merge pull request #2076 from CliMA/ck/demo_gpu_inference_fix
Demonstrate gpu inference fix
2 parents cc2113d + 43fb6ba commit d0a9f9d

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

test/Fields/inference_repro.jl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@ import ClimaComms
44
ClimaComms.@import_required_backends
55
import ClimaCore: Fields, Domains, Geometry, Meshes, Spaces
66

7+
macro ConstantValue(T)
8+
quote
9+
Base.broadcastable(x::$T) = x
10+
Base.axes(x::$T) = ()
11+
Base.getindex(x::$T, i...) = x
12+
Base.getindex(x::$T, i) = x
13+
Base.ndims(x::Type{<:$T}) = 0
14+
end
15+
end
16+
717
struct LandParameters{FT}
818
ρ_cloud_ice::FT
919
end
10-
Base.broadcastable(x::LandParameters) = tuple(x)
20+
@ConstantValue LandParameters
1121

1222
struct vanGenuchten{FT}
1323
α::FT
1424
end
15-
Base.broadcastable(x::vanGenuchten) = tuple(x)
25+
@ConstantValue vanGenuchten
1626

1727
function phase_change_source(
1828
θ_l::FT,
@@ -64,16 +74,5 @@ end
6474

6575
using Test
6676
@testset "GPU inference failure" begin
67-
if ClimaComms.device() isa ClimaComms.CUDADevice
68-
@test_broken try
69-
main(Float64)
70-
true
71-
catch e
72-
@assert occursin("GPUCompiler.InvalidIRError", string(e))
73-
@assert occursin("dynamic function invocation", e.errors[1][1])
74-
false
75-
end
76-
else
77-
main(Float64)
78-
end
77+
main(Float64)
7978
end

0 commit comments

Comments
 (0)