Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ version = "0.10.10"
projects = ["lib/intrinsics", "test", "docs", "res"]

[deps]
AcceleratedKernels = "6a4ca0a5-0e36-4168-a932-d9be78d558f1"
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7"
GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55"
Expand All @@ -29,6 +30,7 @@ spirv2clc_jll = "f0274c0c-8c8a-59f1-85b7-f7d60330c5fb"
SPIRVIntrinsics = {path = "lib/intrinsics"}

[compat]
AcceleratedKernels = "0.3.1, 0.4"
Adapt = "4"
GPUArrays = "11.2.1"
GPUCompiler = "2"
Expand Down
4 changes: 4 additions & 0 deletions src/OpenCL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using Random
using Preferences

import KernelAbstractions: KernelAbstractions
import AcceleratedKernels as AK

using Core: LLVMPtr

Expand Down Expand Up @@ -50,4 +51,7 @@ include("random.jl")
include("OpenCLKernels.jl")
import .OpenCLKernels: OpenCLBackend
export OpenCLBackend

include("sorting.jl")
include("accumulate.jl")
end
21 changes: 21 additions & 0 deletions src/accumulate.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Use a smaller block size to work around a scan correctness issue
# with the Blelloch parallel prefix sum at larger block sizes (>=128).
const _ACCUMULATE_BLOCK_SIZE = 64
Comment on lines +1 to +3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you expand on this? Is this a general AK issue or specific to OpenCL? Does this not depend on the workgroup/subgroup size?


Base.accumulate!(
op, B::CLArray, A::CLArray; init = zero(eltype(A)),
block_size = _ACCUMULATE_BLOCK_SIZE, kwargs...
) =
AK.accumulate!(op, B, A, OpenCLBackend(); init, block_size, kwargs...)

Base.accumulate(
op, A::CLArray; init = zero(eltype(A)),
block_size = _ACCUMULATE_BLOCK_SIZE, kwargs...
) =
AK.accumulate(op, A, OpenCLBackend(); init, block_size, kwargs...)

Base.cumsum(src::CLArray; block_size = _ACCUMULATE_BLOCK_SIZE, kwargs...) =
AK.cumsum(src, OpenCLBackend(); block_size, kwargs...)

Base.cumprod(src::CLArray; block_size = _ACCUMULATE_BLOCK_SIZE, kwargs...) =
AK.cumprod(src, OpenCLBackend(); block_size, kwargs...)
3 changes: 3 additions & 0 deletions src/sorting.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Base.sort!(x::CLArray; kwargs...) = (AK.sort!(x; kwargs...); return x)
Base.sortperm!(ix::CLArray, x::CLArray; kwargs...) = (AK.sortperm!(ix, x; kwargs...); return ix)
Base.sortperm(x::CLArray; kwargs...) = sortperm!(CLArray(1:length(x)), x; kwargs...)