enable AVX2 for IDPF single queue
Subsystems (2)
cover enable AVX2 for IDPF single queue
In case some CPUs don't support AVX512. Enable AVX2 for them to get better per-core performance.
Wenzhuo Lu (2):
common/idpf: enable AVX2 for single queue Rx
common/idpf: enable AVX2 for single queue Tx
doc/guides/rel_notes/release_24_03.rst | 3 + drivers/common/idpf/idpf_common_device.h | 2 + drivers/common/idpf/idpf_common_rxtx.h | 8 + drivers/common/idpf/idpf_common_rxtx_avx2.c | 834 ++++++++++++++++++++ drivers/common/idpf/meson.build | 16 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_rxtx.c | 26 + 7 files changed, 891 insertions(+) create mode 100644 drivers/common/idpf/idpf_common_rxtx_avx2.c
Signature · 1 line
2.25.1
PATCH 1/2 common/idpf: enable AVX2 for single queue Rx
In case some CPUs don't support AVX512. Enable AVX2 for them to get better per-core performance.
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_rxtx.h | 4 + drivers/common/idpf/idpf_common_rxtx_avx2.c | 609 ++++++++++++++++++++ drivers/common/idpf/meson.build | 16 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_rxtx.c | 12 + 6 files changed, 643 insertions(+) create mode 100644 drivers/common/idpf/idpf_common_rxtx_avx2.c
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -114,6 +114,7 @@ struct idpf_vport {bool rx_vec_allowed;bool tx_vec_allowed; +bool rx_use_avx2;bool rx_use_avx512;bool tx_use_avx512;
drivers/common/idpf/idpf_common_rxtx.h +4 -0
@@ -302,5 +302,9 @@ uint16_t idpf_dp_splitq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pk__rte_internal uint16_t idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,uint16_t nb_pkts); +__rte_internal +uint16_t idpf_dp_singleq_recv_pkts_avx2(void *rx_queue, +struct rte_mbuf **rx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/idpf_common_rxtx_avx2.c new file +609 -0
609 lines not on this page · raw message
drivers/common/idpf/meson.build +16 -0
@@ -16,6 +16,22 @@ sources = files( ) if arch_subdir == 'x86' + # compile AVX2 version if either: + # a. we have AVX supported in minimum instruction set baseline + # b. it's not minimum instruction set, but supported by compiler + if cc.get_define('__AVX2__', args: machine_args) != '' + cflags += ['-DCC_AVX2_SUPPORT'] + sources += files('idpf_common_rxtx_avx2.c') + elif cc.has_argument('-mavx2') + cflags += ['-DCC_AVX2_SUPPORT'] + idpf_avx2_lib = static_library('idpf_avx2_lib', + 'idpf_common_rxtx_avx2.c', + dependencies: [static_rte_ethdev, static_rte_kvargs, static_rte_hash], + include_directories: includes, + c_args: [cflags, '-mavx2']) + objs += idpf_avx2_lib.extract_objects('idpf_common_rxtx_avx2.c') + endif + idpf_avx512_cpu_support = ( cc.get_define('__AVX512F__', args: machine_args) != '' and cc.get_define('__AVX512BW__', args: machine_args) != '' and
drivers/common/idpf/version.map +1 -0
@@ -14,6 +14,7 @@ INTERNAL { idpf_dp_splitq_recv_pkts_avx512; idpf_dp_splitq_xmit_pkts; idpf_dp_splitq_xmit_pkts_avx512; + idpf_dp_singleq_recv_pkts_avx2; idpf_qc_rx_thresh_check; idpf_qc_rx_queue_release;
drivers/net/idpf/idpf_rxtx.c +12 -0
@@ -772,6 +772,11 @@ idpf_set_rx_function(struct rte_eth_dev *dev) rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) { vport->rx_vec_allowed = true; +if ((rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 || +rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 ) && +rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) + vport->rx_use_avx2 = true; + if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)#ifdef CC_AVX512_SUPPORT if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
@@ -823,6 +828,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ +if (vport->rx_use_avx2) { +PMD_DRV_LOG (NOTICE , +"Using Single AVX2 Vector Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts_avx2; +return ; + } }if (dev->data->scattered_rx) {
Signature · 1 line
2.25.1
PATCH 2/2 common/idpf: enable AVX2 for single queue Tx
In reply to Wenzhuo LuIn case some CPUs don't support AVX512. Enable AVX2 for them to get better per-core performance.
--- doc/guides/rel_notes/release_24_03.rst | 3 + drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_rxtx.h | 4 + drivers/common/idpf/idpf_common_rxtx_avx2.c | 225 ++++++++++++++++++++ drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_rxtx.c | 14 ++ 6 files changed, 248 insertions(+)
doc/guides/rel_notes/release_24_03.rst +3 -0
@@ -55,6 +55,9 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= + * **Added support of vector instructions on IDPF.** + + Added support of AVX2 instructions in IDPF single queue RX and TX path. Removed Items -------------
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -115,6 +115,7 @@ struct idpf_vport {bool rx_vec_allowed;bool tx_vec_allowed;bool rx_use_avx2; +bool tx_use_avx2;bool rx_use_avx512;bool tx_use_avx512;
drivers/common/idpf/idpf_common_rxtx.h +4 -0
@@ -306,5 +306,9 @@ __rte_internaluint16_t idpf_dp_singleq_recv_pkts_avx2 (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts); +__rte_internal +uint16_t idpf_dp_singleq_xmit_pkts_avx2(void *tx_queue, +struct rte_mbuf **tx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/idpf_common_rxtx_avx2.c +225 -0
228 lines not on this page · raw message
drivers/common/idpf/version.map +1 -0
@@ -15,6 +15,7 @@ INTERNAL { idpf_dp_splitq_xmit_pkts; idpf_dp_splitq_xmit_pkts_avx512; idpf_dp_singleq_recv_pkts_avx2; + idpf_dp_singleq_xmit_pkts_avx2; idpf_qc_rx_thresh_check; idpf_qc_rx_queue_release;
drivers/net/idpf/idpf_rxtx.c +14 -0
@@ -884,6 +884,12 @@ idpf_set_tx_function(struct rte_eth_dev *dev)if (idpf_tx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->tx_vec_allowed = true; + +if ((rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 || +rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 ) && +rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) + vport->tx_use_avx2 = true; + if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)#ifdef CC_AVX512_SUPPORT {
@@ -943,6 +949,14 @@ idpf_set_tx_function(struct rte_eth_dev *dev)return ; }#endif /* CC_AVX512_SUPPORT */ +if (vport->tx_use_avx2) { +PMD_DRV_LOG (NOTICE , +"Using Single AVX2 Vector Tx (port %d)." , + dev->data->port_id); + dev->tx_pkt_burst = idpf_dp_singleq_xmit_pkts_avx2; + dev->tx_pkt_prepare = idpf_dp_prep_pkts; +return ; + } } PMD_DRV_LOG(NOTICE, "Using Single Scalar Tx (port %d).",
Signature · 1 line
2.25.1
RE: [PATCH 2/2] common/idpf: enable AVX2 for single queue Tx
Quoted 7 lines
-----Original Message-----
From: Wenzhuo Lu <[email protected]>
Sent: Thursday, December 7, 2023 2:35 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: [PATCH 2/2] common/idpf: enable AVX2 for single queue Tx
Quoted 5 lines
In case some CPUs don't support AVX512. Enable AVX2 for them to get better per-core performance.
Signed-off-by Wenzhuo Lu <[email protected]>---
Verified idpf single queue + AVX2 in functional regression test, tested pass.
v2 cover enable AVX2 for IDPF single queue
In reply to Wenzhuo LuIn case some CPUs don't support AVX512. Enable AVX2 for them to get better per-core performance.
---
v2:
- Removed unused code.
*** BLURB HERE ***
Wenzhuo Lu (2):
common/idpf: enable AVX2 for single queue Rx
common/idpf: enable AVX2 for single queue Tx
doc/guides/rel_notes/release_24_03.rst | 3 + drivers/common/idpf/idpf_common_device.h | 2 + drivers/common/idpf/idpf_common_rxtx.h | 8 + drivers/common/idpf/idpf_common_rxtx_avx2.c | 815 ++++++++++++++++++++ drivers/common/idpf/meson.build | 16 + drivers/common/idpf/version.map | 2 + drivers/net/idpf/idpf_rxtx.c | 26 + 7 files changed, 872 insertions(+) create mode 100644 drivers/common/idpf/idpf_common_rxtx_avx2.c
Signature · 1 line
2.25.1
PATCH v2 1/2 common/idpf: enable AVX2 for single queue Rx
In case some CPUs don't support AVX512. Enable AVX2 for them to get better per-core performance.
--- drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_rxtx.h | 4 + drivers/common/idpf/idpf_common_rxtx_avx2.c | 590 ++++++++++++++++++++ drivers/common/idpf/meson.build | 16 + drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_rxtx.c | 12 + 6 files changed, 624 insertions(+) create mode 100644 drivers/common/idpf/idpf_common_rxtx_avx2.c
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -114,6 +114,7 @@ struct idpf_vport {bool rx_vec_allowed;bool tx_vec_allowed; +bool rx_use_avx2;bool rx_use_avx512;bool tx_use_avx512;
drivers/common/idpf/idpf_common_rxtx.h +4 -0
@@ -302,5 +302,9 @@ uint16_t idpf_dp_splitq_xmit_pkts_avx512(void *tx_queue, struct rte_mbuf **tx_pk__rte_internal uint16_t idpf_dp_singleq_recv_scatter_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,uint16_t nb_pkts); +__rte_internal +uint16_t idpf_dp_singleq_recv_pkts_avx2(void *rx_queue, +struct rte_mbuf **rx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/idpf_common_rxtx_avx2.c new file +590 -0
590 lines not on this page · raw message
drivers/common/idpf/meson.build +16 -0
@@ -16,6 +16,22 @@ sources = files( ) if arch_subdir == 'x86' + # compile AVX2 version if either: + # a. we have AVX supported in minimum instruction set baseline + # b. it's not minimum instruction set, but supported by compiler + if cc.get_define('__AVX2__', args: machine_args) != '' + cflags += ['-DCC_AVX2_SUPPORT'] + sources += files('idpf_common_rxtx_avx2.c') + elif cc.has_argument('-mavx2') + cflags += ['-DCC_AVX2_SUPPORT'] + idpf_avx2_lib = static_library('idpf_avx2_lib', + 'idpf_common_rxtx_avx2.c', + dependencies: [static_rte_ethdev, static_rte_kvargs, static_rte_hash], + include_directories: includes, + c_args: [cflags, '-mavx2']) + objs += idpf_avx2_lib.extract_objects('idpf_common_rxtx_avx2.c') + endif + idpf_avx512_cpu_support = ( cc.get_define('__AVX512F__', args: machine_args) != '' and cc.get_define('__AVX512BW__', args: machine_args) != '' and
drivers/common/idpf/version.map +1 -0
@@ -14,6 +14,7 @@ INTERNAL { idpf_dp_splitq_recv_pkts_avx512; idpf_dp_splitq_xmit_pkts; idpf_dp_splitq_xmit_pkts_avx512; + idpf_dp_singleq_recv_pkts_avx2; idpf_qc_rx_thresh_check; idpf_qc_rx_queue_release;
drivers/net/idpf/idpf_rxtx.c +12 -0
@@ -772,6 +772,11 @@ idpf_set_rx_function(struct rte_eth_dev *dev) rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_128) { vport->rx_vec_allowed = true; +if ((rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 || +rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 ) && +rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) + vport->rx_use_avx2 = true; + if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)#ifdef CC_AVX512_SUPPORT if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F) == 1 &&
@@ -823,6 +828,13 @@ idpf_set_rx_function(struct rte_eth_dev *dev) return; }#endif /* CC_AVX512_SUPPORT */ +if (vport->rx_use_avx2) { +PMD_DRV_LOG (NOTICE , +"Using Single AVX2 Vector Rx (port %d)." , + dev->data->port_id); + dev->rx_pkt_burst = idpf_dp_singleq_recv_pkts_avx2; +return ; + } }if (dev->data->scattered_rx) {
Signature · 1 line
2.25.1
PATCH v2 2/2 common/idpf: enable AVX2 for single queue Tx
In reply to Wenzhuo LuIn case some CPUs don't support AVX512. Enable AVX2 for them to get better per-core performance.
--- doc/guides/rel_notes/release_24_03.rst | 3 + drivers/common/idpf/idpf_common_device.h | 1 + drivers/common/idpf/idpf_common_rxtx.h | 4 + drivers/common/idpf/idpf_common_rxtx_avx2.c | 225 ++++++++++++++++++++ drivers/common/idpf/version.map | 1 + drivers/net/idpf/idpf_rxtx.c | 14 ++ 6 files changed, 248 insertions(+)
doc/guides/rel_notes/release_24_03.rst +3 -0
@@ -55,6 +55,9 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= + * **Added support of vector instructions on IDPF.** + + Added support of AVX2 instructions in IDPF single queue RX and TX path. Removed Items -------------
drivers/common/idpf/idpf_common_device.h +1 -0
@@ -115,6 +115,7 @@ struct idpf_vport {bool rx_vec_allowed;bool tx_vec_allowed;bool rx_use_avx2; +bool tx_use_avx2;bool rx_use_avx512;bool tx_use_avx512;
drivers/common/idpf/idpf_common_rxtx.h +4 -0
@@ -306,5 +306,9 @@ __rte_internaluint16_t idpf_dp_singleq_recv_pkts_avx2 (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts); +__rte_internal +uint16_t idpf_dp_singleq_xmit_pkts_avx2(void *tx_queue, +struct rte_mbuf **tx_pkts, +uint16_t nb_pkts);#endif /* _IDPF_COMMON_RXTX_H_ */
drivers/common/idpf/idpf_common_rxtx_avx2.c +225 -0
228 lines not on this page · raw message
drivers/common/idpf/version.map +1 -0
@@ -15,6 +15,7 @@ INTERNAL { idpf_dp_splitq_xmit_pkts; idpf_dp_splitq_xmit_pkts_avx512; idpf_dp_singleq_recv_pkts_avx2; + idpf_dp_singleq_xmit_pkts_avx2; idpf_qc_rx_thresh_check; idpf_qc_rx_queue_release;
drivers/net/idpf/idpf_rxtx.c +14 -0
@@ -884,6 +884,12 @@ idpf_set_tx_function(struct rte_eth_dev *dev)if (idpf_tx_vec_dev_check_default (dev) ==IDPF_VECTOR_PATH &&rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_128 ) { vport->tx_vec_allowed = true; + +if ((rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX2 ) ==1 || +rte_cpu_get_flag_enabled (RTE_CPUFLAG_AVX512F ) ==1 ) && +rte_vect_get_max_simd_bitwidth () >=RTE_VECT_SIMD_256 ) + vport->tx_use_avx2 = true; + if (rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512)#ifdef CC_AVX512_SUPPORT {
@@ -943,6 +949,14 @@ idpf_set_tx_function(struct rte_eth_dev *dev)return ; }#endif /* CC_AVX512_SUPPORT */ +if (vport->tx_use_avx2) { +PMD_DRV_LOG (NOTICE , +"Using Single AVX2 Vector Tx (port %d)." , + dev->data->port_id); + dev->tx_pkt_burst = idpf_dp_singleq_xmit_pkts_avx2; + dev->tx_pkt_prepare = idpf_dp_prep_pkts; +return ; + } } PMD_DRV_LOG(NOTICE, "Using Single Scalar Tx (port %d).",
Signature · 1 line
2.25.1