Repository navigation
Conversation
In pq_gen_avx2 and xor_gen_avx, save just the low 128 bits of the registers, as the Windows x64 calling convention requires only those to be saved. Signed-off-by: Miroslav Cimerman <mcimerman@protonmail.com>
Avoids the AVX-SSE transition penalty. Signed-off-by: Miroslav Cimerman <mcimerman@protonmail.com>
The vzeroupper added before shifts the loop8_bytes by 3 bytes, which performs worse: raid_funcs_perf -t xor_gen --sources 4 --sizes 64 became 7.6% slower on Sandy Bridge, 5.1% slower on Haswell-EP and 8.7% slower on Skylake-SP. With the loop aligned, the same command is 11.3%, 2.5% and 18.6% faster than master on these CPUs. Signed-off-by: Miroslav Cimerman <mcimerman@protonmail.com>
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.
Commit 1
The first commit saves just the low 128 bits of registers, as allowed by the win64 calling convention, and as other kernels do.
Commit 2
The second commit adds
vzeroupperbefore returning from AVX kernels, just as GFNI kernels inerasure_codedo it. Did not add it inpq_gen_avx.asm, as that code only uses the xmm part of the registers. It helps everything older than Skylake dodge the AVX<->SSE transition penalty (measured about 40-60 cycles per call on Haswell-EP and about 190 cycles per call on Sandy Bridge, two transitions per call), and is even more important on Skylake. On Skylake, with the high half of the registers dirty, each non-VEX encoded instruction depends on the previous value of its destination register, so instructions that could run in parallel run one after another: personally measured around 5x slowdown for 16 independentsqrtpdon Skylake-SP. Thevzerouppermight hurt only on Knights Landing, which I don't have access to anymore unfortunately. [1,2,3]No negative measurable performance impact on Haswell-EP, Sandy Bridge and Skylake-SP, besides a corner case that Commit 3 mostly takes care of (see below). If needed, I can further test on Comet Lake, and Zen 2.
Commit 3
In
xor_gen_avxandxor_gen_avx512, calls whose length is not a multiple of 128 bytes finish the remainder 8 bytes at a time inloop8_bytes, which sits afterreturn_pass. Thevzeroupperadded in commit 2 shifts that loop by 3 bytes, which costs short calls that run only this loop: on Haswell-EP,raid_funcs_perf -t xor_gen --sources 4 --sizes 64 --csvis 5.1% slower with commits 1-2 than on master. A build with a 3 byte NOP in place ofvzeroupperis just as slow per call, so it is the loop's position, not the instruction. Commit 3 alignsloop8_bytesto 16 bytes inxor_gen_avxandxor_gen_avx512, which makes these calls faster than on master on Sandy Bridge, Haswell-EP and Skylake-SP. Lengths that are multiples of 128 bytes don't use this loop and are unaffected.raid_funcs_perf -t xor_gen --sources 4 --sizes 64 --csv, 8 interleaved rounds ("commits 1-2" is this PR without commit 3, "master + commit 3" is master with only thealign 16):Haswell-EP (Xeon E5-2699 v3,
xor_gen_avx)Skylake-SP (Xeon Gold 6130,
xor_gen_avx512)On Sandy Bridge (Core i5-2520M,
xor_gen_avx), the same command gives -7.6% for commits 1-2, +11.0% for master + commit 3 and +11.3% for this PR against master.The only measurable cost of
vzeroupperitself shows in these very short calls, where it is noticeable: comparing master + commit 3 with this PR, about 2.5% on Skylake-SP, within noise on Haswell-EP and Sandy Bridge.