Skip to content

spatialGradient() reworked to use wide universal intrinsics - #13693

Merged
alalek merged 2 commits into
opencv:3.4from
terfendail:spatialgrad_wintr
Jan 30, 2019
Merged

alalek merged 2 commits into
opencv:3.4from
terfendail:spatialgrad_wintr

Conversation

@terfendail

@terfendail terfendail commented Jan 25, 2019 •

Copy link
Copy Markdown
Contributor

This pullrequest changes

spatialGradient() reworked to use wide universal intrinsics

buildworker:Win64 OpenCL=windows-2

@terfendail

Copy link
Copy Markdown
Contributor Author
Performance for SSE2 baseline
Performance test Reference time PR time Speedup
spatialGradient::Size_Ksize_BorderType::(640x360, 3, 1) 0.070 0.069 1.01
spatialGradient::Size_Ksize_BorderType::(640x360, 3, 4) 0.067 0.067 0.99
spatialGradient::Size_Ksize_BorderType::(960x540, 3, 1) 0.146 0.156 0.94
spatialGradient::Size_Ksize_BorderType::(960x540, 3, 4) 0.145 0.155 0.94
spatialGradient::Size_Ksize_BorderType::(1280x720, 3, 1) 0.263 0.268 0.98
spatialGradient::Size_Ksize_BorderType::(1280x720, 3, 4) 0.254 0.271 0.94
spatialGradient::Size_Ksize_BorderType::(1920x1080, 3, 1) 0.582 0.599 0.97
spatialGradient::Size_Ksize_BorderType::(1920x1080, 3, 4) 0.567 0.591 0.96
Performance for SSE4_2 baseline
Performance test Reference time PR time Speedup
spatialGradient::Size_Ksize_BorderType::(640x360, 3, 1) 0.068 0.066 1.03
spatialGradient::Size_Ksize_BorderType::(640x360, 3, 4) 0.067 0.065 1.03
spatialGradient::Size_Ksize_BorderType::(960x540, 3, 1) 0.147 0.146 1.00
spatialGradient::Size_Ksize_BorderType::(960x540, 3, 4) 0.146 0.148 0.98
spatialGradient::Size_Ksize_BorderType::(1280x720, 3, 1) 0.245 0.254 0.96
spatialGradient::Size_Ksize_BorderType::(1280x720, 3, 4) 0.244 0.257 0.95
spatialGradient::Size_Ksize_BorderType::(1920x1080, 3, 1) 0.578 0.566 1.02
spatialGradient::Size_Ksize_BorderType::(1920x1080, 3, 4) 0.544 0.566 0.96
Performance for AVX2 baseline
Performance test Reference time PR time Speedup
spatialGradient::Size_Ksize_BorderType::(640x360, 3, 1) 0.066 0.068 0.96
spatialGradient::Size_Ksize_BorderType::(640x360, 3, 4) 0.064 0.067 0.96
spatialGradient::Size_Ksize_BorderType::(960x540, 3, 1) 0.146 0.143 1.02
spatialGradient::Size_Ksize_BorderType::(960x540, 3, 4) 0.149 0.145 1.02
spatialGradient::Size_Ksize_BorderType::(1280x720, 3, 1) 0.256 0.239 1.07
spatialGradient::Size_Ksize_BorderType::(1280x720, 3, 4) 0.259 0.240 1.08
spatialGradient::Size_Ksize_BorderType::(1920x1080, 3, 1) 0.584 0.523 1.12
spatialGradient::Size_Ksize_BorderType::(1920x1080, 3, 4) 0.585 0.520 1.12

Comment thread modules/imgproc/src/spatialgradient.cpp Outdated
if(hasSIMD128())
#if CV_SIMD
uchar *m_src;
short *n_dx, *n_dy;

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 these variables outside of the for loop below?

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.

Moved variables inside loops

Comment thread modules/imgproc/src/spatialgradient.cpp Outdated
{
uchar *p_src;//previous row
if ( i == 0 ) p_src = src.ptr<uchar>(i_top);
else p_src = src.ptr<uchar>(i-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.

const uchar *p_src = src.ptr<uchar>(( i == 0 ) ? i_top : i - 1);

Similar for m_src.

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.

fixed

@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 👍

@alalek
alalek merged commit 2f5af1b into opencv:3.4 Jan 30, 2019
@terfendail
terfendail deleted the spatialgrad_wintr branch January 31, 2019 11:29
@alalek alalek mentioned this pull request Feb 1, 2019
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
* spatialGradient() reworked to use wide universal intrinsics

* Moved row pointers inside loops
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.

2 participants