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

Implement mapreduce #561

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Implement mapreduce #561

wants to merge 3 commits into from

Conversation

vchuravy
Copy link
Member

Ported from oneAPI.jl

  • Currentl limited to a static workgroupsize

@SimonDanisch
Copy link
Member

Could these things maybe live in https://github.com/anicusan/AcceleratedKernels.jl in the future ?
Seems like they put quite a bit of effort into fast, KernelAbstraction based array operations in there ;)

@vchuravy
Copy link
Member Author

Could these things maybe live in https://github.com/anicusan/AcceleratedKernels.jl in the future ?

There is a dependency ordering issue, GPUArrays is the common infrastructure and this is would be the fallback implementation for a common implementation. So GPUArrays would need to take a dependency on something like AcceleratedKernels.jl

@vchuravy
Copy link
Member Author

Of course JLArrays doesn't work.. That uses the CPU backend and this is cpu=false

@SimonDanisch
Copy link
Member

There is a dependency ordering issue

I was considering it as "leave it to AcceleratedKernels" to implement these. Well, it's a very young package, but I was wondering if it could be a path towards the future ;)

@leios
Copy link
Contributor

leios commented Sep 24, 2024

Just to write down my current understanding of the JLArray issue:

    while d < items
        @synchronize() # legal since cpu=false

Is not valid for the CPU in KA right now due to the synchronization within a while loop. This should be fine once we have a POCL backend for KA, so the "fix" for JLArrays in this PR is to wait for POCL.

GPU execution on all vendors should still work, and Arrays should have their own implementation somewhere else. It's just that the JLArray tests will fail for a bit here.

Comment on lines +278 to +289
# reduce_items = launch_configuration(kernel)
reduce_items = 512
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# reduce_items = launch_configuration(kernel)
reduce_items = 512
# reduce_items = compute_items(launch_configuration(kernel))
reduce_items = compute_items(512)

But also has to become dynamic, of course.

Comment on lines +301 to +319
# we need multiple steps to cover all values to reduce
partial = similar(R, (size(R)..., reduce_groups))
if init === nothing
# without an explicit initializer we need to copy from the output container
partial .= R
end
reduce_kernel(f, op, init, Val(items), Rreduce, Rother, partial, A; ndrange)

GPUArrays.mapreducedim!(identity, op, R′, partial; init=init)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a good time to add support for grid stride loops to KA.jl and handle this with a single kernel launch + atomic writes to global memory?

@maleadt maleadt force-pushed the tb/kernelabstractions branch 6 times, most recently from 7348bba to f418d7a Compare October 17, 2024 14:01
Base automatically changed from tb/kernelabstractions to master October 17, 2024 14:29
@maleadt maleadt changed the title Add kernelabstractions based mapreduce implementation Implement mapreduce Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants