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

Issue 2014023002: Add clz functions (Count number of Leading Zero bits), 32-and 64-bit variants (Closed)

Created:
4 years, 7 months ago by kwiberg-webrtc
Modified:
4 years, 6 months ago
Reviewers:
tlegrand-webrtc
CC:
webrtc-reviews_webrtc.org, Andrew MacDonald, zhengzhonghou_agora.io, fengyue_agora.io, tterriberry_mozilla.com, audio-team_agora.io, henrika_webrtc, mflodman, peah-webrtc, minyue-webrtc, aluebs-webrtc, bjornv1
Base URL:
https://chromium.googlesource.com/external/webrtc.git@bug601787-1
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

Add clz functions (Count number of Leading Zero bits), 32-and 64-bit variants Using __builtin_clz on gcc/clang, and a fallback implementation otherwise. Also redefine WebRtcSpl_GetSizeInBits(x) as simply 32 - clz32(x). BUG=chromium:601787 Committed: https://crrev.com/729b21f97f3d849b1ef2bd61114e4b39d073884d Cr-Commit-Position: refs/heads/master@{#13014}

Patch Set 1 : #

Total comments: 2

Patch Set 2 : new algorithm #

Total comments: 2

Patch Set 3 : compile fix #

Patch Set 4 : Reimplement WebRtcSpl_Norm* with WebRtcSpl_CountLeadingZeros32 #

Total comments: 6

Patch Set 5 : fix comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+113 lines, -73 lines) Patch
M webrtc/common_audio/BUILD.gn View 1 1 chunk +1 line, -0 lines 0 comments Download
M webrtc/common_audio/common_audio.gyp View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M webrtc/common_audio/real_fourier.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M webrtc/common_audio/signal_processing/include/spl_inl.h View 1 2 3 4 2 chunks +59 lines, -68 lines 0 comments Download
M webrtc/common_audio/signal_processing/signal_processing_unittest.cc View 1 chunk +26 lines, -0 lines 0 comments Download
A webrtc/common_audio/signal_processing/spl_inl.c View 1 1 chunk +24 lines, -0 lines 0 comments Download
M webrtc/system_wrappers/include/compile_assert_c.h View 1 chunk +1 line, -4 lines 0 comments Download

Messages

Total messages: 19 (5 generated)
kwiberg-webrtc
4 years, 7 months ago (2016-05-25 23:49:23 UTC) #3
tlegrand-webrtc
I liked Patch Set 1 more than Patch Set 2. What was the reason for ...
4 years, 7 months ago (2016-05-26 12:01:47 UTC) #4
kwiberg-webrtc
https://codereview.chromium.org/2014023002/diff/40001/webrtc/common_audio/signal_processing/spl_inl.c File webrtc/common_audio/signal_processing/spl_inl.c (right): https://codereview.chromium.org/2014023002/diff/40001/webrtc/common_audio/signal_processing/spl_inl.c#newcode23 webrtc/common_audio/signal_processing/spl_inl.c:23: -1, 15, -1, 21, -1, 29, 19, -1, -1, ...
4 years, 7 months ago (2016-05-26 12:18:00 UTC) #5
kwiberg-webrtc
On 2016/05/26 12:01:47, tlegrand-webrtc wrote: > I liked Patch Set 1 more than Patch Set ...
4 years, 7 months ago (2016-05-26 13:03:08 UTC) #6
kwiberg-webrtc
(A little late, since you've already seen it, but...) Changed to another clz algorithm. A ...
4 years, 7 months ago (2016-05-26 13:04:25 UTC) #7
kwiberg-webrtc
On 2016/05/26 13:03:08, kwiberg-webrtc wrote: > On 2016/05/26 12:01:47, tlegrand-webrtc wrote: > > I liked ...
4 years, 7 months ago (2016-05-26 13:28:02 UTC) #8
tlegrand-webrtc
On 2016/05/26 13:28:02, kwiberg-webrtc wrote: > On 2016/05/26 13:03:08, kwiberg-webrtc wrote: > > On 2016/05/26 ...
4 years, 7 months ago (2016-05-26 14:18:52 UTC) #9
tlegrand-webrtc
Thanks for running the extra benchmark tests! LGTM with a small nit. https://codereview.webrtc.org/2014023002/diff/80001/webrtc/common_audio/signal_processing/include/spl_inl.h File webrtc/common_audio/signal_processing/include/spl_inl.h ...
4 years, 6 months ago (2016-06-02 09:49:11 UTC) #10
kwiberg-webrtc
https://codereview.webrtc.org/2014023002/diff/80001/webrtc/common_audio/signal_processing/include/spl_inl.h File webrtc/common_audio/signal_processing/include/spl_inl.h (right): https://codereview.webrtc.org/2014023002/diff/80001/webrtc/common_audio/signal_processing/include/spl_inl.h#newcode128 webrtc/common_audio/signal_processing/include/spl_inl.h:128: // Return the number of steps a can be ...
4 years, 6 months ago (2016-06-02 09:55:34 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2014023002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2014023002/100001
4 years, 6 months ago (2016-06-02 09:55:53 UTC) #14
commit-bot: I haz the power
Committed patchset #5 (id:100001)
4 years, 6 months ago (2016-06-02 11:02:18 UTC) #15
commit-bot: I haz the power
Patchset 5 (id:??) landed as https://crrev.com/729b21f97f3d849b1ef2bd61114e4b39d073884d Cr-Commit-Position: refs/heads/master@{#13014}
4 years, 6 months ago (2016-06-02 11:02:37 UTC) #17
jridges
On 2016/05/26 12:18:00, kwiberg-webrtc wrote: > https://codereview.chromium.org/2014023002/diff/40001/webrtc/common_audio/signal_processing/spl_inl.c > File webrtc/common_audio/signal_processing/spl_inl.c (right): > > https://codereview.chromium.org/2014023002/diff/40001/webrtc/common_audio/signal_processing/spl_inl.c#newcode23 > ...
4 years, 6 months ago (2016-06-02 16:15:53 UTC) #18
kwiberg-webrtc
4 years, 6 months ago (2016-06-02 16:54:33 UTC) #19
Message was sent while issue was closed.
On 2016/06/02 16:15:53, jridges wrote:
> On 2016/05/26 12:18:00, kwiberg-webrtc wrote:
> >
>
https://codereview.chromium.org/2014023002/diff/40001/webrtc/common_audio/sig...
> > File webrtc/common_audio/signal_processing/spl_inl.c (right):
> > 
> >
>
https://codereview.chromium.org/2014023002/diff/40001/webrtc/common_audio/sig...
> > webrtc/common_audio/signal_processing/spl_inl.c:23: -1, 15, -1, 21, -1, 29,
> 19,
> > -1, -1, -1, -1, -1, 1,  27, 5,  12,
> > On 2016/05/26 12:01:46, tlegrand-webrtc wrote:
> > > I would prefer keeping it as in Patch Set 1, since this add memory usage
for
> a
> > > function that should mostly be used in tests, right?
> > 
> > Yes, this global table adds 64 bytes to the program (about the same as a few
> > lines of code). But at each call site, the inlined code is ~50 instead of
~100
> > bytes (unless we use GCC or clang, in which case the inlined code is ~10
bytes
> > and doesn't use this table).
> > 
> > No, WebRtcSpl_CountLeadingZeros32_NotBuiltin isn't just used in tests (then
> what
> > would be the point?)---it's used wherever we don't use gcc or clang, such as
> on
> > Windows.
> > 
> > I could preprocessor-magick this table away if we're on GCC or clang, but
it's
> > going to be ugly since we still want the tests. Frankly, I'd rather lose the
> 64
> > bytes...
> 
> It might be worth it to use the _BitScanReverse intrinsic in Windows. I
believe
> it compiles to a single instruction.

Yes. I looked into that, but somewhy Microsoft has made it ridiculously
complicated to use, compared to __builtin_clz. I could add support for it, but
it's not just a question of five minutes.

For reference: https://msdn.microsoft.com/en-us/library/fbxyd7zd.aspx

Powered by Google App Engine
This is Rietveld 408576698