Skip to content

imgproc: remove raw SSE2/NEON implementation from imgwarp.cpp - #11169

Merged
opencv-pushbot merged 1 commit into
opencv:3.4from
tomoaki0705:universalRemap
Apr 13, 2018
Merged

opencv-pushbot merged 1 commit into
opencv:3.4from
tomoaki0705:universalRemap

Conversation

@tomoaki0705

@tomoaki0705 tomoaki0705 commented Mar 27, 2018 •

Copy link
Copy Markdown
Contributor
  • use universal intrinsic instead of raw intrinsic
  • add 2 channels 16bit width de-interleave on x86 platform
  • I'll paste performance comparison later
force_builders=Custom
docker_image:Custom=powerpc64le

@tomoaki0705

Copy link
Copy Markdown
Contributor Author

/cc @seiko2plus
I added new universal intrinsic, they look like already exists on vsx, but I'd like to ask your review.

  • v_load_deinterleave(const short*, v_int16x8& a, v_int16x8& b);
  • v_load_deinterleave(const ushort*, v_uint16x8& a, v_uint16x8& b);

@tomoaki0705

Copy link
Copy Markdown
Contributor Author

Hmmm, I only payed attention on opencv_test_imgproc, but the failure comes from opencv_perf_imgproc.

The situation what is happening is that they are "warp" processing.
That means coordinates are computed in float, and could have rounding error.
If rounding error happens on coordinate, the pixel value could differ more than the threshold easily.

I'll have a look by loosening some thresholds.

CV_PICK_AND_PACK_RGB(S1, iofs0[2], cn, v0);
CV_PICK_AND_PACK_RGB(S0, iofs0[3], cn, u1);
CV_PICK_AND_PACK_RGB(S1, iofs0[3], cn, v1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for "loosen the threshold", I think you just forget to load next offset of bilinear lookup table.

int offset2 = FXY[x + 2] * 16;
int offset3 = FXY[x + 3] * 16;

w00 = v_load(wtab + offset2);
w01 = v_load(wtab + offset2 + 8);
w10 = v_load(wtab + offset3);
w11 = v_load(wtab + offset3 + 8);

@tomoaki0705
tomoaki0705 force-pushed the universalRemap branch 2 times, most recently from b0bb8ad to 837e6da Compare March 28, 2018 09:12
@tomoaki0705

Copy link
Copy Markdown
Contributor Author

Thank you @seiko2plus, indeed that's my mistake.
I appreciate your review, and nice check!

Though we had a nice review from @seiko2plus , still I had to loosen the check on opencv_perf_imgproc
The reason is rounding error.
I'd like to explain more clearly.

Normal rounding error

Let's think of linear interpolation. It's take a weighted average of 4 pixels. Simply writing

d[y*w+x] = s[y*w+x-1]*f0 + s[y*w+x]*f1 + s[(y-1)*w+x]*f2 + s[(y-1)*w+x-1]*f3

and this will have 4 multiply and 3 add in float.
In another word, it's happening in f and s.
This may cause a rounding error, but usually the difference is relatively small, and could only differ 1 when we convert back the value in integer (in worst case).
So, that's the reason we have eps=1 in the test cases, and this is reasonable.

Rounding error in this PR

Now, image warping is a coordinate computation in float.
Simply writing, the above code becomes like following.

x = (dx * fx0 + dy * fx1 + fz)  / (dx * g0 + dy * g1)
y = (dx * fy0 + dy * fy1 + fz) / (dx * g0 + dy * g1)
dx[dy*w+dx] = .....// same as above

So now the rounding error happens not only on f and s but to x and y
This means that the source data becomes totally different, and there is no guarantee that the difference becomes smaller than 1.

Though, still this rarely happens, so it's almost impossible to tell the difference just viewing the output image by human eye.
Still, comparing the difference in the difference of pixel value, is nonsense.

solution used in this PR

I added a dirty workaround in the verify of ts module.
At least this will let the test pass, but probably I need to brush up this implementation.

My point is, due to the rounding error, we need to loosen the verify in opencv_perf_imgproc.

@tomoaki0705

Copy link
Copy Markdown
Contributor Author

Am I supposed to fix the test failure on Mac machine ?
I feel it's irrelevant to my fix, though.

@alalek

alalek commented Mar 29, 2018

Copy link
Copy Markdown
Member

3/3 Mac builder failures.
I will take a look on the stacktrace under debugger.

@alalek

alalek commented Mar 29, 2018

Copy link
Copy Markdown
Member

Code tries to read after the buffer end.
Get commit from this branch: https://github.com/alalek/opencv/commits/pr11169_r
Compile it on Linux (debug mode should work too).
Run:

gdb -ex run --args ./bin/opencv_test_features2d --gtest_filter=BRISK/DescriptorRotationInvariance.rotation/0

(don't run all tests at once, this patch has huge memory leaks)

Details
0x00007ffff3ee1090 in cv::RemapVec_8u::operator() (this=0x7ffec70a3afe, _src=..., _dst=0x7ffecdae03e6, XY=0x7ffec70a5bd8, FXY=0x7ffeb8393204, _wtab=0x7ffff651cae0 <cv::BilinearTab_i>, 
    width=30) at /home/alalek/projects/opencv/dev/modules/imgproc/src/imgwarp.cpp:542
542	                CV_PICK_AND_PACK_RGB(S1, iofs0[0], cn, v0);
(gdb) p S1
$1 = (const uchar *) 0x7ffff7e96480
(gdb) p iofs0[0]
$2 = 330618
(gdb) p cn
$3 = 3
(gdb) p S1+iofs0[0]+cn
$4 = (const uchar *) 0x7ffff7ee6ffd "\023\026\030"
(gdb) p S1+iofs0[0]+cn+4
$5 = (const uchar *) 0x7ffff7ee7001 ""

seiko2plus pushed a commit to seiko2plus/opencv that referenced this pull request Mar 29, 2018
  * use universal intrinsic instead of raw intrinsic
  * add 2 channels de-interleave on x86 platform
  * implement loose verify in performance check
seiko2plus pushed a commit to seiko2plus/opencv that referenced this pull request Mar 29, 2018
  * use universal intrinsic instead of raw intrinsic
  * add 2 channels de-interleave on x86 platform
  * implement loose verify in performance check
@tomoaki0705

Copy link
Copy Markdown
Contributor Author

I really appreciate your help, @alalek ( I always say this but this time was way difficult to figure out )

I was reading out of the buffer.
The reading part was as is before, so this bug did exist previously.
I modified the coordinate, and probably one of the pixel went to the edge of the image.
That explains the situation.

Comment thread modules/imgproc/src/imgwarp.cpp Outdated
v_int16x8 xy2ofs = v_reinterpret_as_s16(v_setall_s32(cn + (sstep << 16)));
int CV_DECL_ALIGNED(16) iofs0[4], iofs1[4];

#define CV_PICK_AND_PACK_RGB(ptr, offset, cn, result) \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cn is not used here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'll fix this

Comment thread modules/imgproc/src/imgwarp.cpp Outdated
v_uint8x16 rgb1 = v_uint8x16(p[offset+3],p[offset+4],p[offset+5], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); \
v_zip(rgb0, rgb1, rrggbb, dummy); \
v_expand(rrggbb, rrggbb8, dummy8); \
result = v_reinterpret_as_s16(rrggbb8); \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need here zip/expand vector intrinsics?

result = v_int16x8((short)p[offset+0], (short)p[offset+3], (short)p[offset+1], (short)p[offset+4], (short)p[offset+2], (short)p[offset+5], 0, 0);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason I implemented this way is that I followed the previous way.
Yeah, your suggestion look better.

@seiko2plus

Copy link
Copy Markdown
Contributor

@tomoaki0705,

I added new universal intrinsic, they look like already exists on vsx, but I'd like to ask your review.
v_load_deinterleave(const short*, v_int16x8& a, v_int16x8& b);
v_load_deinterleave(const ushort*, v_uint16x8& a, v_uint16x8& b);

Yes, they already implemented on VSX and I'll provide performance comparison for ppc64le later.

Thank you @seiko2plus, indeed that's my mistake.
I appreciate your review, and nice check!
Though we had a nice review from @seiko2plus , still I had to loosen the check on opencv_perf_imgproc
The reason is rounding error.
I'd like to explain more clearly.
......

You are very welcome and thank you for the clarification.

Comment thread modules/imgproc/src/imgwarp.cpp Outdated
d0 = v_load((int*)(wtab+FXY[x+3]*4));
v_transpose4x4(a0, b0, c0, d0, a1, b1, c1, d1);
v0 = v_dotprod(v_reinterpret_as_s16(v0), v_reinterpret_as_s16(a1));
v1 = v_dotprod(v_reinterpret_as_s16(v1), v_reinterpret_as_s16(b1));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better if we load the lower 64 bits using "v_load_low" as it was before?
note: wtab has special case for 1 channel

const short* wtab = cn == 1 ? (const short*)_wtab : &BilinearTab_iC4[0][0][0];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, let's keep the v_load_low

@tomoaki0705
tomoaki0705 force-pushed the universalRemap branch 2 times, most recently from 858cdda to f5caadb Compare March 30, 2018 13:49
@tomoaki0705

Copy link
Copy Markdown
Contributor Author

Hmm, it's seems that on some modes, this PR degrades the performance.
I'll look for a bit.

@seiko2plus

seiko2plus commented Apr 3, 2018 •

Copy link
Copy Markdown
Contributor

Yes indeed, I did some performance tests on ppc64le and I got a lot of performance lose.. the comparison has been tested only on Remap(8UC4) for now, since I had to write SIMD code by using raw VSX intrinsics.

VSX raw which has been used in comparison
// just for 4 channel 

#define VSX_PICK_AND_PACK_RGB(ptr, offset, cn, rs)                        \
do {                                                                      \
    vec_char16 a = vec_char16_c(vec_int4_sp(*(int*)(ptr + offset)));      \
    vec_char16 b = vec_char16_c(vec_int4_sp(*(int*)(ptr + offset + cn))); \
    rs = vec_short8_c(vec_mergeh(vec_mergeh(a, b), vec_char16_z));        \
} while(0)


for( ; x <= width - 4; x += 4, D += 16 )
{
    vsx_st(vec_msum(vsx_ld(x * 2, XY), xy2ofs.val, vec_int4_z), 0, iofs0);

    vec_short8 u0, v0, u1, v1;
    VSX_PICK_AND_PACK_RGB(S0, iofs0[0], cn, u0);
    VSX_PICK_AND_PACK_RGB(S1, iofs0[0], cn, v0);
    VSX_PICK_AND_PACK_RGB(S0, iofs0[1], cn, u1);
    VSX_PICK_AND_PACK_RGB(S1, iofs0[1], cn, v1);

    int offset0 = FXY[x] * 16;
    int offset1 = FXY[x + 1] * 16;

    vec_short8 w00 = vsx_ld(offset0, wtab);
    vec_short8 w01 = vsx_ld(offset0 + 8, wtab);
    vec_short8 w10 = vsx_ld(offset1, wtab);
    vec_short8 w11 = vsx_ld(offset1 + 8, wtab);

    vec_int4 u0_4 = vec_msum(u0, w00, vec_msum(v0, w01, delta.val));
    vec_int4 u1_4 = vec_msum(u1, w10, vec_msum(v1, w11, delta.val));

    const vec_uint4 v_coef_bits = vec_uint4_sp(INTER_REMAP_COEF_BITS);
    u0_4 = vec_sra(u0_4, v_coef_bits);
    u1_4 = vec_sra(u1_4, v_coef_bits);

    u0 = vec_packs(u0_4, u1_4);
    vec_st_l8(vec_packsu(u0, u0), D);

    int offset2 = FXY[x + 2] * 16;
    int offset3 = FXY[x + 3] * 16;

    w00 = vsx_ld(offset2, wtab);
    w01 = vsx_ld(offset2 + 8, wtab);
    w10 = vsx_ld(offset3, wtab);
    w11 = vsx_ld(offset3 + 8, wtab);

    VSX_PICK_AND_PACK_RGB(S0, iofs0[2], cn, u0);
    VSX_PICK_AND_PACK_RGB(S1, iofs0[2], cn, v0);
    VSX_PICK_AND_PACK_RGB(S0, iofs0[3], cn, u1);
    VSX_PICK_AND_PACK_RGB(S1, iofs0[3], cn, v1);

    u0_4 = vec_msum(u0, w00, vec_msum(v0, w01, delta.val));
    u1_4 = vec_msum(u1, w10, vec_msum(v1, w11, delta.val));
    u0_4 = vec_sra(u0_4, v_coef_bits);
    u1_4 = vec_sra(u1_4, v_coef_bits);

    u0 = vec_packs(u0_4, u1_4);
    vec_st_l8(vec_packsu(u0, u0), D + 8);
}

test results

Name of Test Raw VSX UNV and PACK_RGB v_zip/v_expand UNV and PACK_RGB current
Test(8UC4, 1280x720, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 3.971 ms 5.078 ms 12.850 ms
Test(8UC4, 1280x720, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 4.097 ms 5.181 ms 13.055 ms
Test(8UC4, 1280x720, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 4.095 ms 5.175 ms 13.046 ms
Test(8UC4, 1280x720, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 4.096 ms 5.152 ms 12.902 ms
Test(8UC4, 1280x720, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 3.997 ms 5.055 ms 13.066 ms
Test(8UC4, 1280x720, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 4.106 ms 5.137 ms 12.930 ms
Test(8UC4, 1280x720, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 4.039 ms 5.138 ms 13.126 ms
Test(8UC4, 1280x720, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 4.039 ms 5.138 ms 13.090 ms
Test(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 8.978 ms 11.553 ms 29.014 ms
Test(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 9.203 ms 11.728 ms 29.147 ms
Test(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 9.181 ms 11.812 ms 29.379 ms
Test(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 9.142 ms 11.722 ms 29.252 ms
Test(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 9.099 ms 11.550 ms 29.189 ms
Test(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 9.260 ms 11.671 ms 29.451 ms
Test(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 9.110 ms 11.649 ms 29.583 ms
Test(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 9.165 ms 11.580 ms 29.282 ms
Test(8UC4, 640x480, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 1.572 ms 1.988 ms 5.144 ms
Test(8UC4, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 1.599 ms 2.030 ms 5.150 ms
Test(8UC4, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 1.636 ms 2.075 ms 5.165 ms
Test(8UC4, 640x480, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 1.599 ms 2.023 ms 5.144 ms
Test(8UC4, 640x480, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 1.561 ms 1.995 ms 5.108 ms
Test(8UC4, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 1.620 ms 2.035 ms 5.103 ms
Test(8UC4, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 1.595 ms 2.041 ms 5.125 ms
Test(8UC4, 640x480, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 1.591 ms 2.042 ms 5.108 ms

@tomoaki0705, so I think if you could combine this patch bf1852d with yours and improve PACK_RGB to be close to VSX raw then we will get the exact performance on ppc64le by using universal intrinsics , I didn't run any tests on SSE or NEON yet but I'm kinda sure the same needed for them.

@tomoaki0705

tomoaki0705 commented Apr 10, 2018 •

Copy link
Copy Markdown
Contributor Author

So it took very long time to check the performance degrade.

Also, The result became so large, I pasted on gist.(To be Updated)
The result on Arm32bit
The result on Arm64bit
The result on x86_64

Now, I extracted some results here
Please note that result on x86_64 with INTER_LINEAR has performance degradation
This is due to the modification of the memory access.
Previously it was accessing via int but now accessing via cahr
*(int*)(S0 + iofs0[0])) to p[offset], p[offset+1], (short)p[offset+2]

As it's clear in this PR, this access has a chance to access after the buffer, so it's dangerous.
Thus, this degradation is inevitable.

Please let me know if there's any modification required.

ODROID-X2 Ubuntu 14.04 Cortex A9 Quad-core 1.7GHz

  • GCC 4.8
Name of Test fdd83e5 3533531 3533531 vs fdd83e5 (x-factor)
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 47.609 ms 41.584 ms 1.14
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 50.593 ms 43.857 ms 1.15
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 50.830 ms 44.223 ms 1.15
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 47.904 ms 40.800 ms 1.17
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 47.376 ms 41.836 ms 1.13
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 50.364 ms 43.679 ms 1.15
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 50.698 ms 44.158 ms 1.15
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 47.629 ms 41.407 ms 1.15
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 23.887 ms 22.560 ms 1.06
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 30.556 ms 29.841 ms 1.02
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 30.639 ms 29.779 ms 1.03
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 25.480 ms 24.255 ms 1.05
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 24.049 ms 22.224 ms 1.08
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 30.428 ms 29.775 ms 1.02
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 30.918 ms 30.138 ms 1.03

ODROID-C2 Cortex A53 1.5GHz

  • GCC 5.4.0
Name of Test fdd83e5 3533531 3533531 vs fdd83e5 (x-factor)
remap::TestRemap::(8UC4, 1280x720, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 14.482 ms 9.398 ms 1.54
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 61.262 ms 43.209 ms 1.42
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 62.597 ms 43.793 ms 1.43
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 63.005 ms 44.122 ms 1.43
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 62.509 ms 43.835 ms 1.43
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 61.734 ms 43.227 ms 1.43
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 62.648 ms 43.745 ms 1.43
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 63.050 ms 43.931 ms 1.44
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 62.309 ms 44.016 ms 1.42
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 29.998 ms 18.028 ms 1.66
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 32.357 ms 20.392 ms 1.59
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 32.314 ms 20.520 ms 1.57
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 31.311 ms 19.719 ms 1.59
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 30.131 ms 17.955 ms 1.68
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 32.374 ms 20.440 ms 1.58
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 32.266 ms 20.498 ms 1.57
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 31.405 ms 19.639 ms 1.60

Windows x86_64 Corei7 7700K Quad-core 4GHz

  • Visual Studio 2015 Pro Update 3
Name of Test fdd83e5 3533531 3533531 vs fdd83e5 (x-factor)
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 2.475 ms 6.100 ms 0.41
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 2.661 ms 5.844 ms 0.46
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 2.635 ms 5.503 ms 0.48
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 2.534 ms 5.391 ms 0.47
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 2.494 ms 5.140 ms 0.49
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 2.628 ms 5.152 ms 0.51
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 2.595 ms 5.226 ms 0.50
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 2.571 ms 5.140 ms 0.50
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 1.933 ms 1.853 ms 1.04
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 1.892 ms 1.955 ms 0.97
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 2.074 ms 1.989 ms 1.04
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 1.868 ms 1.952 ms 0.96
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 1.756 ms 2.010 ms 0.87
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 2.371 ms 2.446 ms 0.97
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 2.456 ms 1.973 ms 1.24
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 2.005 ms 2.141 ms 0.94

@tomoaki0705
tomoaki0705 force-pushed the universalRemap branch 3 times, most recently from c87fb2e to d275826 Compare April 10, 2018 11:58
Comment thread modules/imgproc/src/imgwarp.cpp Outdated
v_int16x8 w01 = v_load(wtab + offset0 + 8);
v_int16x8 w10 = v_load(wtab + offset1);
v_int16x8 w11 = v_load(wtab + offset1 + 8);
CV_PICK_AND_PACK_RGB(S0, iofs0[0], u0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be separate macro CV_PICK_AND_PACK_RGBA() (not RGB).
Also there is no issue with buffer overrun with 8UC4.
Something like this:

#define CV_PICK_AND_PACK_RGBA(ptr, offset, result) \
        { \
            const uchar* const p = ((const uchar*)ptr) + (offset); \
            CV_DbgAssert(p <= _src.datalimit - 8); \
            v_uint8x16 rrggbb, dummy; \
            v_uint16x8 rrggbb8, dummy8; \
            v_uint8x16 rgb0 = v_reinterpret_as_u8(v_int32x4(*(int*)(p), 0, 0, 0)); \
            v_uint8x16 rgb1 = v_reinterpret_as_u8(v_int32x4(*(int*)(p + 4), 0, 0, 0)); \
            v_zip(rgb0, rgb1, rrggbb, dummy); \
            v_expand(rrggbb, rrggbb8, dummy8); \
            result = v_reinterpret_as_s16(rrggbb8); \
        }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I added CV_PICK_AND_PACK_RGBA

Comment thread modules/imgproc/src/imgwarp.cpp Outdated
unsigned char* p = (unsigned char*)ptr; \
result = v_int16x8((short)p[offset], (short)p[offset+3], /* r0r1 */ \
(short)p[offset+1], (short)p[offset+4], /* g0g1 */ \
(short)p[offset+2], (short)p[offset+5], /* b0b1 */ 0, 0); \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buffer overrun is very rare case here, so we can use check here:

#define CV_PICK_AND_PACK_RGB(ptr, offset, result) \
        { \
            const uchar* const p = ((const uchar*)ptr) + (offset); \
            if (p <= src_limit_8bytes) \
            { \
                v_uint8x16 rrggbb, dummy; \
                v_uint16x8 rrggbb8, dummy8; \
                v_uint8x16 rgb0 = v_reinterpret_as_u8(v_int32x4(*(int*)(p), 0, 0, 0)); \
                v_uint8x16 rgb1 = v_reinterpret_as_u8(v_int32x4(*(int*)(p + 3), 0, 0, 0)); \
                v_zip(rgb0, rgb1, rrggbb, dummy); \
                v_expand(rrggbb, rrggbb8, dummy8); \
                result = v_reinterpret_as_s16(rrggbb8); \
            } \
            else \
            { \
                result = v_int16x8((short)p[0], (short)p[3], /* r0r1 */ \
                                   (short)p[1], (short)p[4], /* g0g1 */ \
                                   (short)p[2], (short)p[5], /* b0b1 */ 0, 0); \
            } \
        }

where

const uchar* src_limit_8bytes = _src.datalimit - 8;

Alternatively we can try reading "int" + "short casted to int".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I followed your comment

Comment thread modules/imgproc/src/imgwarp.cpp Outdated
else if( cn == 3 )
{
for( ; x <= width - 5; x += 4, D += 12 )
for( ; x <= width - 15; x += 4, D += 12 )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why loop range is changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched back to "5", but still 5 doesn't look correct either.
Maybe "3" or "cn" stands better

ERROR_ABSOLUTE = 0,
ERROR_RELATIVE = 1
ERROR_RELATIVE = 1,
ERROR_LOOSE = 2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert these changes in test framework.
You can use SANITY_CHECK_NOTHING() in perf tests if reliable check is not possible (like these warp operations).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted ERROR_LOOSE and added SANITY_CHECK_NOTHING in some tests
Thank you

Implemented only for 16-bit signed source type (v_int16x8).
*/

inline v_int32x4 v_dotprod_add(const v_int16x8& a, const v_int16x8& b, const v_int32x4& c)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can reuse v_dotprod() name with additonal parameter for initial accumulator value.

/cc @mshabunin ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this part was bit suspicious.
If we combine v_dotprod and v_dotprod_add there might be unnecessary "Plus Zero" operation every where in the source code.
I did some experiments, and at least Visual Studio seems to be good enough to wipe out "Plus Zero" instruction.
I hope GCC is good enough too, so I reverted v_dotprod_add and combined with the existing v_dotprod.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean adding of just v_dotprod() overload with three params. No need to touch old function with 2 parameters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I've missed this comment.
Let me put back the v_dotprod

@@ -231,7 +231,7 @@ PERF_TEST_P( TestRemap, remap,
remap(source, destination, map_x, map_y, interpolationType, borderMode);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8UC3 case is not covered by tests.
Perhaps we need to add test for 8UC3 (to keep perf tests set compact we can remove sz720p (it is highly correlates with 1080p)):

Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1),
Values(szVGA, sz1080p),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the test condition

Comment thread modules/imgproc/src/imgwarp.cpp Outdated
#include "opencv2/core/openvx/ovx_defs.hpp"
#include "imgwarp.hpp"

#include <iostream>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, It was the debug use.
I reverted. Thank you

Comment thread modules/ts/src/ts_perf.cpp Outdated
#define OVER_EPS(name,eps) (eps < fabs(actual_##name - expect_##name))
void Regression::verifyLoose(cv::FileNode node, cv::Mat actual, double eps, std::string argname, ERROR_TYPE err)
{
if (!actual.empty() && actual.dims < 2) return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps these changes are not needed too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more modification left in the ts module

@tomoaki0705

tomoaki0705 commented Apr 13, 2018 •

Copy link
Copy Markdown
Contributor Author

Just a quick check on x86_64
No degradation confirmed.

If precise check needed, I'll update the check next week.
Core i7 8650U 1.9GHz Win10 64bit

Median

Name of Test remap.before remap.after remap.after vs remap.before (x-factor)
remap::TestRemap::(8UC1, 640x480, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 0.720 ms 0.709 ms 1.02
remap::TestRemap::(8UC1, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 0.715 ms 0.712 ms 1.00
remap::TestRemap::(8UC1, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 0.719 ms 0.712 ms 1.01
remap::TestRemap::(8UC1, 640x480, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 0.734 ms 0.720 ms 1.02
remap::TestRemap::(8UC1, 640x480, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 0.689 ms 0.704 ms 0.98
remap::TestRemap::(8UC1, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 0.698 ms 0.709 ms 0.98
remap::TestRemap::(8UC1, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 0.695 ms 0.708 ms 0.98
remap::TestRemap::(8UC1, 640x480, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 0.695 ms 0.712 ms 0.98
remap::TestRemap::(8UC1, 640x480, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 0.277 ms 0.278 ms 1.00
remap::TestRemap::(8UC1, 640x480, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 0.274 ms 0.283 ms 0.97
remap::TestRemap::(8UC1, 640x480, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 0.280 ms 0.280 ms 1.00
remap::TestRemap::(8UC1, 640x480, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 0.280 ms 0.279 ms 1.00
remap::TestRemap::(8UC1, 640x480, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 0.272 ms 0.285 ms 0.96
remap::TestRemap::(8UC1, 640x480, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 0.297 ms 0.284 ms 1.05
remap::TestRemap::(8UC1, 640x480, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 0.287 ms 0.285 ms 1.01
remap::TestRemap::(8UC1, 640x480, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 0.277 ms 0.284 ms 0.98
remap::TestRemap::(8UC1, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 3.947 ms 3.653 ms 1.08
remap::TestRemap::(8UC1, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 4.077 ms 3.838 ms 1.06
remap::TestRemap::(8UC1, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 4.001 ms 3.706 ms 1.08
remap::TestRemap::(8UC1, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 4.057 ms 3.660 ms 1.11
remap::TestRemap::(8UC1, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 3.978 ms 3.752 ms 1.06
remap::TestRemap::(8UC1, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 4.061 ms 3.873 ms 1.05
remap::TestRemap::(8UC1, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 4.096 ms 3.834 ms 1.07
remap::TestRemap::(8UC1, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 4.055 ms 3.776 ms 1.07
remap::TestRemap::(8UC1, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 1.699 ms 1.995 ms 0.85
remap::TestRemap::(8UC1, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 1.802 ms 1.720 ms 1.05
remap::TestRemap::(8UC1, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 1.722 ms 1.718 ms 1.00
remap::TestRemap::(8UC1, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 1.728 ms 1.802 ms 0.96
remap::TestRemap::(8UC1, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 1.749 ms 1.700 ms 1.03
remap::TestRemap::(8UC1, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 1.796 ms 1.759 ms 1.02
remap::TestRemap::(8UC1, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 1.835 ms 1.772 ms 1.04
remap::TestRemap::(8UC1, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 1.771 ms 1.737 ms 1.02
remap::TestRemap::(32FC1, 640x480, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 1.009 ms 0.945 ms 1.07
remap::TestRemap::(32FC1, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 0.923 ms 0.929 ms 0.99
remap::TestRemap::(32FC1, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 0.929 ms 0.934 ms 1.00
remap::TestRemap::(32FC1, 640x480, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 1.010 ms 0.930 ms 1.09
remap::TestRemap::(32FC1, 640x480, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 0.915 ms 0.918 ms 1.00
remap::TestRemap::(32FC1, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 0.923 ms 0.930 ms 0.99
remap::TestRemap::(32FC1, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 0.929 ms 0.929 ms 1.00
remap::TestRemap::(32FC1, 640x480, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 0.939 ms 0.929 ms 1.01
remap::TestRemap::(32FC1, 640x480, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 0.264 ms 0.250 ms 1.06
remap::TestRemap::(32FC1, 640x480, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 0.271 ms 0.268 ms 1.01
remap::TestRemap::(32FC1, 640x480, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 0.271 ms 0.264 ms 1.03
remap::TestRemap::(32FC1, 640x480, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 0.269 ms 0.258 ms 1.04
remap::TestRemap::(32FC1, 640x480, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 0.279 ms 0.262 ms 1.06
remap::TestRemap::(32FC1, 640x480, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 0.279 ms 0.271 ms 1.03
remap::TestRemap::(32FC1, 640x480, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 0.277 ms 0.270 ms 1.03
remap::TestRemap::(32FC1, 640x480, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 0.269 ms 0.268 ms 1.01
remap::TestRemap::(32FC1, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 4.761 ms 4.752 ms 1.00
remap::TestRemap::(32FC1, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 5.050 ms 5.175 ms 0.98
remap::TestRemap::(32FC1, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 4.839 ms 4.913 ms 0.98
remap::TestRemap::(32FC1, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 4.950 ms 4.786 ms 1.03
remap::TestRemap::(32FC1, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 5.023 ms 4.995 ms 1.01
remap::TestRemap::(32FC1, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 5.089 ms 4.924 ms 1.03
remap::TestRemap::(32FC1, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 5.027 ms 5.102 ms 0.99
remap::TestRemap::(32FC1, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 5.033 ms 5.110 ms 0.98
remap::TestRemap::(32FC1, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 2.077 ms 2.097 ms 0.99
remap::TestRemap::(32FC1, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 2.375 ms 2.410 ms 0.99
remap::TestRemap::(32FC1, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 2.347 ms 2.433 ms 0.96
remap::TestRemap::(32FC1, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 2.314 ms 2.378 ms 0.97
remap::TestRemap::(32FC1, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 2.068 ms 2.105 ms 0.98
remap::TestRemap::(32FC1, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 2.342 ms 2.403 ms 0.97
remap::TestRemap::(32FC1, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 2.363 ms 2.423 ms 0.98
remap::TestRemap::(32FC1, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 2.334 ms 2.355 ms 0.99
remap::TestRemap::(8UC3, 640x480, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 0.969 ms 1.079 ms 0.90
remap::TestRemap::(8UC3, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 0.956 ms 1.109 ms 0.86
remap::TestRemap::(8UC3, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 0.991 ms 1.107 ms 0.89
remap::TestRemap::(8UC3, 640x480, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 0.962 ms 1.118 ms 0.86
remap::TestRemap::(8UC3, 640x480, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 0.930 ms 1.074 ms 0.87
remap::TestRemap::(8UC3, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 0.952 ms 1.102 ms 0.86
remap::TestRemap::(8UC3, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 0.958 ms 1.103 ms 0.87
remap::TestRemap::(8UC3, 640x480, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 0.965 ms 1.098 ms 0.88
remap::TestRemap::(8UC3, 640x480, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 0.489 ms 0.469 ms 1.04
remap::TestRemap::(8UC3, 640x480, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 0.474 ms 0.477 ms 0.99
remap::TestRemap::(8UC3, 640x480, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 0.476 ms 0.468 ms 1.02
remap::TestRemap::(8UC3, 640x480, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 0.468 ms 0.471 ms 0.99
remap::TestRemap::(8UC3, 640x480, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 0.490 ms 0.465 ms 1.05
remap::TestRemap::(8UC3, 640x480, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 0.497 ms 0.470 ms 1.06
remap::TestRemap::(8UC3, 640x480, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 0.493 ms 0.474 ms 1.04
remap::TestRemap::(8UC3, 640x480, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 0.494 ms 0.473 ms 1.05
remap::TestRemap::(8UC3, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 5.039 ms 5.560 ms 0.91
remap::TestRemap::(8UC3, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 5.092 ms 5.741 ms 0.89
remap::TestRemap::(8UC3, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 5.134 ms 5.715 ms 0.90
remap::TestRemap::(8UC3, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 5.000 ms 5.642 ms 0.89
remap::TestRemap::(8UC3, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 4.992 ms 5.562 ms 0.90
remap::TestRemap::(8UC3, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 5.240 ms 5.762 ms 0.91
remap::TestRemap::(8UC3, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 5.143 ms 5.635 ms 0.91
remap::TestRemap::(8UC3, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 5.089 ms 5.641 ms 0.90
remap::TestRemap::(8UC3, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 2.581 ms 2.652 ms 0.97
remap::TestRemap::(8UC3, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 2.795 ms 2.801 ms 1.00
remap::TestRemap::(8UC3, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 2.807 ms 2.800 ms 1.00
remap::TestRemap::(8UC3, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 2.771 ms 2.786 ms 0.99
remap::TestRemap::(8UC3, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 2.708 ms 2.656 ms 1.02
remap::TestRemap::(8UC3, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 2.788 ms 2.698 ms 1.03
remap::TestRemap::(8UC3, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 2.831 ms 2.704 ms 1.05
remap::TestRemap::(8UC3, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 2.830 ms 2.673 ms 1.06
remap::TestRemap::(8UC4, 640x480, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 0.881 ms 1.039 ms 0.85
remap::TestRemap::(8UC4, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 0.879 ms 1.018 ms 0.86
remap::TestRemap::(8UC4, 640x480, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 0.890 ms 1.024 ms 0.87
remap::TestRemap::(8UC4, 640x480, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 0.926 ms 1.064 ms 0.87
remap::TestRemap::(8UC4, 640x480, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 0.855 ms 0.994 ms 0.86
remap::TestRemap::(8UC4, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 0.878 ms 1.024 ms 0.86
remap::TestRemap::(8UC4, 640x480, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 0.878 ms 1.010 ms 0.87
remap::TestRemap::(8UC4, 640x480, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 0.885 ms 1.010 ms 0.88
remap::TestRemap::(8UC4, 640x480, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 0.548 ms 0.519 ms 1.06
remap::TestRemap::(8UC4, 640x480, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 0.554 ms 0.531 ms 1.04
remap::TestRemap::(8UC4, 640x480, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 0.554 ms 0.532 ms 1.04
remap::TestRemap::(8UC4, 640x480, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 0.556 ms 0.511 ms 1.09
remap::TestRemap::(8UC4, 640x480, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 0.545 ms 0.521 ms 1.05
remap::TestRemap::(8UC4, 640x480, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 0.555 ms 0.538 ms 1.03
remap::TestRemap::(8UC4, 640x480, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 0.549 ms 0.532 ms 1.03
remap::TestRemap::(8UC4, 640x480, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 0.523 ms 0.531 ms 0.99
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, HALF_SIZE) 4.865 ms 5.355 ms 0.91
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_BOTH) 4.926 ms 5.390 ms 0.91
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, REFLECTION_X) 4.938 ms 5.340 ms 0.92
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_CONSTANT, UPSIDE_DOWN) 4.967 ms 5.096 ms 0.97
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, HALF_SIZE) 4.698 ms 5.267 ms 0.89
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_BOTH) 4.764 ms 5.403 ms 0.88
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, REFLECTION_X) 4.793 ms 5.394 ms 0.89
remap::TestRemap::(8UC4, 1920x1080, INTER_LINEAR, BORDER_REPLICATE, UPSIDE_DOWN) 4.694 ms 5.204 ms 0.90
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, HALF_SIZE) 3.168 ms 2.933 ms 1.08
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_BOTH) 3.297 ms 3.117 ms 1.06
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, REFLECTION_X) 3.369 ms 3.104 ms 1.09
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_CONSTANT, UPSIDE_DOWN) 3.347 ms 3.087 ms 1.08
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, HALF_SIZE) 3.081 ms 2.911 ms 1.06
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_BOTH) 3.224 ms 3.130 ms 1.03
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, REFLECTION_X) 3.232 ms 3.273 ms 0.99
remap::TestRemap::(8UC4, 1920x1080, INTER_NEAREST, BORDER_REPLICATE, UPSIDE_DOWN) 3.131 ms 3.110 ms 1.01

@alalek

alalek commented Apr 13, 2018

Copy link
Copy Markdown
Member

@tomoaki0705 Performance is fine to me (tested on Linux with i7-6700K).

int32x4x2_t cd = vuzpq_s32(c, d);
int32x4_t _c = vmull_s16(vget_low_s16(a.val), vget_low_s16(b.val));
int32x4_t _d = vmull_s16(vget_high_s16(a.val), vget_high_s16(b.val));
int32x4x2_t cd = vuzpq_s32(_c, _d);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need these renames?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to revert this part. updated.

v_reg<w_type, n/2> c;
v_reg<w_type, n/2> s;
for( int i = 0; i < (n/2); i++ )
c.s[i] = (w_type)a.s[i*2]*b.s[i*2] + (w_type)a.s[i*2+1]*b.s[i*2+1];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this rename change is not necessary.

OPENCV_HAL_IMPL_NEON_EXTRACT(float64x2, f64)
#endif

#if CV_SIMD128_64F

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fcvtns from AARCH64 only? (#if defined(__aarch64__))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's written on this p. 103

Comment thread modules/imgproc/perf/perf_warp.cpp Outdated
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"

#include "opencv2/ts/ts_perf.hpp"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this unnecessary include, it should be handled by perf_precomp.hpp (via opencv2/ts.hpp).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted. Thank you for the comment

  * use universal intrinsic instead of raw intrinsic
  * add 2 channels de-interleave on x86 platform
  * add v_int32x4 version of v_muladd
  * add accumulate version of v_dotprod based on the commit from seiko2plus on bf1852d
  * remove some verify check in performance test
  * avoid the out of boundary access and keep the performance

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you 👍

@opencv-pushbot
opencv-pushbot merged commit a82e70c into opencv:3.4 Apr 13, 2018
@tomoaki0705
tomoaki0705 deleted the universalRemap branch April 13, 2018 13:27
@alalek alalek mentioned this pull request Apr 16, 2018
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants