[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Rapp-dev] Pixelwise threshold and conditional pixel operations pathes
From: |
Willie Betschart |
Subject: |
[Rapp-dev] Pixelwise threshold and conditional pixel operations pathes |
Date: |
Fri, 22 Apr 2016 13:53:54 +0000 |
Dear Rapp-dev
I hereby submit two patches with concepts of two new functionalities.
The rapp_thresh_lt_pixel is a pixelwise threshold function, allowing the
developer to do more advanced thresholding. The tests and internal templates
are prepared for functions like rapp_thresh_gt_lt_pixel as well.
Conditional pixop addc and add is added to rapp_cond class. Efficient SIMD
implementation boost the conditional execution. It is constructed with
non-exotic SIMD instructions so it could be used widely. The gather-scatter
documentation states that conditional operations are not efficiently
implemented in SIMD, that was true before RC_VEC_SETMASKV. (I also submit a
NEON implementation of this backend macro.).
Why not using gather scatter instead? The reason is dependent on choice of use
case rather than a speed competitor. The conditional pixop is used when a
selection of pixels in an image should be updated with a single instruction and
then you continue to do processing on the same image. The drawback of doing
this with gather and scatter is described below.
Gather and scatter are superior when processing sequences of operations. Also
gathering is used to continue process selected parts of an image and creating
advanced rearrangements as described in the rapp documentation. A drawback is
costly overhead especially when only calculating a single pixop. Another
drawback is the tricky platform dependent pixel count limit of where gather
scatter increase the performance. You don't really know how sparse a mask will
be in advance and you have to setup a cpu budget for a scene with many objects.
That pixel count? limit is not easily set if you want platform independent
code. If it is a single conditional pixop you what to do with gather and
scatter, the implementation becomes a bit unnecessary complex and slower in
many cases than a single conditional pixop. Conditional pixops, as I
implemented it, are very simple to use and with SIMD fast as well, even with a
dense mask. Most architectures have some coprocessor nowadays.
I attach a c file where I accomplish the same thing with gather, addc, and
scatter and compare with a conditional addition with constant. This is the
typical use of a conditional pixop. The platform is host-x86_64 with sse2. I
attach a screendump with callgrind figures. As can be seen, in this comparison
the conditional addition is about 36x faster.
Best regards
Willie Betschart
?
cond_vs_gs.tar.gz
Description: cond_vs_gs.tar.gz
thresh-pixel.patch
Description: thresh-pixel.patch
cond-pixop-add.patch
Description: cond-pixop-add.patch
- [Rapp-dev] Pixelwise threshold and conditional pixel operations pathes,
Willie Betschart <=