Skip to content

Conversation

@michel2323
Copy link
Member

No description provided.

@michel2323 michel2323 requested a review from vchuravy December 4, 2025 19:40
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 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/src/oneAPIKernels.jl b/src/oneAPIKernels.jl
index 61f2b2d..1c78c70 100644
--- a/src/oneAPIKernels.jl
+++ b/src/oneAPIKernels.jl
@@ -19,11 +19,11 @@ struct oneAPIBackend <: KA.GPU
     always_inline::Bool
 end
 
-oneAPIBackend(; prefer_blocks=false, always_inline=false) = oneAPIBackend(prefer_blocks, always_inline)
+oneAPIBackend(; prefer_blocks = false, always_inline = false) = oneAPIBackend(prefer_blocks, always_inline)
 
-@inline KA.allocate(::oneAPIBackend, ::Type{T}, dims::Tuple; unified::Bool = false) where T = oneArray{T, length(dims), unified ? oneAPI.oneL0.SharedBuffer : oneAPI.oneL0.DeviceBuffer}(undef, dims)
-@inline KA.zeros(::oneAPIBackend, ::Type{T}, dims::Tuple; unified::Bool = false) where T = fill!(oneArray{T, length(dims), unified ? oneAPI.oneL0.SharedBuffer : oneAPI.oneL0.DeviceBuffer}(undef, dims), zero(T))
-@inline KA.ones(::oneAPIBackend, ::Type{T}, dims::Tuple; unified::Bool = false) where T = fill!(oneArray{T, length(dims), unified ? oneAPI.oneL0.SharedBuffer : oneAPI.oneL0.DeviceBuffer}(undef, dims), one(T))
+@inline KA.allocate(::oneAPIBackend, ::Type{T}, dims::Tuple; unified::Bool = false) where {T} = oneArray{T, length(dims), unified ? oneAPI.oneL0.SharedBuffer : oneAPI.oneL0.DeviceBuffer}(undef, dims)
+@inline KA.zeros(::oneAPIBackend, ::Type{T}, dims::Tuple; unified::Bool = false) where {T} = fill!(oneArray{T, length(dims), unified ? oneAPI.oneL0.SharedBuffer : oneAPI.oneL0.DeviceBuffer}(undef, dims), zero(T))
+@inline KA.ones(::oneAPIBackend, ::Type{T}, dims::Tuple; unified::Bool = false) where {T} = fill!(oneArray{T, length(dims), unified ? oneAPI.oneL0.SharedBuffer : oneAPI.oneL0.DeviceBuffer}(undef, dims), one(T))
 
 KA.get_backend(::oneArray) = oneAPIBackend()
 # TODO should be non-blocking
@@ -59,7 +59,7 @@ function KA.device(::oneAPIBackend)::Int
 end
 
 function KA.device!(backend::oneAPIBackend, id::Int)
-    oneAPI.device!(id)
+    return oneAPI.device!(id)
 end
 
 
@@ -121,7 +121,7 @@ function (obj::KA.Kernel{oneAPIBackend})(args...; ndrange=nothing, workgroupsize
         # maxthreads = nothing
     end
 
-    kernel = @oneapi launch=false always_inline=backend.always_inline obj.f(ctx, args...)
+    kernel = @oneapi launch = false always_inline = backend.always_inline obj.f(ctx, args...)
 
     # figure out the optimal workgroupsize automatically
     if KA.workgroupsize(obj) <: KA.DynamicSize && workgroupsize === nothing
@@ -137,9 +137,9 @@ function (obj::KA.Kernel{oneAPIBackend})(args...; ndrange=nothing, workgroupsize
             # (Simplified logic compared to CUDA.jl which uses explicit occupancy calculators)
             total_items = prod(ndrange)
             if total_items < items * 16 # Heuristic factor
-                 # Force at least a few blocks if possible by reducing items per block
-                 target_blocks = 16 # Target at least 16 blocks
-                 items = max(1, min(items, cld(total_items, target_blocks)))
+                # Force at least a few blocks if possible by reducing items per block
+                target_blocks = 16 # Target at least 16 blocks
+                items = max(1, min(items, cld(total_items, target_blocks)))
             end
         end
 
@@ -251,7 +251,8 @@ function KA.priority!(::oneAPIBackend, prio::Symbol)
     # Replace the queue in task_local_storage
     # The key used by global_queue is (:ZeCommandQueue, ctx, dev)
 
-    new_queue = oneAPI.oneL0.ZeCommandQueue(ctx, dev;
+    new_queue = oneAPI.oneL0.ZeCommandQueue(
+        ctx, dev;
         flags = oneAPI.oneL0.ZE_COMMAND_QUEUE_FLAG_IN_ORDER,
         priority = priority_enum
     )

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