DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andre Muezerie <andremue@linux.microsoft.com>
To: andremue@linux.microsoft.com
Cc: dev@dpdk.org
Subject: [PATCH v2 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf
Date: Tue, 18 Feb 2025 08:32:08 -0800	[thread overview]
Message-ID: <1739896329-1946-10-git-send-email-andremue@linux.microsoft.com> (raw)
In-Reply-To: <1739896329-1946-1-git-send-email-andremue@linux.microsoft.com>

There's no MSVC equivalent for compiler extension __builtin_constant_p,
so a workaround is needed.

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 app/test/test_memcpy_perf.c | 106 ++++++++++++++++++------------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/app/test/test_memcpy_perf.c b/app/test/test_memcpy_perf.c
index 5c05a84619..6091b6f9dd 100644
--- a/app/test/test_memcpy_perf.c
+++ b/app/test/test_memcpy_perf.c
@@ -167,66 +167,66 @@ do_uncached_write(uint8_t *dst, int is_dst_cached,
  * Run a single memcpy performance test. This is a macro to ensure that if
  * the "size" parameter is a constant it won't be converted to a variable.
  */
-#define SINGLE_PERF_TEST(dst, is_dst_cached, dst_uoffset,                   \
-                         src, is_src_cached, src_uoffset, size)             \
-do {                                                                        \
-    unsigned int iter, t;                                                   \
-    size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE];          \
-    uint64_t start_time, total_time = 0;                                    \
-    uint64_t total_time2 = 0;                                               \
-    for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {    \
-        fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,             \
-                         src_addrs, is_src_cached, src_uoffset);            \
-        start_time = rte_rdtsc();                                           \
-        for (t = 0; t < TEST_BATCH_SIZE; t++)                               \
-            rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size);           \
-        total_time += rte_rdtsc() - start_time;                             \
-    }                                                                       \
-    for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {    \
-        fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,             \
-                         src_addrs, is_src_cached, src_uoffset);            \
-        start_time = rte_rdtsc();                                           \
-        for (t = 0; t < TEST_BATCH_SIZE; t++)                               \
-            memcpy(dst+dst_addrs[t], src+src_addrs[t], size);               \
-        total_time2 += rte_rdtsc() - start_time;                            \
-    }                                                                       \
-    printf("%3.0f -", (double)total_time  / TEST_ITERATIONS);                 \
-    printf("%3.0f",   (double)total_time2 / TEST_ITERATIONS);                 \
-    printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \
+#define SINGLE_PERF_TEST(dst, is_dst_cached, dst_uoffset,                         \
+			 src, is_src_cached, src_uoffset, size)                   \
+do {                                                                              \
+	unsigned int iter, t;                                                     \
+	size_t dst_addrs[TEST_BATCH_SIZE], src_addrs[TEST_BATCH_SIZE];            \
+	uint64_t start_time, total_time = 0;                                      \
+	uint64_t total_time2 = 0;                                                 \
+	for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {      \
+		fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,           \
+				 src_addrs, is_src_cached, src_uoffset);          \
+		start_time = rte_rdtsc();                                         \
+		for (t = 0; t < TEST_BATCH_SIZE; t++)                             \
+			rte_memcpy(dst+dst_addrs[t], src+src_addrs[t], size);     \
+		total_time += rte_rdtsc() - start_time;                           \
+	}                                                                         \
+	for (iter = 0; iter < (TEST_ITERATIONS / TEST_BATCH_SIZE); iter++) {      \
+		fill_addr_arrays(dst_addrs, is_dst_cached, dst_uoffset,           \
+				 src_addrs, is_src_cached, src_uoffset);          \
+		start_time = rte_rdtsc();                                         \
+		for (t = 0; t < TEST_BATCH_SIZE; t++)                             \
+			memcpy(dst+dst_addrs[t], src+src_addrs[t], size);         \
+		total_time2 += rte_rdtsc() - start_time;                          \
+	}                                                                         \
+	printf("%3.0f -", (double)total_time  / TEST_ITERATIONS);                 \
+	printf("%3.0f",   (double)total_time2 / TEST_ITERATIONS);                 \
+	printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2); \
 } while (0)
 
 /* Run aligned memcpy tests for each cached/uncached permutation */
-#define ALL_PERF_TESTS_FOR_SIZE(n)                                       \
-do {                                                                     \
-    if (__builtin_constant_p(n))                                         \
-        printf("\nC%6u", (unsigned)n);                                   \
-    else                                                                 \
-        printf("\n%7u", (unsigned)n);                                    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n);    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n);    \
+#define ALL_PERF_TESTS_FOR_SIZE(n, def)                                      \
+do {                                                                         \
+	if (__rte_constant_with_default(n, def))                             \
+		printf("\nC%6u", (unsigned int)n);                           \
+	else                                                                 \
+		printf("\n%7u", (unsigned int)n);                            \
+	SINGLE_PERF_TEST(small_buf_write, 1, 0, small_buf_read, 1, 0, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 0, small_buf_read, 1, 0, n);    \
+	SINGLE_PERF_TEST(small_buf_write, 1, 0, large_buf_read, 0, 0, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 0, large_buf_read, 0, 0, n);    \
 } while (0)
 
 /* Run unaligned memcpy tests for each cached/uncached permutation */
-#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(n)                             \
-do {                                                                     \
-    if (__builtin_constant_p(n))                                         \
-        printf("\nC%6u", (unsigned)n);                                   \
-    else                                                                 \
-        printf("\n%7u", (unsigned)n);                                    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n);    \
-    SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n);    \
-    SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n);    \
+#define ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(n, def)                            \
+do {                                                                         \
+	if (__rte_constant_with_default(n, def))                             \
+		printf("\nC%6u", (unsigned int)n);                           \
+	else                                                                 \
+		printf("\n%7u", (unsigned int)n);                            \
+	SINGLE_PERF_TEST(small_buf_write, 1, 1, small_buf_read, 1, 5, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 1, small_buf_read, 1, 5, n);    \
+	SINGLE_PERF_TEST(small_buf_write, 1, 1, large_buf_read, 0, 5, n);    \
+	SINGLE_PERF_TEST(large_buf_write, 0, 1, large_buf_read, 0, 5, n);    \
 } while (0)
 
 /* Run memcpy tests for constant length */
-#define ALL_PERF_TEST_FOR_CONSTANT                                      \
-do {                                                                    \
-    TEST_CONSTANT(6U); TEST_CONSTANT(64U); TEST_CONSTANT(128U);         \
-    TEST_CONSTANT(192U); TEST_CONSTANT(256U); TEST_CONSTANT(512U);      \
-    TEST_CONSTANT(768U); TEST_CONSTANT(1024U); TEST_CONSTANT(1536U);    \
+#define ALL_PERF_TEST_FOR_CONSTANT                                                \
+do {                                                                              \
+	TEST_CONSTANT(6U, 1); TEST_CONSTANT(64U, 1); TEST_CONSTANT(128U, 1);      \
+	TEST_CONSTANT(192U, 1); TEST_CONSTANT(256U, 1); TEST_CONSTANT(512U, 1);   \
+	TEST_CONSTANT(768U, 1); TEST_CONSTANT(1024U, 1); TEST_CONSTANT(1536U, 1); \
 } while (0)
 
 /* Run all memcpy tests for aligned constant cases */
@@ -253,7 +253,7 @@ perf_test_variable_aligned(void)
 {
 	unsigned i;
 	for (i = 0; i < RTE_DIM(buf_sizes); i++) {
-		ALL_PERF_TESTS_FOR_SIZE((size_t)buf_sizes[i]);
+		ALL_PERF_TESTS_FOR_SIZE(buf_sizes[i], 0);
 	}
 }
 
@@ -263,7 +263,7 @@ perf_test_variable_unaligned(void)
 {
 	unsigned i;
 	for (i = 0; i < RTE_DIM(buf_sizes); i++) {
-		ALL_PERF_TESTS_FOR_SIZE_UNALIGNED((size_t)buf_sizes[i]);
+		ALL_PERF_TESTS_FOR_SIZE_UNALIGNED(buf_sizes[i], 0);
 	}
 }
 
-- 
2.48.1.vfs.0.0


  parent reply	other threads:[~2025-02-18 16:33 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11 22:01 [PATCH 00/10] enable "app" to be compiled with MSVC Andre Muezerie
2025-02-11 22:01 ` [PATCH 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-11 22:09   ` Stephen Hemminger
2025-02-12  0:59   ` fengchengwen
2025-02-11 22:01 ` [PATCH 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-12  0:59   ` fengchengwen
2025-02-11 22:01 ` [PATCH 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-11 22:10   ` Stephen Hemminger
2025-02-12  1:01   ` fengchengwen
2025-02-11 22:02 ` [PATCH 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-12  1:03   ` fengchengwen
2025-02-11 22:02 ` [PATCH 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-12  1:04   ` fengchengwen
2025-02-11 22:02 ` [PATCH 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-12  1:04   ` fengchengwen
2025-02-11 22:02 ` [PATCH 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-12  1:10   ` fengchengwen
2025-02-11 22:02 ` [PATCH 08/10] test-pmd: declare lcore_count atomic when using C11 memory model Andre Muezerie
2025-02-11 22:12   ` Stephen Hemminger
2025-02-12  1:16     ` Andre Muezerie
2025-02-12  1:16   ` fengchengwen
2025-02-11 22:02 ` [PATCH 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-11 22:13   ` Stephen Hemminger
2025-02-12  2:07     ` Andre Muezerie
2025-02-18 15:35 ` [PATCH 00/10] enable "app" to be compiled with MSVC David Marchand
2025-02-18 16:31 ` [PATCH v2 " Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-18 17:12     ` Morten Brørup
2025-02-19 16:50       ` Andre Muezerie
2025-02-19 17:10         ` Stephen Hemminger
2025-02-20  1:59           ` Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-18 16:46     ` Bruce Richardson
2025-02-18 17:03       ` Andre Muezerie
2025-02-18 17:07         ` Bruce Richardson
2025-02-19 17:08           ` Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-18 16:47     ` Bruce Richardson
2025-02-18 16:32   ` [PATCH v2 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-18 16:41     ` Bruce Richardson
2025-02-19 17:09       ` Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-18 16:32   ` [PATCH v2 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-18 16:42     ` Bruce Richardson
2025-02-18 16:32   ` [PATCH v2 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
2025-02-18 16:32   ` Andre Muezerie [this message]
2025-02-18 16:32   ` [PATCH v2 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
2025-02-18 16:49     ` Bruce Richardson
2025-02-19  9:15     ` David Marchand
2025-02-19 14:51       ` Andre Muezerie
2025-02-20  2:01 ` [PATCH v3 00/10] enable "app" " Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-20  2:27     ` Stephen Hemminger
2025-02-20  2:01   ` [PATCH v3 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-20  2:01   ` [PATCH v3 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
2025-02-20  7:57   ` [PATCH v3 00/10] enable "app" " Morten Brørup
2025-02-20 21:30 ` [PATCH v4 " Andre Muezerie
2025-02-20 21:30   ` [PATCH v4 01/10] eal: add workaround for __builtin_constant_p Andre Muezerie
2025-02-21 15:31     ` Morten Brørup
2025-02-21 16:47       ` Andre Muezerie
2025-02-20 21:30   ` [PATCH v4 02/10] test_alarm: avoid warning about different qualifiers Andre Muezerie
2025-02-20 21:30   ` [PATCH v4 03/10] test-pmd: fix printf format string mismatch Andre Muezerie
2025-02-21  9:10     ` Bruce Richardson
2025-02-20 21:30   ` [PATCH v4 04/10] test-pmd: do explicit 64-bit shift to avoid implicit conversion Andre Muezerie
2025-02-20 21:30   ` [PATCH v4 05/10] test-pmd: avoid undefined behavior Andre Muezerie
2025-02-20 21:31   ` [PATCH v4 06/10] test-pmd: avoid non-constant initializer Andre Muezerie
2025-02-20 21:31   ` [PATCH v4 07/10] test-pmd: don't return value from void function Andre Muezerie
2025-02-20 21:31   ` [PATCH v4 08/10] test-pmd: declare lcore_count atomic Andre Muezerie
2025-02-21  8:40     ` Konstantin Ananyev
2025-02-20 21:31   ` [PATCH v4 09/10] test: add workaround for __builtin_constant_p in test_memcpy_perf Andre Muezerie
2025-02-20 21:31   ` [PATCH v4 10/10] app: enable app directory to be compiled with MSVC Andre Muezerie
2025-02-20 21:44   ` [PATCH v4 00/10] enable "app" " Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1739896329-1946-10-git-send-email-andremue@linux.microsoft.com \
    --to=andremue@linux.microsoft.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).