Skip to content
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
2 changes: 1 addition & 1 deletion src/compiler/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ The following kwargs are supported:
target") and fall back to no limit, so pick the value per architecture. Negative
values throw an `ArgumentError`.
"""
function hipfunction(f::F, tt::TT = Tuple{}; kwargs...) where {F <: Core.Function, TT}
function hipfunction(f::F, tt::TT = Tuple{}; kwargs...) where {F, TT}
kw = values(kwargs)
dev = AMDGPU.device()
fun = GPUCompiler.cached_lookup(HIP.HIPFunction, F, tt, (dev, kw)) do
Expand Down
18 changes: 18 additions & 0 deletions test/device/launch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,25 @@ end
@test Array(map(x -> x[1] + x[2] + x[3], ROCArray(xs))) == map(x -> x[1] + x[2] + x[3], xs)
end

# a callable object used as a kernel
struct StoreValue
val::Float64
end
function (f::StoreValue)(a)
a[1] = f.val
return
end

@testset "Function/Argument Conversion" begin
@testset "Callable object as kernel" begin
a_dev = ROCArray([1.0])
@roc StoreValue(2.0)(a_dev)
@test Array(a_dev) == [2.0]
# reuses the compiled kernel, with the new instance's state
@roc StoreValue(3.0)(a_dev)
@test Array(a_dev) == [3.0]
end

@testset "Closure as Argument" begin
function kernel(closure)
closure()
Expand Down
Loading