[ovs-dev] [PATCH] util: Better count_1bits().

Jarno Rajahalme jrajahalme at nicira.com
Fri Dec 6 15:42:48 UTC 2013


On Dec 6, 2013, at 7:36 AM, Jarno Rajahalme <jrajahalme at nicira.com> wrote:
> On Dec 5, 2013, at 4:44 PM, Ben Pfaff <blp at nicira.com> wrote:
>> How did you measure the benefit of inlining?
> 
> With a standalone C program running different variants (original, inlined, different algorithm) over

I should mention that I linked with a stripped down version of lib/util.c, keeping the interesting parts, and more importantly, keeping them in a different compilation unit, like we do with OVS.

  Jarno

> randomized data of 10000 u64s about 100000 times and timing each algorithm with clock_gettime(CLOCK_THREAD_CPUTIME_ID). Compiled for 32 or 64 bits with -m32 or without, and for i7 with -march=native -mtune=native. I used -O2 as we compile OVS with -O2, too.
> 
> The alternate algorithm computes the popcount in parallel for the 64 bits (so it is equally fast for both 32 and 64 bits), while the recalculated array requires double the work for 64 bits, compared to 32 bits. But on the other hand, the array lookup is still faster for 32 bits.
> 
>   Jarno
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20131206/9b471495/attachment-0003.html>


More information about the dev mailing list