From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2286A42928; Wed, 12 Apr 2023 17:19:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EF501410F2; Wed, 12 Apr 2023 17:19:25 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 628DF406A2 for ; Wed, 12 Apr 2023 17:19:24 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id A94D421779BE; Wed, 12 Apr 2023 08:19:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A94D421779BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1681312763; bh=+wdeuq4EFIsyLLWufhg5YyeSLRTPj3QlnMoIaSjLbzM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Fm48156HR455n6WVdsoHwmF8gdNvjOXN4L19h1m8c5SRxjIEm0com81WrckJ+x//k cXxDNkzIvkwLKMwdd7o7Gvm2ZpqL7jaiDrzHKJMO0wOmwezYFysF31Pv8iubhHjXEm vB6AQlR2YvhsnZ+SMlg71k20h0s9TAJlIpl00ubc= Date: Wed, 12 Apr 2023 08:19:23 -0700 From: Tyler Retzlaff To: Bruce Richardson Cc: dev@dpdk.org, david.marchand@redhat.com, thomas@monjalon.net, mb@smartsharesystems.com, konstantin.ananyev@huawei.com Subject: Re: [PATCH v4 06/14] eal: use prefetch intrinsics Message-ID: <20230412151923.GA6257@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1680558751-17931-1-git-send-email-roretzla@linux.microsoft.com> <1681247548-18590-1-git-send-email-roretzla@linux.microsoft.com> <1681247548-18590-7-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Apr 12, 2023 at 10:05:57AM +0100, Bruce Richardson wrote: > On Tue, Apr 11, 2023 at 02:12:20PM -0700, Tyler Retzlaff wrote: > > Inline assembly is not supported for MSVC x64 instead use _mm_prefetch > > and _mm_cldemote intrinsics. > > > > Signed-off-by: Tyler Retzlaff > > --- > > Acked-by: Bruce Richardson > > One comment inline below for future consideration. > > > lib/eal/x86/include/rte_prefetch.h | 29 +++++++++++++++++++++++++++++ > > 1 file changed, 29 insertions(+) > > > > diff --git a/lib/eal/x86/include/rte_prefetch.h b/lib/eal/x86/include/rte_prefetch.h > > index 7fd01c4..1391af0 100644 > > --- a/lib/eal/x86/include/rte_prefetch.h > > +++ b/lib/eal/x86/include/rte_prefetch.h > > @@ -13,6 +13,7 @@ > > #include > > #include "generic/rte_prefetch.h" > > > > +#ifndef RTE_TOOLCHAIN_MSVC > > static inline void rte_prefetch0(const volatile void *p) > > { > > asm volatile ("prefetcht0 %[p]" : : [p] "m" (*(const volatile char *)p)); > > @@ -43,6 +44,34 @@ static inline void rte_prefetch_non_temporal(const volatile void *p) > > { > > asm volatile(".byte 0x0f, 0x1c, 0x06" :: "S" (p)); > > } > > +#else > > +static inline void rte_prefetch0(const volatile void *p) > > +{ > > + _mm_prefetch(p, 1); > > +} > > + > > +static inline void rte_prefetch1(const volatile void *p) > > +{ > > + _mm_prefetch(p, 2); > > +} > > + > > +static inline void rte_prefetch2(const volatile void *p) > > +{ > > + _mm_prefetch(p, 3); > > +} > > + > > +static inline void rte_prefetch_non_temporal(const volatile void *p) > > +{ > > + _mm_prefetch(p, 0); > > +} > > For these prefetch instructions, I'm not sure there is any reason why we > can't drop the inline assembly versions. The instructions are very old at > this point and should be widely supported by all compilers we use. > > Rather than using hard-coded 1, 2, 3 values in the prefetch calls, I > believe there should be defines for the levels: "_MM_HINT_T0", > "_MM_HINT_T1" etc. hm, i did not know about these and i bet they fix the problem i had. i.e. if i use e.g. bare '1' i would not get the same prefetch codegen on gcc/msvc but these defines probably resolve that problem. let me take another look at this one. > > > +__rte_experimental > > +static inline void > > +rte_cldemote(const volatile void *p) > > +{ > > + _mm_cldemote(p); > > +} > > +#endif > > + > > > > #ifdef __cplusplus > > } > > -- > > 1.8.3.1 > >