Merged
Conversation
Member
|
I didn't see discussion on what Did you run any benchmarks? |
Contributor
Author
|
Right, sorry. The compiler is smart enough to treat it like two vpmullw %zmm1, %zmm4, %zmm1
vpmovzxbw 32(%r8), %zmm4
vpmullw %zmm2, %zmm4, %zmm2
vpxor %xmm4, %xmm4, %xmm4
vpunpckhbw %zmm4, %zmm0, %zmm5
vpunpckhbw %zmm4, %zmm3, %zmm16
vpmullw %zmm5, %zmm16, %zmm5
vpsrlw $8, %zmm5, %zmm5
vpunpcklbw %zmm4, %zmm0, %zmm0
vpunpcklbw %zmm4, %zmm3, %zmm3
vpmullw %zmm0, %zmm3, %zmm0
vpsrlw $8, %zmm0, %zmm0
vpackuswb %zmm5, %zmm0, %zmm0
vpmovwb %zmm1, %ymm1
vpmovwb %zmm2, %ymm2
vinserti64x4 $1, %ymm2, %zmm1, %zmm1There's a chance it won't work on other architectures, though those architectures might not even have 512-bits and benchmarks with #[bench]
fn $fnn(b: &mut Bencher) {
let x = <$ty>::splat(7);
let y = <$ty>::splat(3);
b.iter(|| {
let mut accum = <$ty>::default();
for _ in 0..RAND_BENCH_N {
// no unrolling, so it's similar to gen_range without the overhead
let (h, l) = test::black_box(x).$wmul_type(test::black_box(y));
accum += h;
accum += l;
}
accum
});
b.bytes = size_of::<$ty>() as u64 * 2 * RAND_BENCH_N;
}performing two multiplications instead of four is easily going to be faster |
dhardy
approved these changes
Aug 12, 2022
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.
stdsimd allows types larger than 512-bits so we can avoid the slow __mulddi3 path. If/when
Simd<u128>arrives we can use it for 64-bit lanes as well