From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 4862758F6 for ; Mon, 4 Sep 2017 03:41:43 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Sep 2017 18:41:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,473,1498546800"; d="scan'208";a="125268375" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga004.jf.intel.com with ESMTP; 03 Sep 2017 18:41:42 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 3 Sep 2017 18:41:42 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 3 Sep 2017 18:41:41 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.168]) by shsmsx102.ccr.corp.intel.com ([169.254.2.39]) with mapi id 14.03.0319.002; Mon, 4 Sep 2017 09:41:37 +0800 From: "Li, Xiaoyun" To: "Ananyev, Konstantin" , "Richardson, Bruce" CC: "dev@dpdk.org" , "Wang, Zhihong" , "Zhang, Qi Z" , "Lu, Wenzhuo" Thread-Topic: [dpdk-dev] [PATCH v2 1/3] eal/x86: run-time dispatch over memcpy Thread-Index: AQHTIwBrlGsHmgShskuUmMa7Bb4+wKKfOegAgACHy9D//484AIAEpU8A Date: Mon, 4 Sep 2017 01:41:37 +0000 Message-ID: References: <1503626773-184682-1-git-send-email-xiaoyun.li@intel.com> <1504256222-32969-1-git-send-email-xiaoyun.li@intel.com> <1504256222-32969-2-git-send-email-xiaoyun.li@intel.com> <2601191342CEEE43887BDE71AB9772584F23F1AC@IRSMSX103.ger.corp.intel.com> <2601191342CEEE43887BDE71AB9772584F23F281@IRSMSX103.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB9772584F23F281@IRSMSX103.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjU0NjE4NTEtZTcyZS00MDExLWE5MDItMGMyZDMyY2NhMDVkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Imk5NGFMeGhjNEJpNFZ1bU5CTzZyVUFlTXNQZjM2bG9ORkxNS0c1SzJISk09In0= x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 1/3] eal/x86: run-time dispatch over memcpy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Sep 2017 01:41:45 -0000 I didn't consider that the orginal codes are inline, would be replaced in c= ompilation time and have no function calls. Anyway, I'll do perf test this week. And if it drops a lot, I will change t= o codes like rte_memcpy_AVX512 (less function calls) and test perf again. Best Regards, Xiaoyun Li -----Original Message----- From: Ananyev, Konstantin=20 Sent: Friday, September 1, 2017 18:39 To: Li, Xiaoyun ; Richardson, Bruce Cc: dev@dpdk.org; Wang, Zhihong ; Zhang, Qi Z ; Lu, Wenzhuo Subject: RE: [dpdk-dev] [PATCH v2 1/3] eal/x86: run-time dispatch over memc= py > -----Original Message----- > From: Li, Xiaoyun > Sent: Friday, September 1, 2017 10:29 AM > To: Ananyev, Konstantin ; Richardson,=20 > Bruce > Cc: dev@dpdk.org; Wang, Zhihong ; Zhang, Qi Z=20 > ; Lu, Wenzhuo > Subject: RE: [dpdk-dev] [PATCH v2 1/3] eal/x86: run-time dispatch over=20 > memcpy >=20 > Hi > I send an email just now. > The original codes have so many functions because maybe other places (rig= ht now nowhere else) would need functions like rte_mov16. Which place exactly? As I understand right now no one using it, and they supposed to be sort of = private ones, correct? So why do you want to make them public? > Then they can directly use it. So I am not sure if I need modify it. >=20 > The performance haven't been tested. But it should be the same as before. Hmm, what makes you think that? Let say to move 64B you are calling rte_mov16() 4 times. Obviously each function call has an overhead - prepare parameter registers,= save/restore scratch registers, actual call/jmp instruction, ret, etc. All that costs cycles. Did you do any performance measurements here? Konstantin=20 > Before, if cpu and compiler supports AVX512 and users enable it, the AVX5= 12 codes would be compiled and runed. > I just delete the macro and make it decide at run-time (constructor time)= not build time. >=20 >=20 > Best Regards, > Xiaoyun Li >=20 >=20 >=20 >=20 > -----Original Message----- > From: Ananyev, Konstantin > Sent: Friday, September 1, 2017 17:17 > To: Li, Xiaoyun ; Richardson, Bruce=20 > > Cc: dev@dpdk.org; Wang, Zhihong ; Zhang, Qi Z=20 > ; Lu, Wenzhuo ; Li,=20 > Xiaoyun > Subject: RE: [dpdk-dev] [PATCH v2 1/3] eal/x86: run-time dispatch over=20 > memcpy >=20 >=20 >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Xiaoyun Li > > Sent: Friday, September 1, 2017 9:57 AM > > To: Richardson, Bruce > > Cc: dev@dpdk.org; Wang, Zhihong ; Zhang, Qi=20 > > Z ; Lu, Wenzhuo ; Li,=20 > > Xiaoyun > > Subject: [dpdk-dev] [PATCH v2 1/3] eal/x86: run-time dispatch over=20 > > memcpy > > > > This patch dynamically selects functions of memcpy at run-time based=20 > > on CPU flags that current machine supports. This patch uses function=20 > > pointers which are bind to the relative functions at constrctor time. > > In addition, AVX512 instructions set would be compiled only if users=20 > > config it enabled and the compiler supports it. >=20 >=20 > I'll ask the same question again: > It seems quite an overhead to add extra function call for each 16(32/64)B= movement. > Wouldn't it be better to have one func_ptr per implementation, i.e: > rte_memcpy_sse(), rte_memcpy_avx2(), rte_memcpy_avx512(), etc.? > BTW, what is the performance diff between old and new versions? > Konstantin >=20 > > > > Signed-off-by: Xiaoyun Li > > --- > > v2 > > * use gcc function multi-versioning to avoid compilation issue. > > * add macros for AVX512 and AVX2. Only if users enable AVX512 and=20 > > the compiler supports it, the AVX512 codes would be compiled. Only=20 > > if the compiler supports AVX2, the AVX2 codes would be compiled. > > > > .../common/include/arch/x86/rte_memcpy.h | 343 +++++++++++++= -------- > > mk/rte.cpuflags.mk | 14 + > > 2 files changed, 231 insertions(+), 126 deletions(-) > > > > diff --git a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h > > b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h > > index 74c280c..abba6ad 100644 > > --- a/lib/librte_eal/common/include/arch/x86/rte_memcpy.h > > +++ b/lib/librte_eal/common/include/arch/x86/rte_memcpy.h > > @@ -45,11 +45,45 @@ > > #include > > #include > > #include > > +#include > > +#include > > > > #ifdef __cplusplus > > extern "C" { > > #endif > > > > +/* > > + * Select SSE/AVX memory copy method as default one. > > + */ > > + > > +static uint16_t alignment_mask =3D 0x0F; > > + > > +typedef void (*rte_mov16_t)(uint8_t *dst, const uint8_t *src);=20 > > +typedef void (*rte_mov32_t)(uint8_t *dst, const uint8_t *src);=20 > > +typedef void (*rte_mov64_t)(uint8_t *dst, const uint8_t *src);=20 > > +typedef void (*rte_mov128_t)(uint8_t *dst, const uint8_t *src);=20 > > +typedef void (*rte_mov256_t)(uint8_t *dst, const uint8_t *src);=20 > > +#ifdef CC_SUPPORT_AVX2 typedef void (*rte_mov128blocks_t)(uint8_t=20 > > +*dst, const uint8_t *src, size_t n); #endif #ifdef=20 > > +CC_SUPPORT_AVX512 typedef void (*rte_mov512blocks_t)(uint8_t *dst,=20 > > +const uint8_t *src, size_t n); #endif typedef void *=20 > > +(*rte_memcpy_generic_t)(void *dst, const void *src, size_t n); > > + > > +static rte_mov16_t rte_mov16; > > +static rte_mov32_t rte_mov32; > > +static rte_mov64_t rte_mov64; > > +static rte_mov128_t rte_mov128; > > +static rte_mov256_t rte_mov256; > > +#ifdef CC_SUPPORT_AVX2 > > +static rte_mov128blocks_t rte_mov128blocks; #endif #ifdef > > +CC_SUPPORT_AVX512 static rte_mov512blocks_t rte_mov512blocks;=20 > > +#endif static rte_memcpy_generic_t rte_memcpy_generic; > > + > > /** > > * Copy bytes from one location to another. The locations must not ove= rlap. > > * > > @@ -68,10 +102,6 @@ extern "C" { > > static __rte_always_inline void * > > rte_memcpy(void *dst, const void *src, size_t n); > > > > -#ifdef RTE_MACHINE_CPUFLAG_AVX512F > > - > > -#define ALIGNMENT_MASK 0x3F > > - > > /** > > * AVX512 implementation below > > */ > > @@ -80,8 +110,10 @@ rte_memcpy(void *dst, const void *src, size_t n); > > * Copy 16 bytes from one location to another, > > * locations should not overlap. > > */ > > +#ifdef CC_SUPPORT_AVX512 > > +__attribute__((target("avx512f"))) > > static inline void > > -rte_mov16(uint8_t *dst, const uint8_t *src) > > +rte_mov16_AVX512F(uint8_t *dst, const uint8_t *src) > > { > > __m128i xmm0; > > > > @@ -93,8 +125,9 @@ rte_mov16(uint8_t *dst, const uint8_t *src) > > * Copy 32 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx512f"))) > > static inline void > > -rte_mov32(uint8_t *dst, const uint8_t *src) > > +rte_mov32_AVX512F(uint8_t *dst, const uint8_t *src) > > { > > __m256i ymm0; > > > > @@ -106,8 +139,9 @@ rte_mov32(uint8_t *dst, const uint8_t *src) > > * Copy 64 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx512f"))) > > static inline void > > -rte_mov64(uint8_t *dst, const uint8_t *src) > > +rte_mov64_AVX512F(uint8_t *dst, const uint8_t *src) > > { > > __m512i zmm0; > > > > @@ -119,32 +153,35 @@ rte_mov64(uint8_t *dst, const uint8_t *src) > > * Copy 128 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx512f"))) > > static inline void > > -rte_mov128(uint8_t *dst, const uint8_t *src) > > +rte_mov128_AVX512F(uint8_t *dst, const uint8_t *src) > > { > > - rte_mov64(dst + 0 * 64, src + 0 * 64); > > - rte_mov64(dst + 1 * 64, src + 1 * 64); > > + (*rte_mov64)(dst + 0 * 64, src + 0 * 64); > > + (*rte_mov64)(dst + 1 * 64, src + 1 * 64); > > } > > > > /** > > * Copy 256 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx512f"))) > > static inline void > > -rte_mov256(uint8_t *dst, const uint8_t *src) > > +rte_mov256_AVX512F(uint8_t *dst, const uint8_t *src) > > { > > - rte_mov64(dst + 0 * 64, src + 0 * 64); > > - rte_mov64(dst + 1 * 64, src + 1 * 64); > > - rte_mov64(dst + 2 * 64, src + 2 * 64); > > - rte_mov64(dst + 3 * 64, src + 3 * 64); > > + (*rte_mov64)(dst + 0 * 64, src + 0 * 64); > > + (*rte_mov64)(dst + 1 * 64, src + 1 * 64); > > + (*rte_mov64)(dst + 2 * 64, src + 2 * 64); > > + (*rte_mov64)(dst + 3 * 64, src + 3 * 64); > > } > > > > /** > > * Copy 128-byte blocks from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx512f"))) > > static inline void > > -rte_mov128blocks(uint8_t *dst, const uint8_t *src, size_t n) > > +rte_mov128blocks_AVX512F(uint8_t *dst, const uint8_t *src, size_t=20 > > +n) > > { > > __m512i zmm0, zmm1; > > > > @@ -163,8 +200,9 @@ rte_mov128blocks(uint8_t *dst, const uint8_t *src, = size_t n) > > * Copy 512-byte blocks from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx512f"))) > > static inline void > > -rte_mov512blocks(uint8_t *dst, const uint8_t *src, size_t n) > > +rte_mov512blocks_AVX512F(uint8_t *dst, const uint8_t *src, size_t=20 > > +n) > > { > > __m512i zmm0, zmm1, zmm2, zmm3, zmm4, zmm5, zmm6, zmm7; > > > > @@ -191,8 +229,9 @@ rte_mov512blocks(uint8_t *dst, const uint8_t *src, = size_t n) > > } > > } > > > > +__attribute__((target("avx512f"))) > > static inline void * > > -rte_memcpy_generic(void *dst, const void *src, size_t n) > > +rte_memcpy_generic_AVX512F(void *dst, const void *src, size_t n) > > { > > uintptr_t dstu =3D (uintptr_t)dst; > > uintptr_t srcu =3D (uintptr_t)src; > > @@ -228,39 +267,39 @@ rte_memcpy_generic(void *dst, const void *src, si= ze_t n) > > * Fast way when copy size doesn't exceed 512 bytes > > */ > > if (n <=3D 32) { > > - rte_mov16((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov16((uint8_t *)dst - 16 + n, > > + (*rte_mov16)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > (const uint8_t *)src - 16 + n); > > return ret; > > } > > if (n <=3D 64) { > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov32((uint8_t *)dst - 32 + n, > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov32)((uint8_t *)dst - 32 + n, > > (const uint8_t *)src - 32 + n); > > return ret; > > } > > if (n <=3D 512) { > > if (n >=3D 256) { > > n -=3D 256; > > - rte_mov256((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov256)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + 256; > > dst =3D (uint8_t *)dst + 256; > > } > > if (n >=3D 128) { > > n -=3D 128; > > - rte_mov128((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov128)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + 128; > > dst =3D (uint8_t *)dst + 128; > > } > > COPY_BLOCK_128_BACK63: > > if (n > 64) { > > - rte_mov64((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov64((uint8_t *)dst - 64 + n, > > + (*rte_mov64)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov64)((uint8_t *)dst - 64 + n, > > (const uint8_t *)src - 64 + n); > > return ret; > > } > > if (n > 0) > > - rte_mov64((uint8_t *)dst - 64 + n, > > + (*rte_mov64)((uint8_t *)dst - 64 + n, > > (const uint8_t *)src - 64 + n); > > return ret; > > } > > @@ -272,7 +311,7 @@ rte_memcpy_generic(void *dst, const void *src, size= _t n) > > if (dstofss > 0) { > > dstofss =3D 64 - dstofss; > > n -=3D dstofss; > > - rte_mov64((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov64)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + dstofss; > > dst =3D (uint8_t *)dst + dstofss; > > } > > @@ -282,7 +321,7 @@ rte_memcpy_generic(void *dst, const void *src, size= _t n) > > * Use copy block function for better instruction order control, > > * which is important when load is unaligned. > > */ > > - rte_mov512blocks((uint8_t *)dst, (const uint8_t *)src, n); > > + (*rte_mov512blocks)((uint8_t *)dst, (const uint8_t *)src, n); > > bits =3D n; > > n =3D n & 511; > > bits -=3D n; > > @@ -295,7 +334,7 @@ rte_memcpy_generic(void *dst, const void *src, size= _t n) > > * which is important when load is unaligned. > > */ > > if (n >=3D 128) { > > - rte_mov128blocks((uint8_t *)dst, (const uint8_t *)src, n); > > + (*rte_mov128blocks)((uint8_t *)dst, (const uint8_t *)src, n); > > bits =3D n; > > n =3D n & 127; > > bits -=3D n; > > @@ -308,10 +347,7 @@ rte_memcpy_generic(void *dst, const void *src, siz= e_t n) > > */ > > goto COPY_BLOCK_128_BACK63; > > } > > - > > -#elif defined RTE_MACHINE_CPUFLAG_AVX2 > > - > > -#define ALIGNMENT_MASK 0x1F > > +#endif > > > > /** > > * AVX2 implementation below > > @@ -321,8 +357,10 @@ rte_memcpy_generic(void *dst, const void *src, siz= e_t n) > > * Copy 16 bytes from one location to another, > > * locations should not overlap. > > */ > > +#ifdef CC_SUPPORT_AVX2 > > +__attribute__((target("avx2"))) > > static inline void > > -rte_mov16(uint8_t *dst, const uint8_t *src) > > +rte_mov16_AVX2(uint8_t *dst, const uint8_t *src) > > { > > __m128i xmm0; > > > > @@ -334,8 +372,9 @@ rte_mov16(uint8_t *dst, const uint8_t *src) > > * Copy 32 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx2"))) > > static inline void > > -rte_mov32(uint8_t *dst, const uint8_t *src) > > +rte_mov32_AVX2(uint8_t *dst, const uint8_t *src) > > { > > __m256i ymm0; > > > > @@ -347,32 +386,35 @@ rte_mov32(uint8_t *dst, const uint8_t *src) > > * Copy 64 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx2"))) > > static inline void > > -rte_mov64(uint8_t *dst, const uint8_t *src) > > +rte_mov64_AVX2(uint8_t *dst, const uint8_t *src) > > { > > - rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32); > > - rte_mov32((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32); > > + (*rte_mov32)((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32); > > + (*rte_mov32)((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 *=20 > > +32); > > } > > > > /** > > * Copy 128 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx2"))) > > static inline void > > -rte_mov128(uint8_t *dst, const uint8_t *src) > > +rte_mov128_AVX2(uint8_t *dst, const uint8_t *src) > > { > > - rte_mov32((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32); > > - rte_mov32((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32); > > - rte_mov32((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32); > > - rte_mov32((uint8_t *)dst + 3 * 32, (const uint8_t *)src + 3 * 32); > > + (*rte_mov32)((uint8_t *)dst + 0 * 32, (const uint8_t *)src + 0 * 32); > > + (*rte_mov32)((uint8_t *)dst + 1 * 32, (const uint8_t *)src + 1 * 32); > > + (*rte_mov32)((uint8_t *)dst + 2 * 32, (const uint8_t *)src + 2 * 32); > > + (*rte_mov32)((uint8_t *)dst + 3 * 32, (const uint8_t *)src + 3 *=20 > > +32); > > } > > > > /** > > * Copy 128-byte blocks from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("avx2"))) > > static inline void > > -rte_mov128blocks(uint8_t *dst, const uint8_t *src, size_t n) > > +rte_mov128blocks_AVX2(uint8_t *dst, const uint8_t *src, size_t n) > > { > > __m256i ymm0, ymm1, ymm2, ymm3; > > > > @@ -391,8 +433,9 @@ rte_mov128blocks(uint8_t *dst, const uint8_t *src, = size_t n) > > } > > } > > > > +__attribute__((target("avx2"))) > > static inline void * > > -rte_memcpy_generic(void *dst, const void *src, size_t n) > > +rte_memcpy_generic_AVX2(void *dst, const void *src, size_t n) > > { > > uintptr_t dstu =3D (uintptr_t)dst; > > uintptr_t srcu =3D (uintptr_t)src; > > @@ -429,46 +472,46 @@ rte_memcpy_generic(void *dst, const void *src, si= ze_t n) > > * Fast way when copy size doesn't exceed 256 bytes > > */ > > if (n <=3D 32) { > > - rte_mov16((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov16((uint8_t *)dst - 16 + n, > > + (*rte_mov16)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > (const uint8_t *)src - 16 + n); > > return ret; > > } > > if (n <=3D 48) { > > - rte_mov16((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov16((uint8_t *)dst + 16, (const uint8_t *)src + 16); > > - rte_mov16((uint8_t *)dst - 16 + n, > > + (*rte_mov16)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov16)((uint8_t *)dst + 16, (const uint8_t *)src + 16); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > (const uint8_t *)src - 16 + n); > > return ret; > > } > > if (n <=3D 64) { > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov32((uint8_t *)dst - 32 + n, > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov32)((uint8_t *)dst - 32 + n, > > (const uint8_t *)src - 32 + n); > > return ret; > > } > > if (n <=3D 256) { > > if (n >=3D 128) { > > n -=3D 128; > > - rte_mov128((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov128)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + 128; > > dst =3D (uint8_t *)dst + 128; > > } > > COPY_BLOCK_128_BACK31: > > if (n >=3D 64) { > > n -=3D 64; > > - rte_mov64((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov64)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + 64; > > dst =3D (uint8_t *)dst + 64; > > } > > if (n > 32) { > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov32((uint8_t *)dst - 32 + n, > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov32)((uint8_t *)dst - 32 + n, > > (const uint8_t *)src - 32 + n); > > return ret; > > } > > if (n > 0) { > > - rte_mov32((uint8_t *)dst - 32 + n, > > + (*rte_mov32)((uint8_t *)dst - 32 + n, > > (const uint8_t *)src - 32 + n); > > } > > return ret; > > @@ -481,7 +524,7 @@ rte_memcpy_generic(void *dst, const void *src, size= _t n) > > if (dstofss > 0) { > > dstofss =3D 32 - dstofss; > > n -=3D dstofss; > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + dstofss; > > dst =3D (uint8_t *)dst + dstofss; > > } > > @@ -489,7 +532,7 @@ rte_memcpy_generic(void *dst, const void *src, size= _t n) > > /** > > * Copy 128-byte blocks > > */ > > - rte_mov128blocks((uint8_t *)dst, (const uint8_t *)src, n); > > + (*rte_mov128blocks)((uint8_t *)dst, (const uint8_t *)src, n); > > bits =3D n; > > n =3D n & 127; > > bits -=3D n; > > @@ -501,10 +544,7 @@ rte_memcpy_generic(void *dst, const void *src, siz= e_t n) > > */ > > goto COPY_BLOCK_128_BACK31; > > } > > - > > -#else /* RTE_MACHINE_CPUFLAG */ > > - > > -#define ALIGNMENT_MASK 0x0F > > +#endif > > > > /** > > * SSE & AVX implementation below > > @@ -514,8 +554,9 @@ rte_memcpy_generic(void *dst, const void *src, size= _t n) > > * Copy 16 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("default"))) > > static inline void > > -rte_mov16(uint8_t *dst, const uint8_t *src) > > +rte_mov16_DEFAULT(uint8_t *dst, const uint8_t *src) > > { > > __m128i xmm0; > > > > @@ -527,66 +568,70 @@ rte_mov16(uint8_t *dst, const uint8_t *src) > > * Copy 32 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("default"))) > > static inline void > > -rte_mov32(uint8_t *dst, const uint8_t *src) > > +rte_mov32_DEFAULT(uint8_t *dst, const uint8_t *src) > > { > > - rte_mov16((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16); > > - rte_mov16((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 * 16); > > + (*rte_mov16)((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16); > > + (*rte_mov16)((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 *=20 > > +16); > > } > > > > /** > > * Copy 64 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("default"))) > > static inline void > > -rte_mov64(uint8_t *dst, const uint8_t *src) > > +rte_mov64_DEFAULT(uint8_t *dst, const uint8_t *src) > > { > > - rte_mov16((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16); > > - rte_mov16((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 * 16); > > - rte_mov16((uint8_t *)dst + 2 * 16, (const uint8_t *)src + 2 * 16); > > - rte_mov16((uint8_t *)dst + 3 * 16, (const uint8_t *)src + 3 * 16); > > + (*rte_mov16)((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16); > > + (*rte_mov16)((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 * 16); > > + (*rte_mov16)((uint8_t *)dst + 2 * 16, (const uint8_t *)src + 2 * 16); > > + (*rte_mov16)((uint8_t *)dst + 3 * 16, (const uint8_t *)src + 3 *=20 > > +16); > > } > > > > /** > > * Copy 128 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("default"))) > > static inline void > > -rte_mov128(uint8_t *dst, const uint8_t *src) > > +rte_mov128_DEFAULT(uint8_t *dst, const uint8_t *src) > > { > > - rte_mov16((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16); > > - rte_mov16((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 * 16); > > - rte_mov16((uint8_t *)dst + 2 * 16, (const uint8_t *)src + 2 * 16); > > - rte_mov16((uint8_t *)dst + 3 * 16, (const uint8_t *)src + 3 * 16); > > - rte_mov16((uint8_t *)dst + 4 * 16, (const uint8_t *)src + 4 * 16); > > - rte_mov16((uint8_t *)dst + 5 * 16, (const uint8_t *)src + 5 * 16); > > - rte_mov16((uint8_t *)dst + 6 * 16, (const uint8_t *)src + 6 * 16); > > - rte_mov16((uint8_t *)dst + 7 * 16, (const uint8_t *)src + 7 * 16); > > + (*rte_mov16)((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16); > > + (*rte_mov16)((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 * 16); > > + (*rte_mov16)((uint8_t *)dst + 2 * 16, (const uint8_t *)src + 2 * 16); > > + (*rte_mov16)((uint8_t *)dst + 3 * 16, (const uint8_t *)src + 3 * 16); > > + (*rte_mov16)((uint8_t *)dst + 4 * 16, (const uint8_t *)src + 4 * 16); > > + (*rte_mov16)((uint8_t *)dst + 5 * 16, (const uint8_t *)src + 5 * 16); > > + (*rte_mov16)((uint8_t *)dst + 6 * 16, (const uint8_t *)src + 6 * 16); > > + (*rte_mov16)((uint8_t *)dst + 7 * 16, (const uint8_t *)src + 7 *=20 > > +16); > > } > > > > /** > > * Copy 256 bytes from one location to another, > > * locations should not overlap. > > */ > > +__attribute__((target("default"))) > > static inline void > > -rte_mov256(uint8_t *dst, const uint8_t *src) > > +rte_mov256_DEFAULT(uint8_t *dst, const uint8_t *src) > > { > > - rte_mov16((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16); > > - rte_mov16((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 * 16); > > - rte_mov16((uint8_t *)dst + 2 * 16, (const uint8_t *)src + 2 * 16); > > - rte_mov16((uint8_t *)dst + 3 * 16, (const uint8_t *)src + 3 * 16); > > - rte_mov16((uint8_t *)dst + 4 * 16, (const uint8_t *)src + 4 * 16); > > - rte_mov16((uint8_t *)dst + 5 * 16, (const uint8_t *)src + 5 * 16); > > - rte_mov16((uint8_t *)dst + 6 * 16, (const uint8_t *)src + 6 * 16); > > - rte_mov16((uint8_t *)dst + 7 * 16, (const uint8_t *)src + 7 * 16); > > - rte_mov16((uint8_t *)dst + 8 * 16, (const uint8_t *)src + 8 * 16); > > - rte_mov16((uint8_t *)dst + 9 * 16, (const uint8_t *)src + 9 * 16); > > - rte_mov16((uint8_t *)dst + 10 * 16, (const uint8_t *)src + 10 * 16); > > - rte_mov16((uint8_t *)dst + 11 * 16, (const uint8_t *)src + 11 * 16); > > - rte_mov16((uint8_t *)dst + 12 * 16, (const uint8_t *)src + 12 * 16); > > - rte_mov16((uint8_t *)dst + 13 * 16, (const uint8_t *)src + 13 * 16); > > - rte_mov16((uint8_t *)dst + 14 * 16, (const uint8_t *)src + 14 * 16); > > - rte_mov16((uint8_t *)dst + 15 * 16, (const uint8_t *)src + 15 * 16); > > + (*rte_mov16)((uint8_t *)dst + 0 * 16, (const uint8_t *)src + 0 * 16); > > + (*rte_mov16)((uint8_t *)dst + 1 * 16, (const uint8_t *)src + 1 * 16); > > + (*rte_mov16)((uint8_t *)dst + 2 * 16, (const uint8_t *)src + 2 * 16); > > + (*rte_mov16)((uint8_t *)dst + 3 * 16, (const uint8_t *)src + 3 * 16); > > + (*rte_mov16)((uint8_t *)dst + 4 * 16, (const uint8_t *)src + 4 * 16); > > + (*rte_mov16)((uint8_t *)dst + 5 * 16, (const uint8_t *)src + 5 * 16); > > + (*rte_mov16)((uint8_t *)dst + 6 * 16, (const uint8_t *)src + 6 * 16); > > + (*rte_mov16)((uint8_t *)dst + 7 * 16, (const uint8_t *)src + 7 * 16); > > + (*rte_mov16)((uint8_t *)dst + 8 * 16, (const uint8_t *)src + 8 * 16); > > + (*rte_mov16)((uint8_t *)dst + 9 * 16, (const uint8_t *)src + 9 * 16); > > + (*rte_mov16)((uint8_t *)dst + 10 * 16, (const uint8_t *)src + 10 * 16= ); > > + (*rte_mov16)((uint8_t *)dst + 11 * 16, (const uint8_t *)src + 11 * 16= ); > > + (*rte_mov16)((uint8_t *)dst + 12 * 16, (const uint8_t *)src + 12 * 16= ); > > + (*rte_mov16)((uint8_t *)dst + 13 * 16, (const uint8_t *)src + 13 * 16= ); > > + (*rte_mov16)((uint8_t *)dst + 14 * 16, (const uint8_t *)src + 14 * 16= ); > > + (*rte_mov16)((uint8_t *)dst + 15 * 16, (const uint8_t *)src + 15 *=20 > > +16); > > } > > > > /** > > @@ -683,8 +728,9 @@ __extension__ ({ = \ > > } = \ > > }) > > > > +__attribute__((target("default"))) > > static inline void * > > -rte_memcpy_generic(void *dst, const void *src, size_t n) > > +rte_memcpy_generic_DEFAULT(void *dst, const void *src, size_t n) > > { > > __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8; > > uintptr_t dstu =3D (uintptr_t)dst; > > @@ -722,19 +768,22 @@ rte_memcpy_generic(void *dst, const void *src, si= ze_t n) > > * Fast way when copy size doesn't exceed 512 bytes > > */ > > if (n <=3D 32) { > > - rte_mov16((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov16((uint8_t *)dst - 16 + n, (const uint8_t *)src - 16 + n); > > + (*rte_mov16)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > + (const uint8_t *)src - 16 + n); > > return ret; > > } > > if (n <=3D 48) { > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov16((uint8_t *)dst - 16 + n, (const uint8_t *)src - 16 + n); > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > + (const uint8_t *)src - 16 + n); > > return ret; > > } > > if (n <=3D 64) { > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov16((uint8_t *)dst + 32, (const uint8_t *)src + 32); > > - rte_mov16((uint8_t *)dst - 16 + n, (const uint8_t *)src - 16 + n); > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov16)((uint8_t *)dst + 32, (const uint8_t *)src + 32); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > + (const uint8_t *)src - 16 + n); > > return ret; > > } > > if (n <=3D 128) { > > @@ -743,39 +792,42 @@ rte_memcpy_generic(void *dst, const void *src, si= ze_t n) > > if (n <=3D 512) { > > if (n >=3D 256) { > > n -=3D 256; > > - rte_mov128((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov128((uint8_t *)dst + 128, (const uint8_t *)src + 128); > > + (*rte_mov128)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov128)((uint8_t *)dst + 128, > > + (const uint8_t *)src + 128); > > src =3D (const uint8_t *)src + 256; > > dst =3D (uint8_t *)dst + 256; > > } > > COPY_BLOCK_255_BACK15: > > if (n >=3D 128) { > > n -=3D 128; > > - rte_mov128((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov128)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + 128; > > dst =3D (uint8_t *)dst + 128; > > } > > COPY_BLOCK_128_BACK15: > > if (n >=3D 64) { > > n -=3D 64; > > - rte_mov64((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov64)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + 64; > > dst =3D (uint8_t *)dst + 64; > > } > > COPY_BLOCK_64_BACK15: > > if (n >=3D 32) { > > n -=3D 32; > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + 32; > > dst =3D (uint8_t *)dst + 32; > > } > > if (n > 16) { > > - rte_mov16((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov16((uint8_t *)dst - 16 + n, (const uint8_t *)src - 16 + n); > > + (*rte_mov16)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > + (const uint8_t *)src - 16 + n); > > return ret; > > } > > if (n > 0) { > > - rte_mov16((uint8_t *)dst - 16 + n, (const uint8_t *)src - 16 + n); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > + (const uint8_t *)src - 16 + n); > > } > > return ret; > > } > > @@ -790,7 +842,7 @@ rte_memcpy_generic(void *dst, const void *src, size= _t n) > > if (dstofss > 0) { > > dstofss =3D 16 - dstofss + 16; > > n -=3D dstofss; > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > src =3D (const uint8_t *)src + dstofss; > > dst =3D (uint8_t *)dst + dstofss; > > } > > @@ -804,7 +856,7 @@ rte_memcpy_generic(void *dst, const void *src, size= _t n) > > * Copy 256-byte blocks > > */ > > for (; n >=3D 256; n -=3D 256) { > > - rte_mov256((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov256)((uint8_t *)dst, (const uint8_t *)src); > > dst =3D (uint8_t *)dst + 256; > > src =3D (const uint8_t *)src + 256; > > } > > @@ -826,7 +878,46 @@ rte_memcpy_generic(void *dst, const void *src, siz= e_t n) > > goto COPY_BLOCK_64_BACK15; > > } > > > > -#endif /* RTE_MACHINE_CPUFLAG */ > > +static void __attribute__((constructor)) > > +rte_memcpy_init(void) > > +{ > > +#ifdef CC_SUPPORT_AVX512 > > + if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX512F)) { > > + alignment_mask =3D 0x3F; > > + rte_mov16 =3D rte_mov16_AVX512F; > > + rte_mov32 =3D rte_mov32_AVX512F; > > + rte_mov64 =3D rte_mov64_AVX512F; > > + rte_mov128 =3D rte_mov128_AVX512F; > > + rte_mov256 =3D rte_mov256_AVX512F; > > + rte_mov128blocks =3D rte_mov128blocks_AVX512F; > > + rte_mov512blocks =3D rte_mov512blocks_AVX512F; > > + rte_memcpy_generic =3D rte_memcpy_generic_AVX512F; > > + RTE_LOG(INFO, EAL, "AVX512 implementation of memcpy() is using!\n"); > > + } else > > +#endif > > +#ifdef CC_SUPPORT_AVX2 > > + if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_AVX2)) { > > + alignment_mask =3D 0x1F; > > + rte_mov16 =3D rte_mov16_AVX2; > > + rte_mov32 =3D rte_mov32_AVX2; > > + rte_mov64 =3D rte_mov64_AVX2; > > + rte_mov128 =3D rte_mov128_AVX2; > > + rte_mov128blocks =3D rte_mov128blocks_AVX2; > > + rte_memcpy_generic =3D rte_memcpy_generic_AVX2; > > + RTE_LOG(INFO, EAL, "AVX2 implementation of memcpy() is using!\n"); > > + } else > > +#endif > > + { > > + alignment_mask =3D 0x0F; > > + rte_mov16 =3D rte_mov16_DEFAULT; > > + rte_mov32 =3D rte_mov32_DEFAULT; > > + rte_mov64 =3D rte_mov64_DEFAULT; > > + rte_mov128 =3D rte_mov128_DEFAULT; > > + rte_mov256 =3D rte_mov256_DEFAULT; > > + rte_memcpy_generic =3D rte_memcpy_generic_DEFAULT; > > + RTE_LOG(INFO, EAL, "Default SSE/AVX implementation of memcpy() is us= ing!\n"); > > + } > > +} > > > > static inline void * > > rte_memcpy_aligned(void *dst, const void *src, size_t n) @@ -858,8=20 > > +949,8 @@ rte_memcpy_aligned(void *dst, const void *src, size_t n) > > > > /* Copy 16 <=3D size <=3D 32 bytes */ > > if (n <=3D 32) { > > - rte_mov16((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov16((uint8_t *)dst - 16 + n, > > + (*rte_mov16)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov16)((uint8_t *)dst - 16 + n, > > (const uint8_t *)src - 16 + n); > > > > return ret; > > @@ -867,8 +958,8 @@ rte_memcpy_aligned(void *dst, const void *src,=20 > > size_t n) > > > > /* Copy 32 < size <=3D 64 bytes */ > > if (n <=3D 64) { > > - rte_mov32((uint8_t *)dst, (const uint8_t *)src); > > - rte_mov32((uint8_t *)dst - 32 + n, > > + (*rte_mov32)((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov32)((uint8_t *)dst - 32 + n, > > (const uint8_t *)src - 32 + n); > > > > return ret; > > @@ -876,13 +967,13 @@ rte_memcpy_aligned(void *dst, const void *src,=20 > > size_t n) > > > > /* Copy 64 bytes blocks */ > > for (; n >=3D 64; n -=3D 64) { > > - rte_mov64((uint8_t *)dst, (const uint8_t *)src); > > + (*rte_mov64)((uint8_t *)dst, (const uint8_t *)src); > > dst =3D (uint8_t *)dst + 64; > > src =3D (const uint8_t *)src + 64; > > } > > > > /* Copy whatever left */ > > - rte_mov64((uint8_t *)dst - 64 + n, > > + (*rte_mov64)((uint8_t *)dst - 64 + n, > > (const uint8_t *)src - 64 + n); > > > > return ret; > > @@ -891,10 +982,10 @@ rte_memcpy_aligned(void *dst, const void *src,=20 > > size_t n) static inline void * rte_memcpy(void *dst, const void=20 > > *src, size_t n) { > > - if (!(((uintptr_t)dst | (uintptr_t)src) & ALIGNMENT_MASK)) > > + if (!(((uintptr_t)dst | (uintptr_t)src) & alignment_mask)) > > return rte_memcpy_aligned(dst, src, n); > > else > > - return rte_memcpy_generic(dst, src, n); > > + return (*rte_memcpy_generic)(dst, src, n); > > } > > > > #ifdef __cplusplus > > diff --git a/mk/rte.cpuflags.mk b/mk/rte.cpuflags.mk index=20 > > a813c91..92399ec 100644 > > --- a/mk/rte.cpuflags.mk > > +++ b/mk/rte.cpuflags.mk > > @@ -141,3 +141,17 @@ space:=3D $(empty) $(empty) > > CPUFLAGSTMP1 :=3D $(addprefix RTE_CPUFLAG_,$(CPUFLAGS)) > > CPUFLAGSTMP2 :=3D $(subst $(space),$(comma),$(CPUFLAGSTMP1)) > > CPUFLAGS_LIST :=3D -DRTE_COMPILE_TIME_CPUFLAGS=3D$(CPUFLAGSTMP2) > > + > > +# Check if the compiler supports AVX512. > > +CC_SUPPORT_AVX512 :=3D $(shell $(CC) -march=3Dskylake-avx512 -dM -E - = <=20 > > +/dev/null 2>&1 | grep -q AVX512 && echo 1) ifeq=20 > > +($(CC_SUPPORT_AVX512),1) ifeq ($(CONFIG_RTE_ENABLE_AVX512),y)=20 > > +MACHINE_CFLAGS +=3D -DCC_SUPPORT_AVX512 endif endif > > + > > +# Check if the compiler supports AVX2. > > +CC_SUPPORT_AVX2 :=3D $(shell $(CC) -march=3Dcore-avx2 -dM -E - <=20 > > +/dev/null 2>&1 | grep -q AVX2 && echo 1) ifeq=20 > > +($(CC_SUPPORT_AVX2),1) MACHINE_CFLAGS +=3D -DCC_SUPPORT_AVX2 endif > > -- > > 2.7.4