All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Muezerie <andremue@linux.microsoft.com>
To: andremue@linux.microsoft.com
Cc: dev@dpdk.org
Subject: [PATCH v2 2/5] eal: only use numbers as align parameters for MSVC
Date: Tue, 25 Feb 2025 17:06:53 -0800	[thread overview]
Message-ID: <1740532016-6789-3-git-send-email-andremue@linux.microsoft.com> (raw)
In-Reply-To: <1740532016-6789-1-git-send-email-andremue@linux.microsoft.com>

After the instruction set updates for MSVC the error below popped up:

..\lib\eal\x86\include\rte_vect.h(82): error C2059: syntax error: '('

The issue is that MSVC does not allow __rte_aligned(RTE_X86_ZMM_SIZE).
It only accepts numbers that are power of 2. So, even though
RTE_X86_ZMM_SIZE represents a number that is a power of two it cannot
be used directly.
https://learn.microsoft.com/en-us/cpp/cpp/align-cpp?view=msvc-170

Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
 lib/eal/x86/include/rte_vect.h | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/eal/x86/include/rte_vect.h b/lib/eal/x86/include/rte_vect.h
index 70c78e9b77..0a51c539a4 100644
--- a/lib/eal/x86/include/rte_vect.h
+++ b/lib/eal/x86/include/rte_vect.h
@@ -79,7 +79,16 @@ __extension__ ({                \
 #define RTE_X86_ZMM_SIZE	(sizeof(__m512i))
 #define RTE_X86_ZMM_MASK	(RTE_X86_ZMM_SIZE - 1)
 
-typedef union __rte_aligned(RTE_X86_ZMM_SIZE) __rte_x86_zmm {
+/*
+ * MSVC does not allow __rte_aligned(RTE_X86_ZMM_SIZE). It only accepts
+ * numbers that are power of 2. So, even though RTE_X86_ZMM_SIZE represents a
+ * number that is a power of two it cannot be used directly.
+ * Ref: https://learn.microsoft.com/en-us/cpp/cpp/align-cpp?view=msvc-170
+ * The static assert below ensures that RTE_X86_ZMM_SIZE is equal to what is
+ * used in the __rte_aligned() expression.
+ */
+static_assert(RTE_X86_ZMM_SIZE == 64, "Unexpected size of __m512i");
+typedef union __rte_aligned(64) __rte_x86_zmm {
 	__m512i	 z;
 	ymm_t    y[RTE_X86_ZMM_SIZE / sizeof(ymm_t)];
 	xmm_t    x[RTE_X86_ZMM_SIZE / sizeof(xmm_t)];
-- 
2.48.1.vfs.0.0


  parent reply	other threads:[~2025-02-26  1:07 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 21:01 [PATCH 0/6] allow faster instruction sets to be used with MSVC Andre Muezerie
2025-02-24 21:01 ` [PATCH 1/6] eal: make compatible with instruction set updates for MSVC Andre Muezerie
2025-02-24 21:01 ` [PATCH 2/6] eal: only use numbers as align parameters " Andre Muezerie
2025-02-24 21:01 ` [PATCH 3/6] config: allow faster instruction sets to be used with MSVC Andre Muezerie
2025-02-25 14:28   ` Bruce Richardson
2025-02-26  2:01     ` Andre Muezerie
2025-02-26  9:44       ` Bruce Richardson
2025-02-24 21:01 ` [PATCH 4/6] drivers/net: make compatible with instruction set updates for MSVC Andre Muezerie
2025-02-25  9:06   ` Bruce Richardson
2025-02-25 16:44     ` Andre Muezerie
2025-02-24 21:01 ` [PATCH 5/6] acl: " Andre Muezerie
2025-02-25  9:03   ` Bruce Richardson
2025-02-25 16:37     ` Andre Muezerie
2025-02-25 17:21       ` Bruce Richardson
2025-02-25 17:23         ` Andre Muezerie
2025-02-24 21:01 ` [PATCH 6/6] member: " Andre Muezerie
2025-02-26  1:06 ` [PATCH v2 0/5] allow faster instruction sets to be used with MSVC Andre Muezerie
2025-02-26  1:06   ` [PATCH v2 1/5] eal: make compatible with instruction set updates for MSVC Andre Muezerie
2025-02-26  9:50     ` Bruce Richardson
2025-02-26  1:06   ` Andre Muezerie [this message]
2025-02-26  9:51     ` [PATCH v2 2/5] eal: only use numbers as align parameters " Bruce Richardson
2025-02-26 10:15     ` Konstantin Ananyev
2025-02-26  1:06   ` [PATCH v2 3/5] config: create top level variable cc_avx2_flags Andre Muezerie
2025-02-26  9:52     ` Bruce Richardson
2025-02-26  1:06   ` [PATCH v2 4/5] drivers/net: make compatible with instruction set updates for MSVC Andre Muezerie
2025-02-26  9:53     ` Bruce Richardson
2025-02-26  1:06   ` [PATCH v2 5/5] acl: " Andre Muezerie
2025-02-26  9:54     ` Bruce Richardson
2025-02-26 21:21 ` [PATCH v3 0/3] allow faster instruction sets to be used with MSVC Andre Muezerie
2025-02-26 21:21   ` [PATCH v3 1/3] eal: make compatible with instruction set updates for MSVC Andre Muezerie
2025-02-26 21:21   ` [PATCH v3 2/3] eal: only use numbers as align parameters " Andre Muezerie
2025-02-27  8:39     ` Konstantin Ananyev
2025-02-26 21:21   ` [PATCH v3 3/3] config: create top level variable cc_avx2_flags Andre Muezerie
2025-03-06 13:57   ` [PATCH v3 0/3] allow faster instruction sets to be used with MSVC David Marchand

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=1740532016-6789-3-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.