diff mbox series

[ovs-dev,v3,7/8] odp-execute: Add ISA implementation of actions.

Message ID 20211203153301.37692-8-emma.finn@intel.com
State Superseded
Headers show
Series Actions Infrastructure + Optimizations | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed

Commit Message

Emma Finn Dec. 3, 2021, 3:33 p.m. UTC
This commit adds the AVX512 implementation of the action functionality.

Usage:
  $ ovs-appctl dpif-netdev/action-impl-set avx512

Signed-off-by: Emma Finn <emma.finn@intel.com>
---
 lib/automake.mk           |  4 ++-
 lib/dpdk.c                |  1 +
 lib/odp-execute-avx512.c  | 69 +++++++++++++++++++++++++++++++++++++++
 lib/odp-execute-private.c |  9 +++++
 lib/odp-execute-private.h |  9 +++++
 5 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 lib/odp-execute-avx512.c
diff mbox series

Patch

diff --git a/lib/automake.mk b/lib/automake.mk
index 16087031f..34c03da45 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -32,6 +32,7 @@  lib_libopenvswitch_la_LIBADD += lib/libopenvswitchavx512.la
 lib_libopenvswitchavx512_la_CFLAGS = \
 	-mavx512f \
 	-mavx512bw \
+	-mavx512vl \
 	-mavx512dq \
 	-mbmi \
 	-mbmi2 \
@@ -40,7 +41,8 @@  lib_libopenvswitchavx512_la_CFLAGS = \
 lib_libopenvswitchavx512_la_SOURCES = \
 	lib/dpif-netdev-lookup-avx512-gather.c \
 	lib/dpif-netdev-extract-avx512.c \
-	lib/dpif-netdev-avx512.c
+	lib/dpif-netdev-avx512.c \
+	lib/odp-execute-avx512.c
 lib_libopenvswitchavx512_la_LDFLAGS = \
 	-static
 endif
diff --git a/lib/dpdk.c b/lib/dpdk.c
index b2ef31cd2..825e2daad 100644
--- a/lib/dpdk.c
+++ b/lib/dpdk.c
@@ -630,6 +630,7 @@  dpdk_get_cpu_has_isa(const char *arch, const char *feature)
     CHECK_CPU_FEATURE(feature, "avx512vbmi", RTE_CPUFLAG_AVX512VBMI);
     CHECK_CPU_FEATURE(feature, "avx512vpopcntdq", RTE_CPUFLAG_AVX512VPOPCNTDQ);
     CHECK_CPU_FEATURE(feature, "bmi2", RTE_CPUFLAG_BMI2);
+    CHECK_CPU_FEATURE(feature, "avx512vl", RTE_CPUFLAG_AVX512VL);
 #endif
 
     VLOG_WARN("Unknown CPU arch,feature: %s,%s. Returning not supported.\n",
diff --git a/lib/odp-execute-avx512.c b/lib/odp-execute-avx512.c
new file mode 100644
index 000000000..0765b8e3d
--- /dev/null
+++ b/lib/odp-execute-avx512.c
@@ -0,0 +1,69 @@ 
+/*
+ * Copyright (c) 2021 Intel.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <config.h>
+#include <errno.h>
+
+#include "dpdk.h"
+#include "odp-execute-private.h"
+#include "odp-netlink.h"
+#include "dp-packet.h"
+#include "openvswitch/vlog.h"
+
+#include "immintrin.h"
+
+
+/* Probe functions to check ISA requirements. */
+static int32_t
+avx512_isa_probe(uint32_t needs_vbmi)
+{
+    static const char *isa_required[] = {
+        "avx512f",
+        "avx512bw",
+        "bmi2",
+        "avx512vl"
+    };
+
+    int32_t ret = 0;
+    for (uint32_t i = 0; i < ARRAY_SIZE(isa_required); i++) {
+        if (!dpdk_get_cpu_has_isa("x86_64", isa_required[i])) {
+            ret = -ENOTSUP;
+        }
+    }
+
+    if (needs_vbmi) {
+        if (!dpdk_get_cpu_has_isa("x86_64", "avx512vbmi")) {
+            ret = -ENOTSUP;
+        }
+    }
+
+    return ret;
+}
+
+int32_t
+action_avx512_probe(void)
+{
+    const uint32_t needs_vbmi = 0;
+    return avx512_isa_probe(needs_vbmi);
+}
+
+
+int32_t
+action_avx512_init(void)
+{
+    avx512_isa_probe(0);
+    return 0;
+}
diff --git a/lib/odp-execute-private.c b/lib/odp-execute-private.c
index 2301194a0..19a04f518 100644
--- a/lib/odp-execute-private.c
+++ b/lib/odp-execute-private.c
@@ -46,6 +46,15 @@  static struct odp_execute_action_impl action_impls[] = {
         .probe = NULL,
         .init_func = action_autoval_init,
     },
+
+    #if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+    [ACTION_IMPL_AVX512] = {
+        .available = 1,
+        .name = "avx512",
+        .probe = action_avx512_probe,
+        .init_func = NULL,
+    },
+    #endif
 };
 
 static void
diff --git a/lib/odp-execute-private.h b/lib/odp-execute-private.h
index d49714bd2..4c09bee63 100644
--- a/lib/odp-execute-private.h
+++ b/lib/odp-execute-private.h
@@ -73,6 +73,9 @@  enum odp_execute_action_impl_idx {
      * Do not change the autovalidator position in this list without updating
      * the define below.
      */
+    #if (__x86_64__ && HAVE_AVX512F && HAVE_LD_AVX512_GOOD && __SSE4_2__)
+    ACTION_IMPL_AVX512,
+    #endif
 
     ACTION_IMPL_MAX,
 };
@@ -98,4 +101,10 @@  int32_t odp_execute_action_set(const char *name,
  */
 int32_t odp_action_scalar_init(struct odp_execute_action_impl *self);
 
+/* Init function for the optimized with AVX512 actions. */
+int32_t action_avx512_init(void);
+
+/* Probe function to check ISA requirements. */
+int32_t action_avx512_probe(void);
+
 #endif /* ODP_EXTRACT_PRIVATE */