Skip to content
Open
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: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SPIRVIntrinsics = {path = "lib/intrinsics"}

[compat]
Adapt = "4"
GPUArrays = "11.2.1"
GPUArrays = "12"
GPUCompiler = "2.13"
GPUToolbox = "3.3.2"
KernelAbstractions = "0.9.38"
Expand Down
1 change: 0 additions & 1 deletion src/OpenCL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ include("compiler/precompile.jl")
# integrations and specialized functionality
include("util.jl")
include("broadcast.jl")
include("mapreduce.jl")
include("gpuarrays.jl")
include("random.jl")

Expand Down
16 changes: 0 additions & 16 deletions src/gpuarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,3 @@ function GPUArrays.derive(::Type{T}, a::CLArray, dims::Dims{N}, offset::Int) whe
offset = a.offset + offset * sizeof(T)
CLArray{T,N}(ref, dims; offset)
end

const GLOBAL_RNGs = Dict{cl.Device,GPUArrays.RNG}()
const global_rngs_lock = ReentrantLock()

function GPUArrays.default_rng(::Type{<:CLArray})
dev = cl.device()
return Base.@lock global_rngs_lock begin
get!(GLOBAL_RNGs, dev) do
N = dev.max_work_group_size
state = CLArray{NTuple{4, UInt32}}(undef, N)
rng = GPUArrays.RNG(state)
Random.seed!(rng)
rng
end
end
end
182 changes: 0 additions & 182 deletions src/mapreduce.jl

This file was deleted.

11 changes: 10 additions & 1 deletion src/random.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
using Random

gpuarrays_rng() = GPUArrays.default_rng(CLArray)
const GLOBAL_RNGs = Dict{cl.Device,GPUArrays.RNG{CLArray}}()
const global_rngs_lock = ReentrantLock()

# one RNG per device, used by the RNG-less `rand!`/`randn!` methods and `seed!`
function gpuarrays_rng()
dev = cl.device()
return Base.@lock global_rngs_lock begin
get!(() -> GPUArrays.RNG{CLArray}(), GLOBAL_RNGs, dev)
end
end

# GPUArrays in-place
Random.rand!(A::WrappedCLArray) = Random.rand!(gpuarrays_rng(), A)
Expand Down
6 changes: 0 additions & 6 deletions test/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,6 @@ end
@test length(b) == 1
end

@testset "mapreducedim! returning same type" begin
R = transpose(OpenCL.zeros(Float32, 2, 3))
A = CLArray(rand(Float32, 3, 2, 10))
@test @inferred(OpenCL.GPUArrays.mapreducedim!(identity, +, R, A)) === R
end

# finalizers run in no particular order, e.g. at exit (JuliaGPU/OpenCL.jl#279), so memory
# has to remain freeable after the queue and context it was allocated with are finalized
@testset "freeing after finalizing its queue and context" begin
Expand Down
2 changes: 1 addition & 1 deletion test/device/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ if Float16 in GPUArraysTestSuite.supported_eltypes(CLArray)
end

@testset "randn!(Complex{Float16}) is finite" begin
rng = OpenCL.GPUArrays.default_rng(CLArray)
rng = OpenCL.GPUArrays.RNG{CLArray}()
Random.seed!(rng, 1)
A = CLArray{Complex{Float16}}(undef, 4096)
randn!(rng, A)
Expand Down
Loading