Skip to content

Conversation

christiangnrd
Copy link
Member

@christiangnrd christiangnrd commented Sep 30, 2025

JLArrays support done in this way to keep lack of support for scalar indexing.

KA 0.9 support can be easily reverted if not desired

Replaces and closes #595

Copy link
Contributor

github-actions bot commented Sep 30, 2025

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/lib/JLArrays/src/JLArrays.jl b/lib/JLArrays/src/JLArrays.jl
index 4b238fa..3a3d1e3 100644
--- a/lib/JLArrays/src/JLArrays.jl
+++ b/lib/JLArrays/src/JLArrays.jl
@@ -57,7 +57,7 @@ Adapt.adapt_structure(to::Adaptor, r::Base.RefValue) = JlRefValue(adapt(to, r[])
     Base.sizeof(x::JLDeviceArray) = Base.elsize(x) * length(x)
 
     Base.unsafe_convert(::Type{Ptr{T}}, x::JLDeviceArray{T}) where {T} =
-        convert(Ptr{T}, pointer(x.data)) + x.offset*Base.elsize(x)
+        convert(Ptr{T}, pointer(x.data)) + x.offset * Base.elsize(x)
 
     # conversion of untyped data to a typed Array
     function typed_data(x::JLDeviceArray{T}) where {T}
@@ -340,10 +340,10 @@ end
 ## GPUArrays interfaces
 
 @static if !isdefined(JLArrays.KernelAbstractions, :POCL) # KA v0.9
-    Adapt.adapt_storage(::Adaptor, x::JLArray{T,N}) where {T,N} =
-      JLDeviceArray{T,N}(x.data[], x.offset, x.dims)
+    Adapt.adapt_storage(::Adaptor, x::JLArray{T, N}) where {T, N} =
+        JLDeviceArray{T, N}(x.data[], x.offset, x.dims)
 else
-    function Adapt.adapt_storage(::Adaptor, x::JLArray{T,N}) where {T,N}
+    function Adapt.adapt_storage(::Adaptor, x::JLArray{T, N}) where {T, N}
         arr = typed_data(x)
         Adapt.adapt_storage(POCL.KernelAdaptor([pointer(arr)]), arr)
     end

@maleadt
Copy link
Member

maleadt commented Oct 2, 2025

Conceptually fine, but CI doesn't look happy. CUDA.jl failure is unrelated, though.
cc @vchuravy

@christiangnrd
Copy link
Member Author

This is ready for final review. I added tests to KA main branch to confirm that this works for both KA 0.9 and 0.10. I don't know if that should stay, and it seems like Windows CI fails with KA 0.10. Not sure if that's my fault or not.

@christiangnrd
Copy link
Member Author

I wasn't able to reproduce the Windows failure locally, so I still don't understand what's happening, but I got JuliaGPU/KernelAbstractions.jl#638 out of it so not a total waste of time.

@maleadt maleadt merged commit 129fb5b into JuliaGPU:master Oct 6, 2025
19 checks passed
@christiangnrd christiangnrd deleted the ka10 branch October 6, 2025 16:05
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