DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] adapt prefetch functions for MSVC
@ 2024-03-20 21:18 Tyler Retzlaff
  2024-03-20 21:18 ` [PATCH 1/2] eal: provide " Tyler Retzlaff
  2024-03-20 21:18 ` [PATCH 2/2] eal: adjust intrinsic type casts for CXX Tyler Retzlaff
  0 siblings, 2 replies; 3+ messages in thread
From: Tyler Retzlaff @ 2024-03-20 21:18 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Konstantin Ananyev, Tyler Retzlaff

MSVC does not have intrinsics that allow prefetch specifying
read/write so adjust conditional compilation to allow MSVC to
use the non access type inline functions from rte_prefetch.h

While here fix issues with C++ build (which only appears on
MSVC because it uses intrinsics and not inline assembly)

Tyler Retzlaff (2):
  eal: provide prefetch functions for MSVC
  eal: adjust intrinsic type casts for CXX

 lib/eal/include/generic/rte_prefetch.h | 12 ++++++++++++
 lib/eal/x86/include/rte_prefetch.h     | 10 +++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] eal: provide prefetch functions for MSVC
  2024-03-20 21:18 [PATCH 0/2] adapt prefetch functions for MSVC Tyler Retzlaff
@ 2024-03-20 21:18 ` Tyler Retzlaff
  2024-03-20 21:18 ` [PATCH 2/2] eal: adjust intrinsic type casts for CXX Tyler Retzlaff
  1 sibling, 0 replies; 3+ messages in thread
From: Tyler Retzlaff @ 2024-03-20 21:18 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Konstantin Ananyev, Tyler Retzlaff

MSVC does not have an equivalent of __builtin_prefetch that allows read
or read-write parameter. Introduce conditional compile expansion of
rte_prefetch[0-2] inline functions when building with MSVC.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/include/generic/rte_prefetch.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/eal/include/generic/rte_prefetch.h b/lib/eal/include/generic/rte_prefetch.h
index f9fab5e..773b3b8 100644
--- a/lib/eal/include/generic/rte_prefetch.h
+++ b/lib/eal/include/generic/rte_prefetch.h
@@ -71,7 +71,11 @@
 	 * GCC docs where these integer constants are described in more detail:
 	 *  https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
 	 */
+#ifdef RTE_TOOLCHAIN_MSVC
+	rte_prefetch0(p);
+#else
 	__builtin_prefetch(p, 1, 3);
+#endif
 }
 
 /**
@@ -92,7 +96,11 @@
 	 * GCC docs where these integer constants are described in more detail:
 	 *  https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
 	 */
+#ifdef RTE_TOOLCHAIN_MSVC
+	rte_prefetch1(p);
+#else
 	__builtin_prefetch(p, 1, 2);
+#endif
 }
 
 /**
@@ -113,7 +121,11 @@
 	 * GCC docs where these integer constants are described in more detail:
 	 *  https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
 	 */
+#ifdef RTE_TOOLCHAIN_MSVC
+	rte_prefetch2(p);
+#else
 	__builtin_prefetch(p, 1, 1);
+#endif
 }
 
 /**
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] eal: adjust intrinsic type casts for CXX
  2024-03-20 21:18 [PATCH 0/2] adapt prefetch functions for MSVC Tyler Retzlaff
  2024-03-20 21:18 ` [PATCH 1/2] eal: provide " Tyler Retzlaff
@ 2024-03-20 21:18 ` Tyler Retzlaff
  1 sibling, 0 replies; 3+ messages in thread
From: Tyler Retzlaff @ 2024-03-20 21:18 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Konstantin Ananyev, Tyler Retzlaff

_mm_prefetch does not take a volatile qualified pointer, cast it away.
Additionally the pointer type should be char * not void * so adjust the
cast to match.

_mm_cldemote does not take a volatile qualified pointer, cast it away.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/eal/x86/include/rte_prefetch.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/eal/x86/include/rte_prefetch.h b/lib/eal/x86/include/rte_prefetch.h
index 715c61b..8a93777 100644
--- a/lib/eal/x86/include/rte_prefetch.h
+++ b/lib/eal/x86/include/rte_prefetch.h
@@ -20,7 +20,7 @@
 static inline void rte_prefetch0(const volatile void *p)
 {
 #ifdef RTE_TOOLCHAIN_MSVC
-	_mm_prefetch((const void *)p, _MM_HINT_T0);
+	_mm_prefetch((const char *)(uintptr_t)p, _MM_HINT_T0);
 #else
 	asm volatile ("prefetcht0 %[p]" : : [p] "m" (*(const volatile char *)p));
 #endif
@@ -29,7 +29,7 @@ static inline void rte_prefetch0(const volatile void *p)
 static inline void rte_prefetch1(const volatile void *p)
 {
 #ifdef RTE_TOOLCHAIN_MSVC
-	_mm_prefetch((const void *)p, _MM_HINT_T1);
+	_mm_prefetch((const char *)(uintptr_t)p, _MM_HINT_T1);
 #else
 	asm volatile ("prefetcht1 %[p]" : : [p] "m" (*(const volatile char *)p));
 #endif
@@ -38,7 +38,7 @@ static inline void rte_prefetch1(const volatile void *p)
 static inline void rte_prefetch2(const volatile void *p)
 {
 #ifdef RTE_TOOLCHAIN_MSVC
-	_mm_prefetch((const void *)p, _MM_HINT_T2);
+	_mm_prefetch((const char *)(uintptr_t)p, _MM_HINT_T2);
 #else
 	asm volatile ("prefetcht2 %[p]" : : [p] "m" (*(const volatile char *)p));
 #endif
@@ -47,7 +47,7 @@ static inline void rte_prefetch2(const volatile void *p)
 static inline void rte_prefetch_non_temporal(const volatile void *p)
 {
 #ifdef RTE_TOOLCHAIN_MSVC
-	_mm_prefetch((const void *)p, _MM_HINT_NTA);
+	_mm_prefetch((const char *)(uintptr_t)p, _MM_HINT_NTA);
 #else
 	asm volatile ("prefetchnta %[p]" : : [p] "m" (*(const volatile char *)p));
 #endif
@@ -58,7 +58,7 @@ static inline void rte_prefetch_non_temporal(const volatile void *p)
 rte_cldemote(const volatile void *p)
 {
 #ifdef RTE_TOOLCHAIN_MSVC
-	_mm_cldemote(p);
+	_mm_cldemote((const void *)(uintptr_t)p);
 #else
 	/*
 	 * We use raw byte codes for now as only the newest compiler
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-20 21:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20 21:18 [PATCH 0/2] adapt prefetch functions for MSVC Tyler Retzlaff
2024-03-20 21:18 ` [PATCH 1/2] eal: provide " Tyler Retzlaff
2024-03-20 21:18 ` [PATCH 2/2] eal: adjust intrinsic type casts for CXX Tyler Retzlaff

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).