Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(444)

Issue 1881903004: Rewriting MatrixConvolution image filter with SSE and AVX2

Created:
4 years, 8 months ago by Sergey M
Modified:
4 years, 8 months ago
CC:
reviews_skia.org
Base URL:
https://skia.googlesource.com/skia@master
Target Ref:
refs/heads/master
Project:
skia
Visibility:
Public.

Description

Rewriting MatrixConvolution image filter with SSE and AVX2 1. Hottest part of SkMatrixConvolutionImageFilter was moved to opts/ folder. 2. Create SSE implementation for MatrixConvolution. Perf.gain ~ 2x over plain implementation. 3. Create AVX2 implementation for MatrixConvolution. Perf.gain ~ 2.5x over plain implementation. 4. Add runtime check for AVX2 availability (AVX2 implementation will be uses only if AVX2 is supported by HW). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1881903004 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+400 lines, -30 lines) Patch
M gyp/opts.gyp View 1 chunk +1 line, -1 line 1 comment Download
M gyp/opts.gypi View 2 chunks +4 lines, -0 lines 1 comment Download
M include/effects/SkMatrixConvolutionImageFilter.h View 1 chunk +0 lines, -5 lines 0 comments Download
M src/core/SkOpts.h View 1 chunk +12 lines, -0 lines 0 comments Download
M src/core/SkOpts.cpp View 2 chunks +12 lines, -1 line 0 comments Download
M src/effects/SkMatrixConvolutionImageFilter.cpp View 6 chunks +16 lines, -23 lines 2 comments Download
A src/opts/SkMatrixConvolutionImageFilter_opts.h View 1 chunk +71 lines, -0 lines 1 comment Download
A src/opts/SkMatrixConvolutionImageFilter_opts_AVX2.h View 1 chunk +31 lines, -0 lines 0 comments Download
A src/opts/SkMatrixConvolutionImageFilter_opts_AVX2.cpp View 1 chunk +112 lines, -0 lines 0 comments Download
A src/opts/SkMatrixConvolutionImageFilter_opts_SSE.h View 1 chunk +31 lines, -0 lines 0 comments Download
A src/opts/SkMatrixConvolutionImageFilter_opts_SSE.cpp View 1 chunk +76 lines, -0 lines 1 comment Download
A src/opts/SkOpts_avx2.cpp View 1 chunk +17 lines, -0 lines 0 comments Download
A src/opts/SkOpts_sse_sse2.cpp View 1 chunk +17 lines, -0 lines 0 comments Download

Messages

Total messages: 15 (4 generated)
Sergey M
Could you take a look at my changes: I implemented MatrixConvolution image filter with SSE ...
4 years, 8 months ago (2016-04-12 19:46:05 UTC) #4
Stephen White
Thanks for the patch! This is promising stuff. mtklein@ should definitely take a look as ...
4 years, 8 months ago (2016-04-12 20:01:59 UTC) #6
mtklein
I too would rather start with an Sk4f version inline in SkMatrixConvolutionImageFilter.cpp. After that lands ...
4 years, 8 months ago (2016-04-12 20:07:19 UTC) #7
Sergey M
On 2016/04/12 20:07:19, mtklein wrote: > I too would rather start with an Sk4f version ...
4 years, 8 months ago (2016-04-12 20:28:19 UTC) #8
mtklein
Hmm, that's odd. Why don't you post up your SkNx version so I can take ...
4 years, 8 months ago (2016-04-12 20:41:52 UTC) #9
Sergey M
On 2016/04/12 20:41:52, mtklein wrote: > Hmm, that's odd. Why don't you post up your ...
4 years, 8 months ago (2016-04-12 21:10:30 UTC) #10
mtklein
On 2016/04/12 at 21:10:30, Melnikov.Sergey.V wrote: > On 2016/04/12 20:41:52, mtklein wrote: > > Hmm, ...
4 years, 8 months ago (2016-04-12 21:11:47 UTC) #11
Sergey M
On 2016/04/12 21:11:47, mtklein wrote: > On 2016/04/12 at 21:10:30, Melnikov.Sergey.V wrote: > > On ...
4 years, 8 months ago (2016-04-13 22:47:30 UTC) #12
mtklein
> As I see you've already committed a version with SkNx implementation. It's not been ...
4 years, 8 months ago (2016-04-14 00:05:55 UTC) #13
Sergey M
On 2016/04/14 00:05:55, mtklein wrote: > > As I see you've already committed a version ...
4 years, 8 months ago (2016-04-14 23:53:12 UTC) #14
mtklein
4 years, 8 months ago (2016-04-15 14:03:41 UTC) #15
> I'll think how to enable AVX2 in SkNx with 'proper' way. I believe, first,
I'll think how to avoid a concrete vector length in algorithms with SkNx (I
mean, for example, you wrote particular vector length in your code: SkNx<4,
float>. It inhibited moving forward to AVX/AVX2 and so).

I agree that it'd be nicer to not have to know the register length.  But for
now, we could always just rewrite this in terms Sk8f.  SkNx<N,T> falls back
transparently to 2 SkNx<N/2,T> if it has no native support for N T's.

> About looking at AVX2. What do you think, what is the preferable way to enable
AVX/AVX2? Guard AVX/AVX2 code with #ifdef/#endif or implement a runtime check
with SkOpts or make in-place runtime check?

For AVX2, definitely a runtime check.  There are no clients of Skia that I'm
aware of building with -mavx2 globally, or -mavx, for that matter.  There are a
few up to -msse4.1.  But it's best to think SSE2 and NEON are nearly guaranteed
at compile time, SSE3 and SSSE3 are very likely at compile time, and anything
beyond that is unlikely.

I've just reorganized how to do these runtime checks.  Hopefully that change
sticks.
   #include "SkCpu.h"
   ...
   if (SkCpu::Supports(SkCpu::AVX2)) { 
       ...
   }

Powered by Google App Engine
This is Rietveld 408576698