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

Specialize sign-related functions #187

Merged
merged 1 commit into from
Jul 14, 2020
Merged

Conversation

kimikage
Copy link
Collaborator

@kimikage kimikage commented Jun 28, 2020

This is part of the issue #185.
Edit:
This prohibits copysign/flipsign for Normed. They should be confusing when the signed Normed is supported in the future. Furthermore, if signed Normed is available, we should not do unsafe sign operations for unsigned Normed.

@kimikage
Copy link
Collaborator Author

Benchmark

julia> versioninfo()
Julia Version 1.4.2
Commit 44fa15b150* (2020-05-23 18:35 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

before

julia> @btime copysign.(x, y) setup=(x=collect(rand(Q0f7,100,100)); y=collect(rand(Q0f7,100,100)));
  31.100 μs (1 allocation: 9.94 KiB)

julia> @btime flipsign.(x, y) setup=(x=collect(rand(Q0f7,100,100)); y=collect(rand(Q0f7,100,100)));
  30.900 μs (1 allocation: 9.94 KiB)
  
julia> @btime signbit.(x) setup=(x=collect(rand(Q0f7,100,100)));
  5.750 μs (3 allocations: 5.56 KiB)

julia> @btime signbit.(x) setup=(x=collect(rand(N0f8,100,100)));
  2.744 μs (3 allocations: 5.56 KiB)
  
julia> @btime abs.(x) setup=(x=collect(rand(N0f8,100,100)));
  2.962 μs (1 allocation: 9.94 KiB)

after

julia> @btime copysign.(x, y) setup=(x=collect(rand(Q0f7,100,100)); y=collect(rand(Q0f7,100,100)));
  7.500 μs (1 allocation: 9.94 KiB)
  
julia> @btime flipsign.(x, y) setup=(x=collect(rand(Q0f7,100,100)); y=collect(rand(Q0f7,100,100)));
  5.350 μs (1 allocation: 9.94 KiB)
  
julia> @btime signbit.(x) setup=(x=collect(rand(Q0f7,100,100)));
  5.316 μs (3 allocations: 5.56 KiB)

julia> @btime signbit.(x) setup=(x=collect(rand(N0f8,100,100)));
  1.700 μs (3 allocations: 5.56 KiB)

julia> @btime abs.(x) setup=(x=collect(rand(N0f8,100,100)));
  2.962 μs (1 allocation: 9.94 KiB)

@codecov
Copy link

codecov bot commented Jun 28, 2020

Codecov Report

Merging #187 into master will increase coverage by 0.14%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #187      +/-   ##
==========================================
+ Coverage   89.15%   89.30%   +0.14%     
==========================================
  Files           6        6              
  Lines         452      458       +6     
==========================================
+ Hits          403      409       +6     
  Misses         49       49              
Impacted Files Coverage Δ
src/fixed.jl 90.17% <ø> (-0.09%) ⬇️
src/normed.jl 88.88% <ø> (-0.12%) ⬇️
src/FixedPointNumbers.jl 87.71% <100.00%> (+1.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba9d832...d7970bc. Read the comment docs.

@kimikage kimikage marked this pull request as ready for review June 29, 2020 18:08
This was referenced Jul 5, 2020
@kimikage
Copy link
Collaborator Author

rebased

@kimikage kimikage requested review from timholy and removed request for timholy July 13, 2020 04:29
@kimikage
Copy link
Collaborator Author

I'll merge this, but wait a little longer for tagging.

@kimikage kimikage merged commit ad288ff into JuliaMath:master Jul 14, 2020
@kimikage kimikage deleted the sign_related branch July 14, 2020 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant