diff options
author | Yanqin Wei <Yanqin.Wei@arm.com> | 2019-06-13 18:38:07 +0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2019-06-13 10:22:12 -0700 |
commit | a0f7bf222030f4cdbce0bda66bd9f2bc6983d9db (patch) | |
tree | ddda5ef1b145f693f0e7b6439e7ab4c9574b01b1 /lib/util.h | |
parent | 2adada0e3db2279c8386cc9ca7e19fd3003f04d6 (diff) | |
download | openvswitch-a0f7bf222030f4cdbce0bda66bd9f2bc6983d9db.tar.gz |
util: implement count_1bits with Neon intrinsics or gcc built-in for aarch64.
Userspace datapath needs to traverse through miniflow values many times. In
this process, 'count_1bits' operation for 'Flowmap' significantly impact
performance. On arm, this function was defined by portable implementation
because gcc for arm does not support popcnt feature.
But in the aarch64, VCNT neon instruction can accelerate "count_1bits".
From Gcc-7, the built-in function is implemented with neon intruction.
In this patch, count_1bits function will be impelmented with gcc built-in
from gcc-7 on, and with neon intrinsics in gcc-6.
Performance test was run in two aarch64 machines. In the NIC2NIC test, one
tuple dpcls lookup case achieves around 4% throughput improvement and
10(average) tuples case achieves around 5% improvement.
Tested-by: Malvika Gupta <malvika.gupta@arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei@arm.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/util.h')
-rw-r--r-- | lib/util.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/util.h b/lib/util.h index c26605abd..095ede20f 100644 --- a/lib/util.h +++ b/lib/util.h @@ -29,6 +29,9 @@ #include "compiler.h" #include "util.h" #include "openvswitch/util.h" +#if defined(__aarch64__) && __GNUC__ >= 6 +#include <arm_neon.h> +#endif extern char *program_name; @@ -356,8 +359,10 @@ log_2_ceil(uint64_t n) static inline unsigned int count_1bits(uint64_t x) { -#if __GNUC__ >= 4 && __POPCNT__ +#if (__GNUC__ >= 4 && __POPCNT__) || (defined(__aarch64__) && __GNUC__ >= 7) return __builtin_popcountll(x); +#elif defined(__aarch64__) && __GNUC__ >= 6 + return vaddv_u8(vcnt_u8(vcreate_u8(x))); #else /* This portable implementation is the fastest one we know of for 64 * bits, and about 3x faster than GCC 4.7 __builtin_popcountll(). */ |