Repository navigation
YUV42x color conversions rewritten to wide intrinsics - #13708
Conversation
| { | ||
| v_uint8 u, v; | ||
| u = vx_load(u1 + i); | ||
| v = vx_load(v1 + i); |
There was a problem hiding this comment.
What are the alignment requirements of these(any and all vector) instructions and the guarantees the API/users give? this applies to all the other places in this and similar PRs
There are platforms(e.g. ARM) that do not support unaligned instructions(even regular scalar non-vector ones), others have big performance hit(e.g. 2x on x86/64)
Were there any tests on non-x86 platforms?
--
Specifically, a lot of people(including us) are having this great signal 7 (SIGBUS), code 1 (BUS_ADRALN) crashes all over the place on android(and less often on ios), some devices/os versions more prone(100%) than the others.
Ours particular reproducible crash is reading VideoCapture->yuv420 conversion.
--
@alalek It raises an eyebrow how fast this PR was merged(even with a single review).
Usually vectorised code is a bugs' nest and it raises a question on the quality of this and similar PRs
I'm new to the opencv processes but i wonder if there are any people at intel/opencv team that would like to review this/similar PRs more thoroughly. What is the process to finding these people? (sorry have not had a time to read any contribution guidelines yet)
--
The usual process to vectorising the code is having:
- unvectorised prologue for unaligned part
- vectorised loop for aligned & full blocks
- unvectorised epilogue for the rest of incomplete block
this code(and probably other places and similar PRs) seem to miss the first part completely.
Alternatively, one must document and ensure all the users are respecting the requirements.
--
It is better to have a working code than fast but incorrect(and even crashing) one.
Is there a possibility to review all this vectorised "mess" for alignment and fix it quickly, or is it better to revert completely until better-thought-out version arrives?
There was a problem hiding this comment.
if(range.start % 2 == 1)
{
u1 += uvsteps[(usIdx++) & 1];
v1 += uvsteps[(vsIdx++) & 1];
}
Was this a (historical) attempt at fixing alignment of (scalar) accesses back then..?
There was a problem hiding this comment.
There are two intrinsic functions in OpenCV:
vx_load(wrapper overv_load()(SIMD128) /v256_load()/v512_load())vx_load_aligned
Both should be aligned on the size of base type (uchar is that case, so no extra limitation): docs
Feel free to prepare reproducer for this problem and open new issue (in form of PR with test is preferable - we have ARM builders in CI (however there can be some extra settings near alignment requirements)).
There was a problem hiding this comment.
Big thanks for the detailed information as always!
Sorry for not reading more into intrinsics, i assumed they were a simple generic unaligned/untyped ones.
One possible reason might be the direct use of the Device(gpu/codec/isp/dsp) memory which may have some quirks for wide accesses...
I'll try gathering more information on this.
This seems related to running on 32bit arm.
YUV42x color conversions rewritten to wide intrinsics (opencv#13708) * a*b+c -> fma * YUV420sp2RGB initially vectorized * shorter var names * loops by 4 * yuv420p2rgb vectorized * yuv422toRGB vectorized * reg arrays * rgb2yuv420 vectorized * warnings fixed * try to fix align error
This pullrequest changes
All 4:2:0 and 4:2:2 conversions from/to YUV in
color_yuv.cpprewritten to wide universal intrinsicsPerformance
Summary, performance boost (times) compared to original time
Geometric mean (ms):
Baseline AVX2
Baseline AVX512SKX
Baseline SSE2
Baseline SSE4.1
Settings