Single-threaded performance improvements in forward DWT for 5-3 and 9-7 (and other improvements)#1253
Merged
rouault merged 24 commits intouclouvain:masterfrom Oct 9, 2020
Conversation
- API wise, opj_codec_set_threads() can be used on the encoding side - opj_compress has a -threads switch similar to opj_uncompress
Update the bench_dwt utility to have a -decode/-encode switch Measured performance gains for DWT encoder on a Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (4 cores, hyper threaded) Encoding time: $ ./bin/bench_dwt -encode -num_threads 1 time for dwt_encode: total = 8.348 s, wallclock = 8.352 s $ ./bin/bench_dwt -encode -num_threads 2 time for dwt_encode: total = 9.776 s, wallclock = 4.904 s $ ./bin/bench_dwt -encode -num_threads 4 time for dwt_encode: total = 13.188 s, wallclock = 3.310 s $ ./bin/bench_dwt -encode -num_threads 8 time for dwt_encode: total = 30.024 s, wallclock = 4.064 s Scaling is probably limited by memory access patterns causing memory access to be the bottleneck. The slightly worse results with threads==8 than with thread==4 is due to hyperthreading being not appropriate here.
…functional change)
…ith original image
…void potential division by zero
…id messing up with stepsize (no functional change)
…tandard The previous constant opj_c13318 was mysteriously equal to 2/K , and in the DWT, we had to divide K and opj_c13318 by 2... The issue was that the band->stepsize computation in tcd.c didn't take into account the log2gain of the band. The effect of this change is expected to be mostly equivalent to the previous situation, except some difference in rounding. But it leads to a dramatic reduction of the mean square error and peak error in the irreversible encoding of issue141.tif !
…res in test suite
"bench_dwt -I" time goes from 2.8s to 2.2s
Nothing in code analysis nor test suite shows that this margin is needed. It dates back to commit dbeebe7 where vector 9x7 decoding was introduced.
"bench_dwt -I" time goes from 2.2s to 1.5s
…the horizontal pass
…est in vertical pass
…the vertical pass
`bench_dwt -encode` times goes from 7.9s to 1.7s
`bench_dwt -I -encode` times goes from 8.6s to 2.1s
…ata organization ~ 9% speed improvement seen on 10980x10980 uint16 image, T36JTT_20160914T074612_B02.tif opj_compress time from 17.2s to 15.8s
Collaborator
Author
|
CC @savmickael This is ready for your review |
Collaborator
Author
|
@savmickael I'll merge this soon (before end of week), unless you want to have a look before |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of improvements:
Combined effect of those improvements on the bench used in PR 1248 (
time bin/opj_compress -threads XXXX -n 5 -c [256,256],[256,256],[256,256],[256,256],[256,256] -t 1024,1024 -PLT -i T36JTT_20160914T074612_B02.tif -o out.jp2 >/dev/null)(For convenience this PR is based on top of PR 1248, so the first 2 commits "Add multithreading ..." belong to this later one)
Funded by ESA for S2-MPC project