-
Notifications
You must be signed in to change notification settings - Fork 30
Add sorting, sparse constructor, and device ownership #534
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
Open
michel2323
wants to merge
1
commit into
master
Choose a base branch
from
ms/sorting
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/lib/mkl/wrappers_sparse.jl b/lib/mkl/wrappers_sparse.jl
index 3f8b0bb..bb17907 100644
--- a/lib/mkl/wrappers_sparse.jl
+++ b/lib/mkl/wrappers_sparse.jl
@@ -1,5 +1,5 @@
function sparse_release_matrix_handle(A::oneAbstractSparseMatrix)
- if A.handle !== nothing
+ return if A.handle !== nothing
try
queue = global_queue(context(A.nzVal), device(A.nzVal))
handle_ptr = Ref{matrix_handle_t}(A.handle)
@@ -8,7 +8,7 @@ function sparse_release_matrix_handle(A::oneAbstractSparseMatrix)
synchronize(queue)
catch err
# Don't let finalizer errors crash the program
- @warn "Error releasing sparse matrix handle" exception=err
+ @warn "Error releasing sparse matrix handle" exception = err
end
end
end
@@ -117,10 +117,10 @@ for (fname, elty, intty) in ((:onemklSsparse_set_coo_data , :Float32 , :Int3
queue = global_queue(context(nzVal), device(nzVal))
if m != 0 && n != 0
$fname(sycl_queue(queue), handle_ptr[], m, n, nnzA, 'O', rowInd, colInd, nzVal)
- dA = oneSparseMatrixCOO{$elty, $intty}(handle_ptr[], rowInd, colInd, nzVal, (m,n), nnzA)
+ dA = oneSparseMatrixCOO{$elty, $intty}(handle_ptr[], rowInd, colInd, nzVal, (m, n), nnzA)
finalizer(sparse_release_matrix_handle, dA)
else
- dA = oneSparseMatrixCOO{$elty, $intty}(nothing, rowInd, colInd, nzVal, (m,n), nnzA)
+ dA = oneSparseMatrixCOO{$elty, $intty}(nothing, rowInd, colInd, nzVal, (m, n), nnzA)
end
return dA
end
diff --git a/src/array.jl b/src/array.jl
index d576cdb..3225b5e 100644
--- a/src/array.jl
+++ b/src/array.jl
@@ -279,8 +279,9 @@ end
## interop with GPU arrays
-function Base.unsafe_convert(::Type{oneDeviceArray{T,N,AS.CrossWorkgroup}}, a::oneArray{T,N}) where {T,N}
- oneDeviceArray{T,N,AS.CrossWorkgroup}(size(a), reinterpret(LLVMPtr{T,AS.CrossWorkgroup}, pointer(a)),
+function Base.unsafe_convert(::Type{oneDeviceArray{T, N, AS.CrossWorkgroup}}, a::oneArray{T, N}) where {T, N}
+ return oneDeviceArray{T, N, AS.CrossWorkgroup}(
+ size(a), reinterpret(LLVMPtr{T, AS.CrossWorkgroup}, pointer(a)),
a.maxsize - a.offset*Base.elsize(a))
end
diff --git a/src/broadcast.jl b/src/broadcast.jl
index 58a30dd..f9d38f6 100644
--- a/src/broadcast.jl
+++ b/src/broadcast.jl
@@ -11,9 +11,9 @@ BroadcastStyle(W::Type{<:oneWrappedArray{T, N}}) where {T, N} =
# when we are dealing with different buffer styles, we cannot know
# which one is better, so use shared memory
BroadcastStyle(
- ::oneArrayStyle{N, B1},
- ::oneArrayStyle{N, B2},
- ) where {N,B1,B2} =
+ ::oneArrayStyle{N, B1},
+ ::oneArrayStyle{N, B2},
+) where {N, B1, B2} =
oneArrayStyle{N, oneL0.SharedBuffer}()
# allocation of output arrays
diff --git a/src/compiler/execution.jl b/src/compiler/execution.jl
index 6503a9b..4900e77 100644
--- a/src/compiler/execution.jl
+++ b/src/compiler/execution.jl
@@ -88,7 +88,7 @@ Adapt.adapt_storage(to::KernelAdaptor, p::ZePtr{T}) where {T} = reinterpret(Ptr{
# convert oneAPI host arrays to device arrays
Adapt.adapt_storage(::KernelAdaptor, xs::oneArray{T,N}) where {T,N} =
- Base.unsafe_convert(oneDeviceArray{T,N,AS.CrossWorkgroup}, xs)
+ Base.unsafe_convert(oneDeviceArray{T, N, AS.CrossWorkgroup}, xs)
# Base.RefValue isn't GPU compatible, so provide a compatible alternative.
# TODO: port improvements from CUDA.jl
diff --git a/src/indexing.jl b/src/indexing.jl
index d46c67b..13d1947 100644
--- a/src/indexing.jl
+++ b/src/indexing.jl
@@ -26,9 +26,9 @@ function Base.findall(bools::oneArray{Bool})
ys = oneArray{I}(undef, n)
if n > 0
- kernel = @oneapi launch=false _ker!(ys, bools, indices)
+ kernel = @oneapi launch = false _ker!(ys, bools, indices)
group_size = launch_configuration(kernel)
- kernel(ys, bools, indices; items=group_size, groups=cld(length(bools), group_size))
+ kernel(ys, bools, indices; items = group_size, groups = cld(length(bools), group_size))
end
# unsafe_free!(indices)
diff --git a/test/device/intrinsics.jl b/test/device/intrinsics.jl
index 5e5605e..e1991fd 100644
--- a/test/device/intrinsics.jl
+++ b/test/device/intrinsics.jl
@@ -226,7 +226,7 @@ end
s[t] = d[t]
s2[t] = 2*d[t]
- barrier(0)
+ barrier(0)
d[t] = s[tr]
return
@@ -252,7 +252,7 @@ end
s[t] = d[t]
s2[t] = d[t]
- barrier(0)
+ barrier(0)
d[t] = s[tr]
return
diff --git a/test/execution.jl b/test/execution.jl
index cd3db01..78f87d6 100644
--- a/test/execution.jl
+++ b/test/execution.jl
@@ -307,12 +307,12 @@ end
@oneapi kernel(arr)
@test Array(arr)[] == 1
- function kernel2(ptr)
+ function kernel2(ptr)
ptr[] = 2
return
end
- @oneapi kernel2(arr)
+ @oneapi kernel2(arr)
@test Array(arr)[] == 2
end
|
amontoison
reviewed
Sep 26, 2025
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #534 +/- ##
==========================================
+ Coverage 79.10% 79.21% +0.10%
==========================================
Files 47 48 +1
Lines 3001 3021 +20
==========================================
+ Hits 2374 2393 +19
- Misses 627 628 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
570e801 to
5c833a7
Compare
80d24c2 to
47c3ff7
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
sort!andsortpermdevice(x)ownership in global queue calls of MKLoneSparseMatrixCSR(rowptr, colptr, nzval, dims)constructor