Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept static sizes as keyword arguments #570

Open
maleadt opened this issue Feb 17, 2025 · 2 comments
Open

Accept static sizes as keyword arguments #570

maleadt opened this issue Feb 17, 2025 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@maleadt
Copy link
Member

maleadt commented Feb 17, 2025

Kernel closures support passing ndrange and workgroupsize as keyword arguments:

(kernel::Kernel{<:NewBackend})(args...; ndrange=nothing, workgroupsize=nothing)

The kernel function itself probably should too, while it currently only accepts positional versions of these arguments (used to construct static sizes):

function $name(dev::Dev, sz::S, range::NDRange) where {Dev, S <: $_Size, NDRange <: $_Size}
return $construct(dev, sz, range, $gpu_name)
end

IMO this makes the code more readable.

@vchuravy vchuravy added enhancement New feature or request good first issue Good for newcomers labels Feb 26, 2025
@Komal0103
Copy link

Komal0103 commented Mar 31, 2025

Hello @maleadt . This might be a novice question, but here we go. I tried solving this by adding the following

function $name(dev::Dev, sz::Union{S, Nothing}=$nothing, range::Union{NDRange, Nothing}=nothing) where {S <: $_Size, NDRange <: $_Size, Dev}
                return $construct(dev, sz, range, $gpu_name)
end

I keep getting the same error.
ERROR: Method overwriting is not permitted during Module precompilation. Use __precompile__(false) to opt-out of precompilation.

I tried searching through a lot of resources, but couldn't find any working solutions. I would appreciate any help to understand this problem.
Thank you in advance!

@maleadt
Copy link
Member Author

maleadt commented Apr 1, 2025

Method overwriting is not permitted during Module precompilation.

Are you defining those methods from the REPL? You have to dev the package and edit its sources.

There's several topics on this error on Discourse, so I'd recommend reading those for some more insights.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants