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

Improve speed and mean accuracy of pow12_5 #483

Merged
merged 1 commit into from
Jun 8, 2021

Conversation

kimikage
Copy link
Collaborator

@kimikage kimikage commented Jun 4, 2021

pow12_5 is used in the RGB{Float64}-->XYZ conversion.
This ensures sufficient accuracy (~2 ULP) in the range of [0.09, 1], which is typically required for the conversion.

julia> Colors.pow12_5(0.5), Float64(0.5^big"2.4")
(0.18946457081379978, 0.18946457081379975)

julia> Colors.pow12_5(1.0), Float64(1.0^big"2.4")
(1.0, 1.0)

julia> Colors.pow12_5(1.5), Float64(1.5^big"2.4")
(2.6461778006805154, 2.6461778006805154)

julia> Colors.pow12_5(5.0), Float64(5.0^big"2.4")
(47.60126373669469, 47.591348467896964)

I decided to solve #425 first in order to do a fair benchmark for PR #482. However, it doesn't seem to be solved by just not using exp. 😕

If we can accept the divergence when the input is more than 2.0, then we can merge this. However, I would like to study #425 some more.

Edit:
@inline is not a good idea, but it could be a workaround for the problem with precompilation.

@codecov
Copy link

codecov bot commented Jun 4, 2021

Codecov Report

Merging #483 (a601bc6) into master (c28d392) will increase coverage by 0.38%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #483      +/-   ##
==========================================
+ Coverage   92.41%   92.79%   +0.38%     
==========================================
  Files           9        9              
  Lines         975      985      +10     
==========================================
+ Hits          901      914      +13     
+ Misses         74       71       -3     
Impacted Files Coverage Δ
src/parse.jl 100.00% <ø> (+2.52%) ⬆️
src/conversions.jl 99.33% <100.00%> (+<0.01%) ⬆️
src/utilities.jl 98.18% <100.00%> (+0.16%) ⬆️

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 6f0a3aa...a601bc6. Read the comment docs.

@kimikage kimikage force-pushed the pow12_5 branch 4 times, most recently from efca927 to e6f024c Compare June 4, 2021 03:39
@kimikage
Copy link
Collaborator Author

kimikage commented Jun 4, 2021

Benchmark

julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 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-11.0.1 (ORCJIT, skylake)

julia> xs = rand(1000) .+ 0.09;

julia> @noinline f(x) = Colors.pow12_5(x);

julia> @btime f.($xs);
  17.200 μs (1 allocation: 7.94 KiB) # before
  8.500 μs (1 allocation: 7.94 KiB)  # after

@kimikage kimikage marked this pull request as ready for review June 5, 2021 03:26
@kimikage kimikage force-pushed the pow12_5 branch 2 times, most recently from 6cb55de to e3b30df Compare June 6, 2021 09:05
@kimikage kimikage changed the title Improve speed and accuracy of pow12_5 Improve speed and mean accuracy of pow12_5 Jun 6, 2021
`pow12_5` is used in the `RGB{Float64}`-->`XYZ` conversion.
This ensures sufficient accuracy (~2 ULP) in the range of [0.09, 1],
which is typically required for the conversion.

`@inline` could be a workaround for the problem with precompilation.
@kimikage kimikage merged commit 109ee4b into JuliaGraphics:master Jun 8, 2021
@kimikage kimikage deleted the pow12_5 branch June 8, 2021 13:02
kimikage added a commit to kimikage/Colors.jl that referenced this pull request May 11, 2024
`pow12_5` is used in the `RGB{Float64}`-->`XYZ` conversion.
This ensures sufficient accuracy (~2 ULP) in the range of [0.09, 1],
which is typically required for the conversion.

`@inline` could be a workaround for the problem with precompilation.
kimikage added a commit that referenced this pull request May 11, 2024
`pow12_5` is used in the `RGB{Float64}`-->`XYZ` conversion.
This ensures sufficient accuracy (~2 ULP) in the range of [0.09, 1],
which is typically required for the conversion.

`@inline` could be a workaround for the problem with precompilation.
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