Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make thread-safe; use JLL package #106

Merged
merged 7 commits into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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
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
5 changes: 2 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ uuid = "55939f99-70c6-5e9b-8bb0-5071ed7d61fd"
version = "0.4.10"

[deps]
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
DecFP_jll = "47200ebd-12ce-5be5-abb7-8e082af23329"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
stevengj marked this conversation as resolved.
Show resolved Hide resolved
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.

148 changes: 76 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 @@ -139,6 +155,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 @@ -213,11 +232,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