About vectorization and planar channels in Krita
boud at valdyas.org
Mon Oct 1 07:18:11 UTC 2012
On Friday 28 September 2012 Sep, Dmitry Kazakov wrote:
> After that long discussion about grayscale selections I decided to check
> whether we really need planar channels for implementing the vectorization
> in Krita. And it turned out, that we need *not* do it. The SIMD
> instructions cannot work with bytes directly (we won't be able to multiply
> anything), so in both of the cases, when we use planar bytes and not, we
> will have to convert the pixel data into some other format: single
> precision float or single word integer, doing some inevitable permutations
> and wasting time on them. The flat channels will give us no help with it.
> What we really need to do is just to use the advantages of RGBA pixel
> layout (better data locality and good alignment) and optimize our code. As
> a proof of concept, I've written a small benchmark, that compares our
> standard integer COMPOSITE_OVER algorithm against its SIMD (avx)
> implementation. The streamed implementation showed a 3.3 times better speed
> than the algorithm we use right now. More than that, this sketch was
> written in just a day so it has lots of possibilities for optimization (it
> can be modified to process 10.6 pixels at a time instead of 8, for example).
> The actual results of composing of 32 MPixels:
> TestAvxCompositeOverTest::testPerPixelComposition(): 370 msecs
> TestAvxCompositeOverTest::testAVXComposition(): 147 msecs
> TestAvxCompositeOverTest::testAVXCompositionx2(): 113 msecs
Well, that's very much worth it, I think. How about tackling the composite ops first, while we think about the selection issues? Please do use the Vc library when working on the composite ops in Krita, though, so we have only one api to learn.
> What I want to tell with this mail:
> 1) There is no need to port the whole Krita to use some other channel
> layouts. Even current layout gives us lots of possibilities to optimize our
Ok, that's good.
> 2) We still need to decide what to do with grayscale selections.
Yeah... Please go for optimization of the composite ops first, let's tackle this later.
http://www.valdyas.org, http://www.krita.org, http://www.boudewijnrempt.nl
More information about the kimageshop