Skip to content

Commit

Permalink
KA without cuda backend (#670)
Browse files Browse the repository at this point in the history
* KA without cuda backend

* fix

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
wsmoses and github-actions[bot] authored Feb 1, 2025
1 parent e9471bd commit c2786dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ext/ReactantCUDAExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function threads_to_workgroupsize(threads, ndrange)
end
end

function (obj::KA.Kernel{ReactantBackend})(args...; ndrange=nothing, workgroupsize=nothing)
function ka_with_reactant(ndrange, workgroupsize, obj, args...)
backend = KA.backend(obj)

ndrange, workgroupsize, iterspace, dynamic = KA.launch_config(
Expand Down Expand Up @@ -325,6 +325,14 @@ function (obj::KA.Kernel{ReactantBackend})(args...; ndrange=nothing, workgroupsi
return nothing
end

Reactant.@reactant_overlay @noinline function (obj::KA.Kernel{ReactantBackend})(
args...; ndrange=nothing, workgroupsize=nothing
)
return Reactant.call_with_reactant(
ka_with_reactant, ndrange, workgroupsize, obj, args...
)
end

Adapt.adapt_storage(to::KA.ConstAdaptor, a::CuTracedArray) = Base.Experimental.Const(a)

function recudaconvert(arg)
Expand Down
8 changes: 8 additions & 0 deletions ext/ReactantKernelAbstractionsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,12 @@ function KA.priority!(::ReactantBackend, prio::Symbol)
return nothing
end

function tokw(ndrange, workgroupsize, obj, args...)
@inline obj(args...; ndrange, workgroupsize)
end

function (obj::KA.Kernel{ReactantBackend})(args...; ndrange=nothing, workgroupsize=nothing)
@jit tokw(ndrange, workgroupsize, obj, args...)
end

end

0 comments on commit c2786dd

Please sign in to comment.