Skip to content

Commit

Permalink
Make thread-safe; use JLL package (#106)
Browse files Browse the repository at this point in the history
* Make _buffer thread-safe

* Make thread-safe; use JLL package

* BinaryProvider not needed

* resize! global vectors

* Vector declaration

* Use RefArray

* Use buffer in functions
  • Loading branch information
jmkuhn authored Mar 29, 2020
1 parent 7c213d3 commit 8eca99e
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 126 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
*.jl.cov
*.jl.mem
Manifest.toml
deps/IntelRDFPMathLib*
deps/installed_vers
deps/libbid*.*
deps/deps.jl
deps/usr
deps/build.log
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ os:
- osx

julia:
- 0.7
- 1.0
- 1.3
- 1.4
- nightly

env:
matrix:
- JULIA_NUM_THREADS=1
- JULIA_NUM_THREADS=2

notifications:
email: false

Expand Down
6 changes: 2 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ uuid = "55939f99-70c6-5e9b-8bb0-5071ed7d61fd"
version = "0.4.10"

[deps]
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
DecFP_jll = "47200ebd-12ce-5be5-abb7-8e082af23329"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"

[compat]
BinaryProvider = "0.5"
SpecialFunctions = "0.7, 0.8, 0.9"
julia = "0.7, 1"
julia = "1.3"

[extras]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
environment:
matrix:
- julia_version: 0.7
- julia_version: 1.0
- julia_version: 1.3
- julia_version: 1.4
- julia_version: latest

platform:
Expand Down
37 changes: 0 additions & 37 deletions deps/build.jl

This file was deleted.

151 changes: 79 additions & 72 deletions src/DecFP.jl

Large diffs are not rendered by default.

29 changes: 26 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
using DecFP, Test, Printf, Base.MathConstants, SpecialFunctions

@test unsafe_load(DecFP.flags[]) == 0
@test DecFP.flags[Threads.threadid()] == 0

import DecFP.isnanstr
@test isnanstr("nan") && isnanstr(" +NAN") && isnanstr("-NaN") && !isnanstr("nano")

function testthreads(T, i, mode)
@test @sprintf("%.0f", T(i)) == string(i)
@test rounding(T) == RoundNearest
setrounding(T, mode) do
@test rounding(T) == mode
if mode in (RoundNearest, RoundToZero, RoundDown)
@test T(1) + eps(T(1)) / 2 == T(1)
else
@test T(1) + eps(T(1)) / 2 == T(1) + eps(T(1))
end
end
@test rounding(T) == RoundNearest
@test_throws InexactError convert(Int64, T("1.5"))
@test_throws DomainError sqrt(T(-2))
end

for T in (Dec32, Dec64, Dec128)
@info "TESTING $T ..."
@info "TESTING $T nthreads = $(Threads.nthreads()) ..."

if T == Dec32
@test d32"3.2" * d32"4.5" == d32"14.4"
Expand Down Expand Up @@ -141,6 +157,9 @@ for T in (Dec32, Dec64, Dec128)
@test f(T(v)) f(v)
end

# issue #47
@test exp10(T(0)) == T(1)

for c in (π, e, γ, catalan, φ)
@test T(c) Float64(c)
end
Expand Down Expand Up @@ -215,11 +234,15 @@ for T in (Dec32, Dec64, Dec128)
@test typeof(xd * pi) == T
@test typeof((xd+yd*im)*pi) == Complex{T}

Threads.@threads for (i, mode) in collect(enumerate((RoundNearest, RoundToZero, RoundFromZero, RoundUp, RoundDown)))
testthreads(T, i, mode)
end

# issue #85
@test T(1.5) == T(T(1.5))
end

@test unsafe_load(DecFP.flags[]) == 0
@test DecFP.flags[Threads.threadid()] == 0

# issue #37
@test reinterpret(UInt128, Dec128(1.5)) == 0x303e000000000000000000000000000f
Expand Down

0 comments on commit 8eca99e

Please sign in to comment.