Skip to content

Commit

Permalink
linux-dpdk: ml: implement on top of mldev
Browse files Browse the repository at this point in the history
Add ML implementation, which utilizes DPDK's mldev.

Limitations:

- Only a single device can be used. The device is specified in the
  configuration file.

- Only a single inference at a time per model.

- The maximum number of concurrent inferences is limited by the number
  of queue pairs.

- Inference is always synchronous, regardless of completion mode.

Signed-off-by: Jere Leppänen <[email protected]>
  • Loading branch information
JereLeppanen committed Sep 10, 2024
1 parent 61c2fce commit 9506995
Show file tree
Hide file tree
Showing 13 changed files with 2,222 additions and 42 deletions.
35 changes: 6 additions & 29 deletions config/odp-linux-dpdk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# Mandatory fields
odp_implementation = "linux-dpdk"
config_file_version = "0.1.26"
config_file_version = "0.1.27"

# System options
system: {
Expand Down Expand Up @@ -337,32 +337,9 @@ dma: {
}

ml: {
# Enable onnxruntime profiling, when enabled, a json file will be
# generated after inference. chrome://tracing/ can be used to check
# the profiling. Use 0 to disable and 1 to enable profiling.
enable_profiling = 0

# Choose onnxruntime execution mode, which can be "SEQUENTIAL" or
# "PARALLEL"
execution_mode = "SEQUENTIAL"

# Set the number of threads used to parallelize the execution of the
# graph across nodes. A value of 0 means onnxruntime will pick a default.
inter_op_num_threads = 0

# Set the number of threads used to parallelize the execution within
# a node. A value of 0 means onnxruntime will pick a default.
intra_op_num_threads = 0

# Set graph optimization level. Valid values are:
# DISABLE_ALL: disables all optimizations
# ENABLE_BASIC: enables basic optimizations
# ENABLE_EXTENDED: enables basic and extended optimizations
# ENABLE_ALL: enables all available optimizations including layout optimization
graph_optimization_level = "ENABLE_ALL"

# Serialize the optimized model to disk. When initializing a session
# with the same model, no need to apply optimization anymore, thus
# reducing model startup time.
optimized_model_filepath = ""
# Device ID
dev_id = 0

# Number of queue pairs
num_queue_pairs = 16
}
5 changes: 2 additions & 3 deletions platform/linux-dpdk/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ AM_CPPFLAGS += -I$(top_srcdir)/platform/$(with_platform)/arch/@ARCH_DIR@
AM_CPPFLAGS += -I$(top_srcdir)/platform/$(with_platform)/arch/default

AM_CPPFLAGS += $(OPENSSL_CPPFLAGS)
AM_CPPFLAGS += $(ORT_CPPFLAGS)

AM_CFLAGS += $(DPDK_CFLAGS)
AM_CFLAGS += $(LIBCONFIG_CFLAGS)
Expand Down Expand Up @@ -262,7 +261,7 @@ __LIB__libodp_dpdk_la_SOURCES = \

if WITH_ML
__LIB__libodp_dpdk_la_SOURCES += \
../linux-generic/odp_ml.c
odp_ml.c
else
__LIB__libodp_dpdk_la_SOURCES += \
../linux-generic/odp_ml_null.c
Expand Down Expand Up @@ -423,7 +422,7 @@ __LIB__libodp_dpdk_la_LIBADD += $(LIBCONFIG_LIBS)
__LIB__libodp_dpdk_la_LIBADD += $(DPDK_LIBS_LIBODP)
__LIB__libodp_dpdk_la_LIBADD += $(PTHREAD_LIBS)
__LIB__libodp_dpdk_la_LIBADD += $(TIMER_LIBS)
__LIB__libodp_dpdk_la_LIBADD += $(ORT_LIBS)
__LIB__libodp_dpdk_la_LIBADD += $(ML_LIBS)

CHECK_GLOBALS_REGEX = " (odp_|_odp_|_deprecated_odp_|miniz_|mz_|tdefl_|tinfl_|mp_hdlr_init_odp_pool_ops|__odr_asan)"

Expand Down
4 changes: 3 additions & 1 deletion platform/linux-dpdk/include/odp_config_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ extern "C" {

/*
* Stashes reserved for internal usage
*
* One stash reserved per DMA session, and one reserved for ML.
*/
#define CONFIG_INTERNAL_STASHES CONFIG_MAX_DMA_SESSIONS
#define CONFIG_INTERNAL_STASHES (CONFIG_MAX_DMA_SESSIONS + 1)

/*
* Maximum number of stashes
Expand Down
2 changes: 1 addition & 1 deletion platform/linux-dpdk/libodp-dpdk.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Description: The ODP packet processing engine
Version: @PKGCONFIG_VERSION@
Requires.private: libconfig
Libs: -L${libdir} -l@ODP_LIB_NAME@ @DPDK_LIBS_NON_ABI_COMPAT@ @ATOMIC_LIBS_NON_ABI_COMPAT@
Libs.private: @DPDK_LIBS_ABI_COMPAT@ @OPENSSL_STATIC_LIBS@ @PTHREAD_LIBS@ @TIMER_LIBS@ -lpthread @ATOMIC_LIBS_ABI_COMPAT@ @ORT_LIBS@
Libs.private: @DPDK_LIBS_ABI_COMPAT@ @OPENSSL_STATIC_LIBS@ @PTHREAD_LIBS@ @TIMER_LIBS@ -lpthread @ATOMIC_LIBS_ABI_COMPAT@ @ML_LIBS@
Cflags: -I${includedir} @DPDK_CFLAGS@
6 changes: 5 additions & 1 deletion platform/linux-dpdk/m4/configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ esac
# Required for experimental rte_event_port_unlinks_in_progress() API
DPDK_CFLAGS="${DPDK_CFLAGS} -DALLOW_EXPERIMENTAL_API"

AS_VAR_APPEND([PLAT_DEP_LIBS], ["${ATOMIC_LIBS} ${LIBCONFIG_LIBS} ${OPENSSL_LIBS} ${DPDK_LIBS_LT} ${LIBCLI_LIBS} ${ORT_LIBS}"])
# ML availability check requires DPDK include path, and must therefore be done
# after DPDK check.
ODP_ML

AS_VAR_APPEND([PLAT_DEP_LIBS], ["${ATOMIC_LIBS} ${LIBCONFIG_LIBS} ${OPENSSL_LIBS} ${DPDK_LIBS_LT} ${LIBCLI_LIBS}"])

# Add text to the end of configure with platform specific settings.
# Make sure it's aligned same as other lines in configure.ac.
Expand Down
2 changes: 1 addition & 1 deletion platform/linux-dpdk/m4/odp_libconfig.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
##########################################################################
m4_define([_odp_config_version_generation], [0])
m4_define([_odp_config_version_major], [1])
m4_define([_odp_config_version_minor], [26])
m4_define([_odp_config_version_minor], [27])

m4_define([_odp_config_version],
[_odp_config_version_generation._odp_config_version_major._odp_config_version_minor])
Expand Down
1 change: 0 additions & 1 deletion platform/linux-dpdk/m4/odp_ml.m4

This file was deleted.

36 changes: 36 additions & 0 deletions platform/linux-dpdk/m4/odp_ml.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
##########################################################################
# DPDK ML API
##########################################################################
AC_DEFUN([ODP_ML], [dnl
ml_support=no
ml_option=yes
AC_ARG_ENABLE([dpdk-ml],
[AS_HELP_STRING([--disable-dpdk-ml],
[disable ML support]
[[default=enabled] (linux-dpdk)])],
[if test "x$enableval" = "xno"; then
ml_option=no
fi])
AS_IF([test "x$ml_option" != "xno"], [dnl
#########################################################################
# If dpdk mldev header is available, enable ML API
#########################################################################
OLD_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$DPDK_CFLAGS $CPPFLAGS"
AC_CHECK_HEADERS([rte_mldev.h], [ml_support=yes], [], [])
CPPFLAGS=$OLD_CPPFLAGS
])
AC_CONFIG_COMMANDS_PRE([dnl
AM_CONDITIONAL([WITH_ML], [test x$ml_support = xyes])
])
# Even if ML is not enabled, -lm is needed by quantization.
ML_LIBS="-lm"
AC_SUBST([ML_LIBS])
]) # ODP_ML
Loading

0 comments on commit 9506995

Please sign in to comment.