From 8adc3de24316757b03cad0a2ec5e2bfc925f7395 Mon Sep 17 00:00:00 2001 From: William Moses Date: Fri, 31 Jan 2025 21:12:49 -0600 Subject: [PATCH] Update ReactantCUDAExt.jl --- ext/ReactantCUDAExt.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ext/ReactantCUDAExt.jl b/ext/ReactantCUDAExt.jl index ea60f2507..6256fa7bb 100644 --- a/ext/ReactantCUDAExt.jl +++ b/ext/ReactantCUDAExt.jl @@ -263,6 +263,15 @@ function Adapt.adapt_structure( ) end +function threads_to_workgroupsize(threads, ndrange) + total = 1 + return map(ndrange) do n + x = min(div(threads, total), n) + total *= x + return x + end +end + function (obj::KA.Kernel{ReactantBackend})(args...; ndrange=nothing, workgroupsize=nothing) backend = KA.backend(obj)