diff mbox series

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

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

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning

Commit Message

Emma Finn Dec. 2, 2021, 10:41 a.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  | 68 +++++++++++++++++++++++++++++++++++++++
 lib/odp-execute-private.c |  9 ++++++
 lib/odp-execute-private.h |  9 ++++++
 5 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100644 lib/odp-execute-avx512.c

Comments

0-day Robot Dec. 2, 2021, 11:04 a.m. UTC | #1
Bleep bloop.  Greetings Emma Finn, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


Patch skipped due to previous failure.

Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
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..c46638e3f
--- /dev/null
+++ b/lib/odp-execute-avx512.c
@@ -0,0 +1,68 @@ 
+/*
+ * 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 "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(struct odp_execute_action_impl *self)
+{
+    avx512_isa_probe(0);
+    return 0;
+}
diff --git a/lib/odp-execute-private.c b/lib/odp-execute-private.c
index 3d1176cdd..bdb8d1e1e 100644
--- a/lib/odp-execute-private.c
+++ b/lib/odp-execute-private.c
@@ -45,6 +45,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 = action_avx512_init,
+    },
+    #endif
 };
 
 static uint32_t active_action_impl_index;
diff --git a/lib/odp-execute-private.h b/lib/odp-execute-private.h
index d49714bd2..5ba2868bf 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(struct odp_execute_action_impl *self);
+
+/* Probe function to check ISA requirements. */
+int32_t action_avx512_probe(void);
+
 #endif /* ODP_EXTRACT_PRIVATE */