rte_memcmp functions
cover rte_memcmp functions
This patch provides AVX/SSE based memcmp implementation on x86. For other architectures supported by DPDK, rte_memcmp simply uses memcmp function.
Following are preliminary performance numbers on Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz
RTE>>memcmp_perf_autotest
*** RTE memcmp equal performance test results *** *** Length (bytes), Ticks/Op. ***
*** 2, 4.8526 *** *** 5, 5.4023 *** *** 8, 4.5067 *** *** 9, 5.4024 *** *** 15, 7.2069 *** *** 16, 4.5027 *** *** 17, 4.5020 *** *** 31, 4.5020 *** *** 32, 4.5033 *** *** 33, 5.1377 *** *** 63, 6.9069 *** *** 64, 6.9472 *** *** 65, 9.6301 *** *** 127, 13.5122 *** *** 128, 10.8028 *** *** 129, 11.7058 *** *** 191, 14.4105 *** *** 192, 14.4251 *** *** 193, 16.2139 *** *** 255, 18.0125 *** *** 256, 17.1150 *** *** 257, 18.9129 *** *** 319, 20.7148 *** *** 320, 20.7161 *** *** 321, 22.5198 *** *** 383, 24.3169 *** *** 384, 22.5195 *** *** 385, 24.3197 *** *** 447, 26.1171 *** *** 448, 26.1289 *** *** 449, 27.9168 *** *** 511, 29.7252 *** *** 512, 29.7202 *** *** 513, 27.9253 *** *** 767, 38.7506 *** *** 768, 36.9327 *** *** 769, 38.7259 *** *** 1023, 49.5368 *** *** 1024, 49.5347 *** *** 1025, 46.8414 *** *** 1522, 68.4517 *** *** 1536, 68.4522 *** *** 1600, 67.5478 *** *** 2048, 87.3674 *** *** 2560, 106.2776 *** *** 3072, 125.1937 *** *** 3584, 144.1503 *** *** 4096, 163.0243 *** *** 4608, 181.9367 *** *** 5632, 219.7613 *** *** 6144, 238.6745 *** *** 6656, 257.6009 *** *** 7168, 276.5084 *** *** 7680, 295.4162 *** *** 8192, 314.3726 *** *** 16834, 746.1065 *** *** memcmp equal performance test results *** *** Length (bytes), Ticks/Op. *** *** 2, 9.0100 *** *** 5, 8.1065 *** *** 8, 9.1944 *** *** 9, 9.0044 *** *** 15, 9.0084 *** *** 16, 10.0695 *** *** 17, 9.0109 *** *** 31, 9.9111 *** *** 32, 9.9085 *** *** 33, 9.9112 *** *** 63, 12.6098 *** *** 64, 12.6106 *** *** 65, 12.6060 *** *** 127, 19.8160 *** *** 128, 19.8145 *** *** 129, 20.7260 *** *** 191, 26.1214 *** *** 192, 26.1195 *** *** 193, 26.1158 *** *** 255, 30.6222 *** *** 256, 30.6267 *** *** 257, 31.5270 *** *** 319, 36.0264 *** *** 320, 36.0497 *** *** 321, 36.9247 *** *** 383, 40.5290 *** *** 384, 40.5265 *** *** 385, 41.4331 *** *** 447, 45.9317 *** *** 448, 45.9324 *** *** 449, 45.9302 *** *** 511, 50.4652 *** *** 512, 50.4379 *** *** 513, 51.3361 *** *** 767, 67.5552 *** *** 768, 67.5464 *** *** 769, 67.5462 *** *** 1023, 85.5579 *** *** 1024, 85.5610 *** *** 1025, 85.5582 *** *** 1522, 120.6860 *** *** 1536, 121.6064 *** *** 1600, 126.1075 *** *** 2048, 157.6208 *** *** 2560, 208.8309 *** *** 3072, 241.7587 *** *** 3584, 276.1556 *** *** 4096, 310.5865 *** *** 4608, 343.8918 *** *** 5632, 411.2264 *** *** 6144, 445.3057 *** *** 6656, 480.4620 *** *** 7168, 512.5769 *** *** 7680, 547.9394 *** *** 8192, 582.7687 *** *** 16834, 1456.4280 *** *** RTE memcmp greater than performance test results *** *** Length (bytes), Ticks/Op. *** *** 1, 22.5862 *** *** 8, 24.9140 *** *** 15, 25.3942 *** *** 16, 22.1721 *** *** 32, 24.1650 *** *** 64, 25.0849 *** *** 128, 26.5515 *** *** 256, 28.7055 *** *** 512, 35.2811 *** *** 1024, 44.4520 *** *** 2048, 64.1331 *** *** 4096, 103.9949 *** *** 8192, 184.8077 *** *** 16384, 345.6785 *** *** memcmp greater than performance test results *** *** Length (bytes), Ticks/Op. *** *** 1, 22.6340 *** *** 8, 25.5552 *** *** 15, 25.4223 *** *** 16, 25.1371 *** *** 32, 26.7381 *** *** 64, 27.4521 *** *** 128, 29.7323 *** *** 256, 35.8891 *** *** 512, 46.0419 *** *** 1024, 101.1564 *** *** 2048, 159.8415 *** *** 4096, 230.2136 *** *** 8192, 366.2912 *** *** 16384, 647.0217 *** *** RTE memcmp less than performance test results *** *** Length (bytes), Ticks/Op. *** *** 1, 22.6627 *** *** 8, 26.2665 *** *** 15, 26.8192 *** *** 16, 21.7960 *** *** 32, 23.9878 *** *** 64, 24.2074 *** *** 128, 26.8111 *** *** 256, 28.3444 *** *** 512, 34.7882 *** *** 1024, 44.4824 *** *** 2048, 63.4154 *** *** 4096, 101.4360 *** *** 8192, 179.1029 *** *** 16384, 333.9357 *** *** memcmp less than performance test results *** *** Length (bytes), Ticks/Op. *** *** 1, 22.2894 *** *** 8, 24.9805 *** *** 15, 24.8632 *** *** 16, 24.3448 *** *** 32, 24.8554 *** *** 64, 25.7541 *** *** 128, 29.1831 *** *** 256, 36.2345 *** *** 512, 45.8233 *** *** 1024, 103.4597 *** *** 2048, 163.5588 *** *** 4096, 232.7368 *** *** 8192, 368.1143 *** *** 16384, 649.0326 ***
Test OK
RTE>>quit
Ravi Kerur (2):
rte_memcmp functions using Intel AVX and SSE intrinsics Test cases for rte_memcmp functions
app/test/Makefile | 31 +- app/test/autotest_data.py | 19 + app/test/test_memcmp.c | 250 +++++++ app/test/test_memcmp_perf.c | 396 +++++++++++ .../common/include/arch/arm/rte_memcmp.h | 60 ++ .../common/include/arch/ppc_64/rte_memcmp.h | 62 ++ .../common/include/arch/tile/rte_memcmp.h | 60 ++ .../common/include/arch/x86/rte_memcmp.h | 786 +++++++++++++++++++++ lib/librte_eal/common/include/generic/rte_memcmp.h | 175 +++++ 9 files changed, 1838 insertions(+), 1 deletion(-) create mode 100644 app/test/test_memcmp.c create mode 100644 app/test/test_memcmp_perf.c create mode 100644 lib/librte_eal/common/include/arch/arm/rte_memcmp.h create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h create mode 100644 lib/librte_eal/common/include/arch/tile/rte_memcmp.h create mode 100644 lib/librte_eal/common/include/arch/x86/rte_memcmp.h create mode 100644 lib/librte_eal/common/include/generic/rte_memcmp.h
Signature · 1 line
1.9.1
PATCH 1/2 rte_memcmp functions using Intel AVX and SSE intrinsics
v1:
This patch adds memcmp functionality using AVX and SSE intrinsics provided by Intel. For other architectures supported by DPDK regular memcmp function is used.
Compiled and tested on Ubuntu 14.04(non-NUMA) and 15.10(NUMA) systems.
--- .../common/include/arch/arm/rte_memcmp.h | 60 ++ .../common/include/arch/ppc_64/rte_memcmp.h | 62 ++ .../common/include/arch/tile/rte_memcmp.h | 60 ++ .../common/include/arch/x86/rte_memcmp.h | 786 +++++++++++++++++++++ lib/librte_eal/common/include/generic/rte_memcmp.h | 175 +++++ 5 files changed, 1143 insertions(+) create mode 100644 lib/librte_eal/common/include/arch/arm/rte_memcmp.h create mode 100644 lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h create mode 100644 lib/librte_eal/common/include/arch/tile/rte_memcmp.h create mode 100644 lib/librte_eal/common/include/arch/x86/rte_memcmp.h create mode 100644 lib/librte_eal/common/include/generic/rte_memcmp.h
lib/librte_eal/common/include/arch/arm/rte_memcmp.h new file +60 -0
@@ -0,0 +1,60 @@ +/* +* BSD LICENSE +* +* Copyright(c) 2016 RehiveTech. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of IBM Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef _RTE_MEMCMP_ARM_H_ +#define _RTE_MEMCMP_ARM_H_ + +#include <stdint.h> +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#include "generic/rte_memcmp.h" + +#define rte_memcmp (dst, src, n) \ + ({ (__builtin_constant_p(n)) ? \ + memcmp((dst), (src), (n)) : \ + rte_memcmp_func((dst), (src), (n)); }) + +static inline bool +rte_memcmp_func (void *dst,const void *src,size_t n) +{ +return memcmp (dst, src, n); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MEMCMP_ARM_H_ */
lib/librte_eal/common/include/arch/ppc_64/rte_memcmp.h new file +62 -0
62 lines not on this page · raw message
lib/librte_eal/common/include/arch/tile/rte_memcmp.h new file +60 -0
60 lines not on this page · raw message
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +786 -0
786 lines not on this page · raw message
lib/librte_eal/common/include/generic/rte_memcmp.h new file +175 -0
175 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 2/2 Test cases for rte_memcmp functions
v1:
This patch adds test cases for rte_memcmp functions. New rte_memcmp functions can be tested via 'make test' and 'testpmd' utility.
Compiled and tested on Ubuntu 14.04(non-NUMA) and 15.10(NUMA) systems.
--- app/test/Makefile | 31 +++- app/test/autotest_data.py | 19 +++ app/test/test_memcmp.c | 250 ++++++++++++++++++++++++++++ app/test/test_memcmp_perf.c | 396 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 695 insertions(+), 1 deletion(-) create mode 100644 app/test/test_memcmp.c create mode 100644 app/test/test_memcmp_perf.c
app/test/Makefile +30 -1
@@ -82,6 +82,9 @@ SRCS-y += test_logs.c SRCS-y += test_memcpy.c SRCS-y += test_memcpy_perf.c +SRCS-y += test_memcmp.c +SRCS-y += test_memcmp_perf.c + SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash.c SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_thash.c SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_perf.c
@@ -160,14 +163,40 @@ CFLAGS += $(WERROR_FLAGS) CFLAGS += -D_GNU_SOURCE -# Disable VTA for memcpy test +# Disable VTA for memcpy and memcmp tests ifeq ($(CC), gcc) ifeq ($(shell test $(GCC_VERSION) -ge 44 && echo 1), 1) CFLAGS_test_memcpy.o += -fno-var-tracking-assignments CFLAGS_test_memcpy_perf.o += -fno-var-tracking-assignments + +CFLAGS_test_memcmp.o += -fno-var-tracking-assignments +CFLAGS_test_memcmp_perf.o += -fno-var-tracking-assignments + endif endif +CMP_AVX2_SUPPORT=$(shell $(CC) -march=core-avx2 -dM -E - </dev/null 2>&1 | \ + grep -q AVX2 && echo 1) + +ifeq ($(CMP_AVX2_SUPPORT), 1) + ifeq ($(CC), icc) + CFLAGS_test_memcmp.o += -march=core-avx2 + CFLAGS_test_memcmp_perf.o += -march=core-avx2 + else + CFLAGS_test_memcmp.o += -mavx2 + CFLAGS_test_memcmp_perf.o += -mavx2 + endif +else + ifeq ($(CC), icc) + CFLAGS_test_memcmp.o += -march=core-sse4.1 + CFLAGS_test_memcmp_perf.o += -march=core-sse4.1 + else + CFLAGS_test_memcmp.o += -msse4.1 + CFLAGS_test_memcmp_perf.o += -msse4.1 + endif +endif + + # this application needs libraries first DEPDIRS-y += lib drivers
app/test/autotest_data.py +19 -0
@@ -186,6 +186,12 @@ parallel_test_group_list = [ "Report" : None, }, { + "Name" : "Memcmp autotest", + "Command" : "memcmp_autotest", + "Func" : default_autotest, + "Report" : None, + }, + { "Name" : "Memzone autotest", "Command" : "memzone_autotest", "Func" : default_autotest,
@@ -398,6 +404,19 @@ non_parallel_test_group_list = [ ] }, { + "Prefix": "memcmp_perf", + "Memory" : per_sockets(512), + "Tests" : + [ + { + "Name" : "Memcmp performance autotest", + "Command" : "memcmp_perf_autotest", + "Func" : default_autotest, + "Report" : None, + }, + ] +}, +{ "Prefix": "hash_perf", "Memory" : per_sockets(512), "Tests" :
app/test/test_memcmp.c new file +250 -0
250 lines not on this page · raw message
app/test/test_memcmp_perf.c new file +396 -0
396 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v1 1/2] rte_memcmp functions using Intel AVX and SSE intrinsics
In reply to Ravi Kerur2016-03-07 15:00, Ravi Kerur:
Quoted 4 lines
v1:
This patch adds memcmp functionality using AVX and SSE intrinsics provided by Intel. For other architectures supported by DPDK regular memcmp function is used.
Anyone to review this patch please? Zhihong?
Re: [PATCH v1 2/2] Test cases for rte_memcmp functions
In reply to Ravi KerurQuoted 15 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Tuesday, March 8, 2016 7:01 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v1 2/2] Test cases forrte_memcmpfunctionsv1:
This patch adds test cases forrte_memcmpfunctions. Newrte_memcmpfunctions can be tested via 'make test' and 'testpmd' utility.Compiled and tested on Ubuntu 14.04(non-NUMA) and 15.10(NUMA) systems.
[...]
Quoted 10 lines
+/************************************************************
*******************
+ * Memcmp function performance test configuration section. Each performance test
+ * will be performedMEMCMP_ITERATIONStimes.
+ *
+ * The five arrays below control what tests are performed. Every combination
+ * from the array entries is tested.
+ */
+#defineMEMCMP_ITERATIONS(500 * 500 * 500)
Maybe less iteration will make the test faster without compromise precison?
Quoted 9 lines
app/test/test_memcmp_perf.c new file +9
-0+ +static size_t memcmp_sizes[] = { +2 ,5 ,8 ,9 ,15 ,16 ,17 ,31 ,32 ,33 ,63 ,64 ,65 ,127 ,128 , +129 ,191 ,192 ,193 ,255 ,256 ,257 ,319 ,320 ,321 ,383 ,384 , +385 ,447 ,448 ,449 ,511 ,512 ,513 ,767 ,768 ,769 ,1023 ,1024 , +1025 ,1522 ,1536 ,1600 ,2048 ,2560 ,3072 ,3584 ,4096 ,4608 , +5632 ,6144 ,6656 ,7168 ,7680 ,8192 ,16834 +}; +
[...]
Quoted 5 lines
app/test/test_memcmp_perf.c new file +5
-0+/* +* Do all performance tests. +*/ +static int +test_memcmp_perf (void )
app/test/test_memcmp_perf.c line 387
Quoted 10 lines
app/test/test_memcmp_perf.c new file +10
-0+{ +if (run_all_memcmp_eq_perf_tests () !=0 ) +return -1 ; + +if (run_all_memcmp_gt_perf_tests () !=0 ) +return -1 ; + +if (run_all_memcmp_lt_perf_tests () !=0 ) +return -1 ; +
Perhaps unaligned test cases are needed here.
How do you think?
Quoted 11 lines
app/test/test_memcmp_perf.c new file +9
-1+ +return 0 ; +} + +static struct test_command memcmp_perf_cmd = { + .command ="memcmp_perf_autotest" , + .callback = test_memcmp_perf, +}; +REGISTER_TEST_COMMAND (memcmp_perf_cmd); --1.9.1
Re: [PATCH v1 1/2] rte_memcmp functions using Intel AVX and SSE intrinsics
In reply to Ravi KerurQuoted 17 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Tuesday, March 8, 2016 7:01 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v1 1/2]rte_memcmpfunctions using Intel AVX and SSE intrinsicsv1:
This patch adds memcmp functionality using AVX and SSE intrinsics provided by Intel. For other architectures supported by DPDK regular memcmp function is used.Compiled and tested on Ubuntu 14.04(non-NUMA) and 15.10(NUMA) systems.
[...]
lib/librte_eal/common/include/arch/x86/rte_memcmp.h line 175
Quoted 3 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +3
-0+if (unlikely (!_mm_testz_si128 (xmm2, xmm2))) { +__m128i idx = +_mm_setr_epi8 (15 ,14 ,13 ,12 ,11 ,10 ,9 ,8 ,7 ,6 ,5 ,4 ,3 ,2 ,1 ,0 );
line over 80 characters ;)
Quoted 19 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +14
-0+ +/* +* Reverse byte order +*/ + xmm0 =_mm_shuffle_epi8 (xmm0, idx); + xmm1 =_mm_shuffle_epi8 (xmm1, idx); + +/* +* Compare unsigned bytes with instructions for signed bytes +*/ + xmm0 =_mm_xor_si128 (xmm0,_mm_set1_epi8 (0x80 )); + xmm1 =_mm_xor_si128 (xmm1,_mm_set1_epi8 (0x80 )); + + return _mm_movemask_epi8(xmm0 > xmm1) -
_mm_movemask_epi8(xmm1 > xmm0);lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +4
-0+ } + +return 0 ; +}
[...]
Quoted 9 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +9
-0+static inline int +rte_memcmp (const void *_src_1,const void *_src_2,size_t n) +{ +const uint8_t *src_1 = (const uint8_t *)_src_1; +const uint8_t *src_2 = (const uint8_t *)_src_2; +int ret =0 ; + +if (n <16 ) +return rte_memcmp_regular (src_1, src_2, n);
[...]
lib/librte_eal/common/include/arch/x86/rte_memcmp.h line 449
Quoted 3 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +3
-0+ +while (n >512 ) { + ret =rte_cmp256 (src_1 +0 *256 , src_2 +0 *256 );
Thanks for the great work!
Seems to me there's a big improvement area before going into detailed instruction layout tuning that -- No unalignment handling here for large size memcmp.
So almost without a doubt the performance will be low in micro-architectures like Sandy Bridge if the start address is unaligned, which might be a common case.
Quoted 15 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +15
-0+if (unlikely (ret !=0 )) +return ret; + + ret =rte_cmp256 (src_1 +1 *256 , src_2 +1 *256 ); +if (unlikely (ret !=0 )) +return ret; + + src_1 = src_1 +512 ; + src_2 = src_2 +512 ; + n -= 512; + } + goto CMP_BLOCK_LESS_THAN_512; +} + +#else /* RTE_MACHINE_CPUFLAG_AVX2 */
Re: [PATCH v1 2/2] Test cases for rte_memcmp functions
In reply to Wang, ZhihongZhilong, Thomas,
If there is enough interest within DPDK community I can work on adding support for 'unaligned access' and 'test cases' for it. Please let me know either way.
Thanks,
Ravi
Quoted 78 lines · Zhihong
Quoted 15 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Tuesday, March 8, 2016 7:01 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v1 2/2] Test cases forrte_memcmpfunctionsv1:
This patch adds test cases forrte_memcmpfunctions. Newrte_memcmpfunctions can be tested via 'make test' and 'testpmd' utility.Compiled and tested on Ubuntu 14.04(non-NUMA) and 15.10(NUMA) systems.
[...]
Quoted 3 lines
+/************************************************************
*******************
+ * Memcmp function performance test configuration section. Eachperformance
Quoted 4 lines
test
+ * will be performedMEMCMP_ITERATIONStimes.
+ *
+ * The five arrays below control what tests are performed. Everycombination
Quoted 3 lines
+ * from the array entries is tested.
+ */
+#defineMEMCMP_ITERATIONS(500 * 500 * 500)Maybe less iteration will make the test faster without compromise precison?
Quoted 9 lines
app/test/test_memcmp_perf.c new file +9
-0+ +static size_t memcmp_sizes[] = { +2 ,5 ,8 ,9 ,15 ,16 ,17 ,31 ,32 ,33 ,63 ,64 ,65 ,127 ,128 , +129 ,191 ,192 ,193 ,255 ,256 ,257 ,319 ,320 ,321 ,383 ,384 , +385 ,447 ,448 ,449 ,511 ,512 ,513 ,767 ,768 ,769 ,1023 ,1024 , +1025 ,1522 ,1536 ,1600 ,2048 ,2560 ,3072 ,3584 ,4096 ,4608 , +5632 ,6144 ,6656 ,7168 ,7680 ,8192 ,16834 +}; +[...]
Quoted 5 lines
app/test/test_memcmp_perf.c new file +5
-0+/* +* Do all performance tests. +*/ +static int +test_memcmp_perf (void )app/test/test_memcmp_perf.c line 387
Quoted 10 lines
app/test/test_memcmp_perf.c new file +10
-0+{ +if (run_all_memcmp_eq_perf_tests () !=0 ) +return -1 ; + +if (run_all_memcmp_gt_perf_tests () !=0 ) +return -1 ; + +if (run_all_memcmp_lt_perf_tests () !=0 ) +return -1 ; +Perhaps unaligned test cases are needed here.
How do you think?Quoted 11 lines
app/test/test_memcmp_perf.c new file +9
-1+ +return 0 ; +} + +static struct test_command memcmp_perf_cmd = { + .command ="memcmp_perf_autotest" , + .callback = test_memcmp_perf, +}; +REGISTER_TEST_COMMAND (memcmp_perf_cmd); --1.9.1
Re: [PATCH v1 2/2] Test cases for rte_memcmp functions
Quoted 10 lines
-----Original Message-----
From: Ravi Kerur [mailto:[email protected]]
Sent: Tuesday, June 7, 2016 2:32 AM
To: Wang, Zhihong <[email protected]>; Thomas Monjalon <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v1 2/2] Test cases forrte_memcmpfunctions
Quoted 5 lines
Zhilong, Thomas,
If there is enough interest within DPDK community I can work on adding support for 'unaligned access' and 'test cases' for it. Please let me know either way.
Hi Ravi,
This rte_memcmp is proved with better performance than glibc's in aligned cases, I think it has good value to DPDK lib.
Though we don't have memcmp in critical pmd data path, it offers a better choice for applications who do.
Thanks
Zhihong
Quoted 80 lines
Thanks,
RaviQuoted 13 lines · Zhihong
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ravi Kerur
Sent: Tuesday, March 8, 2016 7:01 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v1 2/2] Test cases forrte_memcmpfunctionsv1:
This patch adds test cases forrte_memcmpfunctions. Newrte_memcmpfunctions can be tested via 'make test' and 'testpmd' utility.Compiled and tested on Ubuntu 14.04(non-NUMA) and 15.10(NUMA) systems.
[...]
Quoted 10 lines
+/************************************************************
*******************
+ * Memcmp function performance test configuration section. Each performance test
+ * will be performedMEMCMP_ITERATIONStimes.
+ *
+ * The five arrays below control what tests are performed. Every combination
+ * from the array entries is tested.
+ */
+#defineMEMCMP_ITERATIONS(500 * 500 * 500)Maybe less iteration will make the test faster without compromise precison?
Quoted 9 lines
app/test/test_memcmp_perf.c new file +9
-0+ +static size_t memcmp_sizes[] = { + 2, 5, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65, 127, 128, + 129, 191, 192, 193, 255, 256, 257, 319, 320, 321, 383, 384, + 385, 447, 448, 449, 511, 512, 513, 767, 768, 769, 1023, 1024, + 1025, 1522, 1536, 1600, 2048, 2560, 3072, 3584, 4096, 4608, + 5632, 6144, 6656, 7168, 7680, 8192, 16834 +}; +[...]
Quoted 5 lines
app/test/test_memcmp_perf.c new file +5
-0+/* +* Do all performance tests. +*/ +static int +test_memcmp_perf (void )app/test/test_memcmp_perf.c line 387
Quoted 10 lines
app/test/test_memcmp_perf.c new file +10
-0+{ + if (run_all_memcmp_eq_perf_tests() != 0) + return -1; + + if (run_all_memcmp_gt_perf_tests() != 0) + return -1; + + if (run_all_memcmp_lt_perf_tests() != 0) + return -1; +Perhaps unaligned test cases are needed here.
How do you think?Quoted 11 lines
app/test/test_memcmp_perf.c new file +9
-1+ + return 0; +} + +static struct test_command memcmp_perf_cmd = { + .command = "memcmp_perf_autotest", + .callback = test_memcmp_perf, +}; +REGISTER_TEST_COMMAND (memcmp_perf_cmd); --1.9.1
Re: [PATCH v1 2/2] Test cases for rte_memcmp functions
2016-06-07 11:09, Wang, Zhihong:
Quoted 6 lines
From: Ravi Kerur [mailto:[email protected]]
Quoted 4 lines
Zhilong, Thomas,
If there is enough interest within DPDK community I can work on adding support for 'unaligned access' and 'test cases' for it. Please let me know either way.
Quoted 7 lines
Hi Ravi,
This
rte_memcmpis proved with better performance than glibc's in aligned cases, I think it has good value to DPDK lib.Though we don't have memcmp in critical pmd data path, it offers a better choice for applications who do.
Re-thinking about this series, could it be some values to have a rte_memcmp implementation?
What is the value compared to glibc one? Why not working on glibc?
Re: [PATCH v1 2/2] Test cases for rte_memcmp functions
Quoted 22 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, January 3, 2017 4:41 AM
To: Wang, Zhihong <[email protected]>; Ravi Kerur <[email protected]>
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v1 2/2] Test cases forrte_memcmpfunctions2016-06-07 11:09, Wang, Zhihong:
Quoted 4 lines
From: Ravi Kerur [mailto:[email protected]]
Quoted 3 lines
Zhilong, Thomas,
If there is enough interest within DPDK community I can work on adding
support
Quoted 1 line
Quoted 1 line
for 'unaligned access' and 'test cases' for it. Please let me know either
way.
Quoted 3 lines
Hi Ravi,
Quoted 8 lines
Quoted 5 lines
This
rte_memcmpis proved with better performance than glibc's in aligned cases, I think it has good value to DPDK lib.Though we don't have memcmp in critical pmd data path, it offers a better choice for applications who do.
Re-thinking about this series, could it be some values to have a
rte_memcmpimplementation?
I think this series (rte_memcmp included) could help:
1. Potentially better performance in hot paths.
2. Agile for tuning.
3. Avoid performance complications -- unusual but possible, like the glibc memset issue I met while working on vhost enqueue.
Quoted 1 line
What is the value compared to glibc one? Why not working on glibc?
As to working on glibc, wider design consideration and test coverage might be needed, and we'll face different release cycles, can we have the same agility? Also working with old glibc could be a problem.
Re: [PATCH v1 2/2] Test cases for rte_memcmp functions
2017-01-09 05:29, Wang, Zhihong:
Quoted 31 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 11 lines
2016-06-07 11:09, Wang, Zhihong:
Quoted 4 lines
From: Ravi Kerur [mailto:[email protected]]
Quoted 3 lines
Zhilong, Thomas,
If there is enough interest within DPDK community I can work on adding
support
Quoted 1 line
Quoted 1 line
for 'unaligned access' and 'test cases' for it. Please let me know either
way.
Quoted 3 lines
Hi Ravi,
Quoted 8 lines
Quoted 5 lines
This
rte_memcmpis proved with better performance than glibc's in aligned cases, I think it has good value to DPDK lib.Though we don't have memcmp in critical pmd data path, it offers a better choice for applications who do.
Re-thinking about this series, could it be some values to have a
rte_memcmpimplementation?I think this series (
rte_memcmpincluded) could help:1. Potentially better performance in hot paths.
2. Agile for tuning.
3. Avoid performance complications -- unusual but possible, like the glibc memset issue I met while working on vhost enqueue.
Quoted 6 lines
Quoted 1 line
What is the value compared to glibc one? Why not working on glibc?
As to working on glibc, wider design consideration and test coverage might be needed, and we'll face different release cycles, can we have the same agility? Also working with old glibc could be a problem.
Probably we need both: add the optimized version in DPDK while working on a glibc optimization.
This strategy could be applicable to memcpy, memcmp and memset.
Re: [PATCH v1 2/2] Test cases for rte_memcmp functions
Quoted 48 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, January 9, 2017 7:09 PM
To: Wang, Zhihong <[email protected]>
Cc: Ravi Kerur <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v1 2/2] Test cases forrte_memcmpfunctions2017-01-09 05:29, Wang, Zhihong:
Quoted 6 lines
From: Thomas Monjalon [mailto:[email protected]]
Quoted 5 lines
2016-06-07 11:09, Wang, Zhihong:
Quoted 4 lines
From: Ravi Kerur [mailto:[email protected]]
Quoted 3 lines
Zhilong, Thomas,
If there is enough interest within DPDK community I can work on
adding
Quoted 7 lines
Quoted 7 lines
support
Quoted 1 line
Quoted 1 line
for 'unaligned access' and 'test cases' for it. Please let me know either
way.
Quoted 4 lines
Hi Ravi,
This
rte_memcmpis proved with better performance than glibc's inaligned
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
cases, I think it has good value to DPDK lib.
Though we don't have memcmp in critical pmd data path, it offers a
better
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
choice for applications who do.
Re-thinking about this series, could it be some values to have a
rte_memcmpQuoted 14 lines
Quoted 1 line
implementation?
I think this series (
rte_memcmpincluded) could help:1. Potentially better performance in hot paths.
2. Agile for tuning.
3. Avoid performance complications -- unusual but possible, like the glibc memset issue I met while working on vhost enqueue.
Quoted 1 line
What is the value compared to glibc one? Why not working on glibc?
Quoted 8 lines
Quoted 4 lines
As to working on glibc, wider design consideration and test coverage might be needed, and we'll face different release cycles, can we have the same agility? Also working with old glibc could be a problem.
Probably we need both: add the optimized version in DPDK while working on a glibc optimization.
This strategy could be applicable to memcpy, memcmp and memset.
This does help in the long run if turned out feasible.
Re: [PATCH v1 1/2] rte_memcmp functions using Intel AVX and SSE intrinsics
In reply to Wang, ZhihongQuoted 61 lines · Zhihong)
Quoted 15 lines
-----Original Message-----
From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ravi Kerur
Sent: Tuesday, March 8, 2016 7:01 AM
To: dev at dpdk.org
Subject: [dpdk-dev] [PATCH v1 1/2]rte_memcmpfunctions using Intel AVX and SSE intrinsicsv1:
This patch adds memcmp functionality using AVX and SSE intrinsics provided by Intel. For other architectures supported by DPDK regular memcmp function is used.Compiled and tested on Ubuntu 14.04(non-NUMA) and 15.10(NUMA) systems.
[...]
lib/librte_eal/common/include/arch/x86/rte_memcmp.h line 175
Quoted 3 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +3
-0+if (unlikely (!_mm_testz_si128 (xmm2, xmm2))) { +__m128i idx = +_mm_setr_epi8 (15 ,14 ,13 ,12 ,11 ,10 ,9 ,8 ,7 ,6 ,5 ,4 ,3 ,2 ,1 ,0 );line over 80 characters ;)
Quoted 19 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +14
-0+ +/* +* Reverse byte order +*/ + xmm0 =_mm_shuffle_epi8 (xmm0, idx); + xmm1 =_mm_shuffle_epi8 (xmm1, idx); + +/* +* Compare unsigned bytes with instructions for signed bytes +*/ + xmm0 =_mm_xor_si128 (xmm0,_mm_set1_epi8 (0x80 )); + xmm1 =_mm_xor_si128 (xmm1,_mm_set1_epi8 (0x80 )); + + return _mm_movemask_epi8(xmm0 > xmm1) -
_mm_movemask_epi8(xmm1 > xmm0);lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +4
-0+ } + +return 0 ; +}[...]
Quoted 9 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +9
-0+static inline int +rte_memcmp (const void *_src_1,const void *_src_2,size_t n) +{ +const uint8_t *src_1 = (const uint8_t *)_src_1; +const uint8_t *src_2 = (const uint8_t *)_src_2; +int ret =0 ; + +if (n <16 ) +return rte_memcmp_regular (src_1, src_2, n);[...]
lib/librte_eal/common/include/arch/x86/rte_memcmp.h line 449
Quoted 3 lines
lib/librte_eal/common/include/arch/x86/rte_memcmp.h new file +3
-0+ +while (n >512 ) { + ret =rte_cmp256 (src_1 +0 *256 , src_2 +0 *256 );Thanks for the great work!
Quoted 7 lines
Seems to me there's a big improvement area before going into detailed instruction layout tuning that -- No unalignment handling here for large size memcmp.
So almost without a doubt the performance will be low in micro-architectures like Sandy Bridge if the start address is unaligned, which might be a common case.
Patch is waiting for comment for a long time, since 2016 May. Updating patch status as rejected.
Anyone planning to work on vectorized version of rte_memcmp() can benefit from this patch:
https://patches.dpdk.org/patch/11156/
https://patches.dpdk.org/patch/11157/