Skip to content

Commit e0117cf

Browse files
Fix Type argument reconstruction in @device_code_* reflection (#184)
Co-authored-by: Tim Besard <tim.besard@gmail.com>
1 parent 9fcbc50 commit e0117cf

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/compiler/driver.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function emit_structured!(cache::CacheView, mi::Core.MethodInstance;
224224
for i in eachindex(arg_types)
225225
if const_argtypes[i+1] isa CC.Const
226226
val = const_argtypes[i+1].val
227-
arg_types[i] = Constant{typeof(val), val}
227+
arg_types[i] = typeof(Constant(val))
228228
end
229229
end
230230
end

test/device/core.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,29 @@ end # invalidations
237237
end
238238
@test Array(c2) Array(a) + Array(b)
239239

240+
# @device_code_tiled with Type argument
241+
# Regression: compile hook reconstructed Constant{typeof(val), val} for Type
242+
# arguments, producing Constant{DataType, T} instead of Constant{Type{T}, T}
243+
# and failing with "requires a dispatch tuple, got non-concrete signature".
244+
function reflect_type_vadd(a::ct.TileArray{Float32,1}, b::ct.TileArray{Float32,1},
245+
c::ct.TileArray{Float32,1}, ::Type{T}) where T
246+
pid = ct.bid(1)
247+
tile_a = ct.load(a, pid, (16,))
248+
tile_b = ct.load(b, pid, (16,))
249+
ct.store(c, pid, tile_a + tile_b + zeros(T, (16,)))
250+
return
251+
end
252+
253+
c3 = CUDA.zeros(Float32, n)
254+
@test @filecheck begin
255+
@check "entry @reflect_type_vadd"
256+
@check "load_view"
257+
@check "addf"
258+
@check "store_view"
259+
ct.@device_code_tiled ct.launch(reflect_type_vadd, cld(n, 16), a, b, c3, Float32)
260+
end
261+
@test Array(c3) Array(a) + Array(b)
262+
240263
# @device_code_tiled with reduce subprogram
241264
# Regression: compile hook tried to compile the reduce combiner (e.g. +) as a
242265
# standalone entry, which cuda-tile-translate rejects.

0 commit comments

Comments
 (0)