-
Notifications
You must be signed in to change notification settings - Fork 34
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
Fix _unsafe_trunc
to reduce the likelihood of arbitrary values
#291
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #291 +/- ##
==========================================
- Coverage 97.05% 96.93% -0.13%
==========================================
Files 7 7
Lines 782 784 +2
==========================================
+ Hits 759 760 +1
- Misses 23 24 +1 ☔ View full report in Codecov by Sentry. |
Benchmark (x86-64 Windows)As for x86-64, there is no major performance regression. using FixedPointNumbers
using BenchmarkTools
mat_f64 = rand(Float64, 1000, 1000) .* 2 .- 1;
mat_f32 = rand(Float32, 1000, 1000) .* 2 .- 1;
@btime $mat_f64 .% N0f8;
@btime $mat_f64 .% N0f16;
@btime $mat_f64 .% N16f16;
@btime $mat_f32 .% N0f8;
@btime $mat_f32 .% N0f16;
@btime $mat_f32 .% N16f16;
@btime $mat_f64 .% Q0f7;
@btime $mat_f64 .% Q0f15;
@btime $mat_f64 .% Q15f16;
@btime $mat_f32 .% Q0f7;
@btime $mat_f32 .% Q0f15;
@btime $mat_f32 .% Q15f16; julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8 (2024-03-01 10:14 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores) beforejulia> @btime $mat_f64 .% N0f8;
214.200 μs (2 allocations: 976.67 KiB)
julia> @btime $mat_f64 .% N0f16;
428.900 μs (2 allocations: 1.91 MiB)
julia> @btime $mat_f64 .% N16f16;
1.118 ms (2 allocations: 3.81 MiB)
julia> @btime $mat_f32 .% N0f8;
119.000 μs (2 allocations: 976.67 KiB)
julia> @btime $mat_f32 .% N0f16;
327.400 μs (2 allocations: 1.91 MiB)
julia> @btime $mat_f32 .% N16f16;
1.095 ms (2 allocations: 3.81 MiB)
julia> @btime $mat_f64 .% Q0f7;
216.300 μs (2 allocations: 976.67 KiB)
julia> @btime $mat_f64 .% Q0f15;
436.200 μs (2 allocations: 1.91 MiB)
julia> @btime $mat_f64 .% Q15f16;
1.123 ms (2 allocations: 3.81 MiB)
julia> @btime $mat_f32 .% Q0f7;
116.900 μs (2 allocations: 976.67 KiB)
julia> @btime $mat_f32 .% Q0f15;
288.300 μs (2 allocations: 1.91 MiB)
julia> @btime $mat_f32 .% Q15f16;
1.122 ms (2 allocations: 3.81 MiB) afterjulia> @btime $mat_f64 .% N0f8;
202.500 μs (2 allocations: 976.67 KiB)
julia> @btime $mat_f64 .% N0f16;
415.000 μs (2 allocations: 1.91 MiB)
julia> @btime $mat_f64 .% N16f16;
1.403 ms (2 allocations: 3.81 MiB)
julia> @btime $mat_f32 .% N0f8;
115.600 μs (2 allocations: 976.67 KiB)
julia> @btime $mat_f32 .% N0f16;
322.200 μs (2 allocations: 1.91 MiB)
julia> @btime $mat_f32 .% N16f16;
1.383 ms (2 allocations: 3.81 MiB)
julia> @btime $mat_f64 .% Q0f7;
205.500 μs (2 allocations: 976.67 KiB)
julia> @btime $mat_f64 .% Q0f15;
417.700 μs (2 allocations: 1.91 MiB)
julia> @btime $mat_f64 .% Q15f16;
1.120 ms (2 allocations: 3.81 MiB)
julia> @btime $mat_f32 .% Q0f7;
116.200 μs (2 allocations: 976.67 KiB)
julia> @btime $mat_f32 .% Q0f15;
329.200 μs (2 allocations: 1.91 MiB)
julia> @btime $mat_f32 .% Q15f16;
1.175 ms (2 allocations: 3.81 MiB) |
We are having problems testing ColorTypes.jl. So, I am going to backport this to v0.8. |
In any case, this PR is a bug fix, so I will merge it first. |
This fixes (mitigates) #288.