Skip to content

Commit

Permalink
alternative fix for #35
Browse files Browse the repository at this point in the history
  • Loading branch information
chriselrod committed Oct 29, 2023
1 parent 9b7425e commit bcbb758
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SLEEFPirates"
uuid = "476501e8-09a2-5ece-8869-fb82de89a1fa"
authors = ["chriselrod <elrodc@gmail.com>"]
version = "0.6.39"
version = "0.6.40"

[deps]
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"
Expand Down
15 changes: 12 additions & 3 deletions src/log.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,17 @@ the natural expoenential function `exp(x)`
e = ilogb2k(d * T(1.0 / 0.75))
m = ldexp3k(d, -e)
e = ifelse(o, e - I(64), e)
# @show m e
x = (m - one(m)) / (m + one(m))
x2 = x * x

t = log_fast_kernel(Val{BASE}(), x2)

x = muladd(x, t, invlog2(Val{BASE}(), T) * e)
il2 = invlog2(Val{Base}())
if il2 === One()
x = muladd(x, t, e)
else
x = muladd(x, t, il2 * e)
end

x = ifelse(isinf(d), T(Inf), x)
x = ifelse((d < zero(I)) | isnan(d), T(NaN), x)
Expand Down Expand Up @@ -323,7 +327,12 @@ end
) where {W,T<:Union{Float32,Float64},BASE}
m = VectorizationBase.vgetmant(d) # m ∈ (0.75,1.5)
e = VectorizationBase.vgetexp(T(1.3333333333333333) * d)
en = invlog2(Val{BASE}(), T) * e
il2 = invlog2(Val{BASE}(), T)
if il2 === One()
en = T(e)
else
en = il2 * e
end
# x = (m - one(m)) / (m + one(m))
x = @fastmath (m - one(m)) / (m + one(m))
x2 = x * x
Expand Down

4 comments on commit bcbb758

@chriselrod
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/94374

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.40 -m "<description of version>" bcbb75834c6a9b1f214c68543cab07939658ceb4
git push origin v0.6.40

@bvdmitri
Copy link

Choose a reason for hiding this comment

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

@chriselrod I get this error now with the new version, I'm not sure what exactly does it mean

Test threw exception
  Expression: all(#= /Users/bvdmitri/.julia/dev/ExponentialFamily.jl/test/distributions/matrix_dirichlet_tests.jl:83 =# @inferred(sufficientstatistics(ef, x)) .≈ (map(log, x),))
  TypeError: in Type, in parameter, expected Type, got a value of type Module
  Stacktrace:
    [1] log_fast
      @ ~/.julia/packages/SLEEFPirates/5kXZv/src/log.jl:283 [inlined]
    [2] log_fast
      @ ~/.julia/packages/SLEEFPirates/5kXZv/src/log.jl:348 [inlined]
    [3] log_fast
      @ ~/.julia/packages/SLEEFPirates/5kXZv/src/log.jl:344 [inlined]
    [4] log
      @ ~/.julia/packages/SLEEFPirates/5kXZv/src/SLEEFPirates.jl:280 [inlined]
    [5] _vmap_singlethread!(f::typeof(log), ptry::LayoutPointers.StridedPointer{Float64, 2, 1, 0, (1, 2), Tuple{Static.StaticInt{8}, Int64}, Tuple{Static.StaticInt{0}, Static.StaticInt{0}}}, start::Static.StaticInt{0}, N::Int64, #unused#::Val{false}, ptrargs::Tuple{LayoutPointers.StridedPointer{Float64, 2, 1, 0, (1, 2), Tuple{Static.StaticInt{8}, Int64}, Tuple{Static.StaticInt{0}, Static.StaticInt{0}}}})
      @ LoopVectorization ~/.julia/packages/LoopVectorization/xHfLl/src/simdfunctionals/map.jl:101
    [6] vmap_singlethread!
      @ ~/.julia/packages/LoopVectorization/xHfLl/src/simdfunctionals/map.jl:80 [inlined]
    [7] macro expansion
      @ ~/.julia/packages/LoopVectorization/xHfLl/src/simdfunctionals/map.jl:290 [inlined]
    [8] gc_preserve_vmap!
      @ ~/.julia/packages/LoopVectorization/xHfLl/src/simdfunctionals/map.jl:290 [inlined]
    [9] vmap!
      @ ~/.julia/packages/LoopVectorization/xHfLl/src/simdfunctionals/map.jl:353 [inlined]
   [10] vmap_call(f::typeof(log), vm!::typeof(LoopVectorization.vmap!), args::Matrix{Float64})
      @ LoopVectorization ~/.julia/packages/LoopVectorization/xHfLl/src/simdfunctionals/map.jl:448
   [11] vmap
      @ ~/.julia/packages/LoopVectorization/xHfLl/src/simdfunctionals/map.jl:458 [inlined]```

Comes from `LoopVectorizations.jl`

@bvdmitri
Copy link

Choose a reason for hiding this comment

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

Ah, I see the PR for that, sorry for the noise

Please sign in to comment.