Repository navigation
core:unv Change behaviour of 16-bit multiply operator - #12516
Conversation
d6484dc to
e9ccc69
Compare
bf08487 to
e0dd613
Compare
e0dd613 to
6360a62
Compare
|
@seiko2plus, thank you for the great work, as usual! |
| v_expand(v_src, v_src0, v_src1); | ||
| v_src0 = v_src0 * v_src0; | ||
| v_src1 = v_src1 * v_src1; | ||
| v_src0 = v_mul_wrap(v_src0, v_src0); |
There was a problem hiding this comment.
can we instead implement v_mul_expand() for v_uint8 data? I think, it can be implement much more efficiently than 8u to 16u expansion + v_mul_wrap. Besides, this v_mul_expand may appear to be useful for many more operations.
There was a problem hiding this comment.
Indeed it seems useful currently used by accumulate product , but we still need to use v_expand + v_mul_wrap with accumulate square.
I was going to implement new universal intrinsics for expand and square(v_square_expand) but I fell back , I don't think its gonna be that helpful.
| return v_int8x32(_v256_shuffle_odd_64(_mm256_packs_epi16(p0, p1))); | ||
| } | ||
| // saturating multiply 16-bit | ||
| inline v_uint16x16 operator * (const v_uint16x16& a, const v_uint16x16& b) |
There was a problem hiding this comment.
in general, all the saturation * operations can be implemented as v_mul_expand() + v_pack().
There was a problem hiding this comment.
Exactly except avx2::uint16 & int64 due performance lose, but I had to implement forward declarations for theses intrinsics in order to re-implement saturation * operations .
7e62bb8 to
e3fb253
Compare
|
@vpisarev, I apologize if I went a little bit far from the target of this pull request but your suggestion about v_mul_expand lead me to full check accum.simd.hpp, |
e3fb253 to
2853515
Compare
|
@seiko2plus, yes, that's fine. Let me know when you are done with this patch :) |
- redefine 16-bit multiply operator to perform saturating multiply
instead of non-saturating multiply
- implement 8-bit multiply operator to perform saturating multiply
- implement v_mul_wrap() for 8-bit, 16-bit non-saturating multiply
- improve performance of v_mul_hi() for VSX
- update intrin tests with new changes
- replace unv 16-bit multiplication operator with v_mul_wrap due behavior changes
- Several improvements depend on vpisarev review
* initial forward declarations for universal intrinsics
* move emulating SSE intrinsics into separate file
* implement v_mul_expand for 8-bit
* reimplement saturating multiply using v_mul_expand + v_pack
* map v_expand, v_load_expand, v_load_expand_q to sse4.1
* fix overflow avx2::v_pack(uint32)
* implement two universal intrinsics v_expand_low and v_expand_high
…operations
- improve cpu dispatching calls to allow more SIMD extentions
(SSE4.1, AVX2, VSX)
- wide universal intrinsics
- replace dummy v_expand with v_expand_low
- replace v_expand + v_mul_wrap with v_mul_expand for product accumulate operations
- use FMA for accumulate operations
- add mask and more types to accumulate's performance tests
f099eb0 to
8965f3a
Compare
|
@vpisarev , I squashed the patch into two commits, extended commits could found at this branch changeUnvMultiply16_without_squash. Performance testsArgs used with opencv_perf_imgprocX86CPUOSBenchmarkNO IPP & BASELINE AVX2 Median (ms)
NO IPP & BASELINE AVX Median (ms)
NO IPP & BASELINE SSE4_1 Median (ms)
NO IPP & BASELINE SSE3 Median (ms)
PPC64LECPUOSBenchmarkBASELINE VSX Median (ms)
Notes
ARMCPUOSBenchmarkBASELINE NEON FP16 Median (ms)
|
Take a look on 1920x1080 - there are no loss observed. Performance results are not very stable on low resolutions. |
|
👍 |
This patch paves the way for #12064
Merge with opencv_contrib: opencv/opencv_contrib#1771