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

Initial KernelAbstractions.jl integration. #233

Merged
merged 6 commits into from
Sep 17, 2024
Merged

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Sep 13, 2024

Demo:

using Test
using OpenCL, pocl_jll
using KernelAbstractions, OpenCL.OpenCLKernels

backend = OpenCLBackend()

@kernel function copy_kernel!(A, @Const(B))
    I = @index(Global)
    @inbounds A[I] = B[I]
end

function mycopy!(A, B)
    backend = get_backend(A)
    @assert size(A) == size(B)
    @assert get_backend(B) == backend

    kernel = copy_kernel!(backend)
    kernel(A, B, ndrange = length(A))
end

A = KernelAbstractions.zeros(backend, Float64, 128, 128)
B = KernelAbstractions.ones(backend, Float64, 128, 128)
mycopy!(A, B)
KernelAbstractions.synchronize(backend)
@test A == B
julia> @test A == B
Test Passed

cc @vchuravy

Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 60.97561% with 32 lines in your changes missing coverage. Please review.

Project coverage is 72.72%. Comparing base (daaf3cf) to head (d677ee2).

Files with missing lines Patch % Lines
src/OpenCLKernels.jl 61.03% 30 Missing ⚠️
src/array.jl 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #233      +/-   ##
==========================================
+ Coverage   71.60%   72.72%   +1.12%     
==========================================
  Files           7        8       +1     
  Lines         324      407      +83     
==========================================
+ Hits          232      296      +64     
- Misses         92      111      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vchuravy
Copy link
Member

Excellent!

@vchuravy
Copy link
Member

The last can of worms is probably atomics...

@maleadt
Copy link
Member Author

maleadt commented Sep 13, 2024

Hopefully that shouldn't too hard, I have them wrapped already from oneAPI.jl: https://github.com/JuliaGPU/OpenCL.jl/blob/master/lib/intrinsics/src/atomic.jl
How do these need to be hooked up to KA.jl?

EDIT: Atomix.jl apparently, so I guess this is a matter of duplicating https://github.com/JuliaConcurrent/Atomix.jl/tree/main/lib/AtomixCUDA

@maleadt maleadt marked this pull request as draft September 13, 2024 14:01
@maleadt maleadt marked this pull request as ready for review September 17, 2024 14:38
@maleadt maleadt merged commit 9c1db8b into master Sep 17, 2024
5 checks passed
@maleadt maleadt deleted the tb/kernelabstractions branch September 17, 2024 14:52
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.

2 participants