From 0195916663a8f8dbfc9afa87a5155d6aa52380bf Mon Sep 17 00:00:00 2001 From: chriselrod Date: Tue, 18 Apr 2023 14:30:43 -0400 Subject: [PATCH] Remove precompilation --- Project.toml | 2 +- src/VectorizedRNG.jl | 14 -------------- src/api.jl | 37 ++++++++++++++++++++----------------- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/Project.toml b/Project.toml index 5a5a849..3f96c9b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "VectorizedRNG" uuid = "33b4df10-0173-11e9-2a0c-851a7edac40e" authors = ["Chris Elrod "] -version = "0.2.23" +version = "0.2.24" [deps] Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" diff --git a/src/VectorizedRNG.jl b/src/VectorizedRNG.jl index 86b888d..b875b2e 100644 --- a/src/VectorizedRNG.jl +++ b/src/VectorizedRNG.jl @@ -123,18 +123,4 @@ function __init__() __init() end -@static if VERSION >= v"1.8.0-beta1" - let - while false - end - __init() - x64 = Vector{Float64}(undef, 16) - rand!(local_rng(), x64) - randn!(local_rng(), x64) - x32 = Vector{Float32}(undef, 16) - rand!(local_rng(), x32) - randn!(local_rng(), x32) - end -end - end # module diff --git a/src/api.jl b/src/api.jl index a1d0d78..1d583fc 100644 --- a/src/api.jl +++ b/src/api.jl @@ -233,14 +233,14 @@ end ) where {K} = vload(ptr, args...) @inline _vload(x::Number, args::Vararg{Any,K}) where {K} = x -function random_sample_u2!( +@inline function samplevector!( f::F, rng::AbstractVRNG{P}, x::AbstractArray{T}, α, β, γ, - g::G = identity + g::G ) where {F,P,T,G} state = getstate(rng, Val{2}(), pick_vector_width(UInt64)) GC.@preserve x begin @@ -290,14 +290,14 @@ function random_sample_u2!( end # GC preserve x end -function random_sample_u2!( +@inline function samplevector!( f::F, rng::AbstractVRNG{P}, x::AbstractArray{T}, ::StaticInt{0}, β, γ, - g::G = identity + g::G ) where {F,P,T,G} state = getstate(rng, Val{2}(), pick_vector_width(UInt64)) GC.@preserve x begin @@ -353,7 +353,7 @@ function Random.rand!( β = StaticInt{0}(), γ = StaticInt{1}() ) where {T<:Union{Float32,Float64},F} - random_sample_u2!(random_uniform, rng, x, α, β, γ, f) + samplevector!(random_uniform, rng, x, α, β, γ, f) end function Random.rand!( @@ -363,7 +363,7 @@ function Random.rand!( β = StaticInt{0}(), γ = StaticInt{1}() ) where {T<:Union{Float32,Float64}} - random_sample_u2!(random_uniform, rng, x, α, β, γ, identity) + samplevector!(random_uniform, rng, x, α, β, γ, identity) end function Random.randn!( @@ -373,7 +373,7 @@ function Random.randn!( β = StaticInt{0}(), γ = StaticInt{1}() ) where {T<:Union{Float32,Float64}} - random_sample_u2!(random_normal, rng, x, α, β, γ) + samplevector!(random_normal, rng, x, α, β, γ, identity) end @inline function random_unsigned( state::AbstractState, @@ -383,13 +383,14 @@ end nextstate(state, Val{N}()) end function Random.rand!(rng::AbstractVRNG, x::AbstractArray{UInt64}) - random_sample_u2!( + samplevector!( random_unsigned, rng, x, StaticInt{0}(), StaticInt{0}(), - StaticInt{1}() + StaticInt{1}(), + identity ) end @@ -399,7 +400,7 @@ function Random.rand!( x::StaticArraysCore.MArray{<:Tuple,T} ) where {T<:Union{Float32,Float64}} GC.@preserve x begin - random_sample_u2!(random_uniform, rng, PtrArray(x), α, β, γ) + samplevector!(random_uniform, rng, PtrArray(x), α, β, γ, identity) end return x end @@ -413,7 +414,7 @@ function Random.rand!( } a = MArray{S,UInt64}(undef) GC.@preserve a begin - random_sample_u2!(random_uniform, rng, PtrArray(a), α, β, γ) + samplevector!(random_uniform, rng, PtrArray(a), α, β, γ, identity) end x .= a end @@ -422,7 +423,7 @@ function Random.randn!( x::StaticArraysCore.MArray{<:Tuple,T} ) where {T<:Union{Float32,Float64}} GC.@preserve x begin - random_sample_u2!(random_normal, rng, PtrArray(x), α, β, γ) + samplevector!(random_normal, rng, PtrArray(x), α, β, γ, identity) end return x end @@ -436,7 +437,7 @@ function Random.randn!( } a = MArray{S,UInt64}(undef) GC.@preserve a begin - random_sample_u2!(random_normal, rng, PtrArray(a), α, β, γ) + samplevector!(random_normal, rng, PtrArray(a), α, β, γ, identity) end x .= a end @@ -445,13 +446,14 @@ function Random.rand!( rng::AbstractVRNG, x::StaticArraysCore.MArray{<:Tuple,UInt64} ) - random_sample_u2!( + samplevector!( random_unsigned, rng, x, StaticInt{0}(), StaticInt{0}(), - StaticInt{1}() + StaticInt{1}(), + identity ) end function Random.rand!( @@ -460,13 +462,14 @@ function Random.rand!( ) where {S<:Tuple,SA<:StaticArraysCore.StaticArray{S,UInt64}} a = MArray{S,UInt64}(undef) GC.@preserve a begin - random_sample_u2!( + samplevector!( random_unsigned, rng, PtrArray(a), StaticInt{0}(), StaticInt{0}(), - StaticInt{1}() + StaticInt{1}(), + identity ) end x .= a