The preprocessor comparison string to check AVX512 capabilities are
lengthy and effecting user readability. Simpify this by aliasing the checks.

Suggested-by: Eelco Chaudron <[email protected]>
Signed-off-by: Sunil Pai G <[email protected]>

---
v2: rebase on master, added alias for DPCLS.
    Remove the acks since there are changes introduced because of
    rebase.
---
 lib/dpif-netdev-lookup.c          |  8 ++++----
 lib/dpif-netdev-private-dpif.c    |  8 +++++---
 lib/dpif-netdev-private-extract.c |  6 ++----
 lib/dpif-netdev-private-extract.h | 10 +++++-----
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/dpif-netdev-lookup.c b/lib/dpif-netdev-lookup.c
index 6bcfb8ba8..4c1379aa5 100644
--- a/lib/dpif-netdev-lookup.c
+++ b/lib/dpif-netdev-lookup.c
@@ -22,9 +22,10 @@
 #include "openvswitch/vlog.h"
 
 VLOG_DEFINE_THIS_MODULE(dpif_netdev_lookup);
+#define DPCLS_IMPL_AVX512_CHECK (__x86_64__ && HAVE_AVX512F \
+    && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW && __SSE4_2__)
 
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \
-     && __SSE4_2__)
+#if DPCLS_IMPL_AVX512_CHECK
 static dpcls_subtable_lookup_func
 dpcls_subtable_avx512_gather_probe(uint32_t u0_bits, uint32_t u1_bits)
 {
@@ -61,8 +62,7 @@ static struct dpcls_subtable_lookup_info_t subtable_lookups[] 
= {
       .name = "generic",
       .usage_cnt = ATOMIC_COUNT_INIT(0), },
 
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \
-     && __SSE4_2__)
+#if DPCLS_IMPL_AVX512_CHECK
     /* Only available on x86_64 bit builds with SSE 4.2 used for OVS core. */
     { .prio = 0,
       .probe = dpcls_subtable_avx512_gather_probe,
diff --git a/lib/dpif-netdev-private-dpif.c b/lib/dpif-netdev-private-dpif.c
index 5ae119a30..ef4cee2ba 100644
--- a/lib/dpif-netdev-private-dpif.c
+++ b/lib/dpif-netdev-private-dpif.c
@@ -28,13 +28,15 @@
 #include "util.h"
 
 VLOG_DEFINE_THIS_MODULE(dpif_netdev_impl);
+#define DPIF_NETDEV_IMPL_AVX512_CHECK (__x86_64__ && HAVE_AVX512F \
+    && HAVE_LD_AVX512_GOOD && __SSE4_2__)
 
 enum dpif_netdev_impl_info_idx {
     DPIF_NETDEV_IMPL_SCALAR,
     DPIF_NETDEV_IMPL_AVX512
 };
 
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+#if DPIF_NETDEV_IMPL_AVX512_CHECK
 static int32_t
 dp_netdev_input_outer_avx512_probe(void)
 {
@@ -54,7 +56,7 @@ static struct dpif_netdev_impl_info_t dpif_impls[] = {
       .probe = NULL,
       .name = "dpif_scalar", },
 
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+#if DPIF_NETDEV_IMPL_AVX512_CHECK
     /* Only available on x86_64 bit builds with SSE 4.2 used for OVS core. */
     [DPIF_NETDEV_IMPL_AVX512] = { .input_func = dp_netdev_input_outer_avx512,
       .probe = dp_netdev_input_outer_avx512_probe,
@@ -73,7 +75,7 @@ dp_netdev_impl_get_default(void)
         int dpif_idx = DPIF_NETDEV_IMPL_SCALAR;
 
 /* Configure-time overriding to run test suite on all implementations. */
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+#if DPIF_NETDEV_IMPL_AVX512_CHECK
 #ifdef DPIF_AVX512_DEFAULT
         dp_netdev_input_func_probe probe;
 
diff --git a/lib/dpif-netdev-private-extract.c 
b/lib/dpif-netdev-private-extract.c
index bd6bb8d94..61258a7ac 100644
--- a/lib/dpif-netdev-private-extract.c
+++ b/lib/dpif-netdev-private-extract.c
@@ -34,8 +34,7 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev_extract);
 /* Variable to hold the default MFEX implementation. */
 static ATOMIC(miniflow_extract_func) default_mfex_func;
 
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \
-     && __SSE4_2__)
+#if MFEX_IMPL_AVX512_CHECK
 static int32_t
 avx512_isa_probe(bool needs_vbmi)
 {
@@ -95,8 +94,7 @@ static struct dpif_miniflow_extract_impl mfex_impls[] = {
         .name = "study", },
 
 /* Compile in implementations only if the compiler ISA checks pass. */
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \
-     && __SSE4_2__)
+#if MFEX_IMPL_AVX512_CHECK
 #if HAVE_AVX512VBMI
     [MFEX_IMPL_VBMI_IPv4_UDP] = {
         .probe = mfex_avx512_vbmi_probe,
diff --git a/lib/dpif-netdev-private-extract.h 
b/lib/dpif-netdev-private-extract.h
index 0b526e199..2a3a91744 100644
--- a/lib/dpif-netdev-private-extract.h
+++ b/lib/dpif-netdev-private-extract.h
@@ -19,6 +19,9 @@
 
 #include <sys/types.h>
 
+#define MFEX_IMPL_AVX512_CHECK (__x86_64__ && HAVE_AVX512F \
+    && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW && __SSE4_2__)
+
 /* Forward declarations. */
 struct dp_packet;
 struct miniflow;
@@ -81,8 +84,7 @@ enum dpif_miniflow_extract_impl_idx {
     MFEX_IMPL_AUTOVALIDATOR,
     MFEX_IMPL_SCALAR,
     MFEX_IMPL_STUDY,
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \
-     && __SSE4_2__)
+#if MFEX_IMPL_AVX512_CHECK
 #if HAVE_AVX512VBMI
     MFEX_IMPL_VBMI_IPv4_UDP,
 #endif
@@ -108,9 +110,7 @@ extern struct ovs_mutex dp_netdev_mutex;
 /* Define a index which points to the first traffic optimized MFEX
  * option from the enum list else holds max value.
  */
-#if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && HAVE_AVX512BW \
-     && __SSE4_2__)
-
+#if MFEX_IMPL_AVX512_CHECK
 #if HAVE_AVX512VBMI
 #define MFEX_IMPL_START_IDX MFEX_IMPL_VBMI_IPv4_UDP
 #else
-- 
2.37.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to