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 459C5A0C43; Thu, 21 Oct 2021 21:29:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 51C0C41104; Thu, 21 Oct 2021 21:29:04 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) by mails.dpdk.org (Postfix) with ESMTP id B19D34003F for ; Thu, 21 Oct 2021 21:03:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VtudcHF/1Bl7aC/pEw6m5pW/4c5+kAwPUmfp+HTrJsPFnwhl9Jb+opORBEf8PUeFBrphC/zA1oquYZaZAPOkWG8fbZQUWIn/KT1Ggf9JCz/CPJtfFlHU8aeH0u4sFAqC2ZuoKKZujwW7cnacQ9xRvE1rsklqQ1pzZLO2bmBpJhHE3e5QU1VLaZ5Cm01APkv9kI3Uh22jpDpeYEfybv0I2W4vIBHBlslRzOmZXPMiKFzK9PjL9HCtXMSVVMPPO3LGS1CrsRw/gzfx1WlhbCmI0ysOP34mLNCmzO/2yho8fcPG/8yXdXNsKbS1sFMXqS2L8IzajeZwc8Lb8AlFuE4BHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hnrdK0/kOB4oVNkZo7E4cfX8cPsCOaFDjYzfeb8eHTg=; b=T09i0bmNXQCMBsb5y8PuRugLDXMmwOqMFO6/0eTwdtS7FxtnnviVf0GLiP83aJI8Pg7zR9gIoiqZ1wPEcVs7l6iJNI1UINnEV1Q27cK8dSG+ZIXQ2/bdI3On6LbdcN8K4eidP1T1Z6KbDZhlF5bKpOJonSctCjwL3JDlq1fquY+Pwut8u+tZgYiPtB/eAvEpvv6IebZyhNe2jiYfBjVxCLnDYVMIpihY/+iTJJOBJIFtLUVqsIYNxeTCI0HbgLP4PiVvX3GCVPfKQRS4KykwoTCPo2UEx2Im40aetwwrQ8jIH8Hotq4cRfcahebdE5E1sM9QDFiG797HLb/6S1fi8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hnrdK0/kOB4oVNkZo7E4cfX8cPsCOaFDjYzfeb8eHTg=; b=nZkrLWf9CA1sRp2REUUnEN26bnRKbxuCWw3LqThk+oO3xHFALY4B2B3lqt+8408P9+4dcDJHEMHg2ixhnvZr4d4WlLAfiElsuDheeRrcoymTrI6PFeGEHJ7a/wKBF87FiFKeHE4RwwfAWmDSbPvn0b3Xv4/6JSwzzKuQcnmT62g= Received: from BY5PR12MB3681.namprd12.prod.outlook.com (2603:10b6:a03:194::16) by BY5PR12MB3826.namprd12.prod.outlook.com (2603:10b6:a03:1a1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.18; Thu, 21 Oct 2021 19:03:11 +0000 Received: from BY5PR12MB3681.namprd12.prod.outlook.com ([fe80::1419:77f5:8c88:c53c]) by BY5PR12MB3681.namprd12.prod.outlook.com ([fe80::1419:77f5:8c88:c53c%7]) with mapi id 15.20.4628.018; Thu, 21 Oct 2021 19:03:11 +0000 From: "Song, Keesang" To: Thomas Monjalon , Aman Kumar CC: "Ananyev, Konstantin" , "dev@dpdk.org" , "rasland@nvidia.com" , "asafp@nvidia.com" , "shys@nvidia.com" , "viacheslavo@nvidia.com" , "akozyrev@nvidia.com" , "matan@nvidia.com" , "Burakov, Anatoly" , "aman.kumar@vvdntech.in" , "jerinjacobk@gmail.com" , "Richardson, Bruce" , "david.marchand@redhat.com" Thread-Topic: [dpdk-dev] [PATCH v2 1/2] lib/eal: add amd epyc2 memcpy routine to eal Thread-Index: AQHXxNbCgvZjpzZirEenQtfW+ZBt0qvaQKyAgANxrPCAAAlrgIAABxHAgAAKHYCAAANfIA== Date: Thu, 21 Oct 2021 19:03:11 +0000 Message-ID: References: <20210823084411.29592-1-aman.kumar@vvdntech.in> <2486642.Qmzdh8hRR2@thomas> In-Reply-To: <2486642.Qmzdh8hRR2@thomas> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_ActionId=c2ba09a3-6e87-4d7b-b092-bc037dfd069e; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_ContentBits=0; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Enabled=true; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Method=Standard; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_Name=AMD Official Use Only-AIP 2.0; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_SetDate=2021-10-21T18:53:54Z; MSIP_Label_88914ebd-7e6c-4e12-a031-a9906be2db14_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; authentication-results: monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f013dc26-80d8-476f-a749-08d994c56da8 x-ms-traffictypediagnostic: BY5PR12MB3826: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rCDdcjB+MOoPWwhBtgjgSk80hKtyE0Rm/n6OhzWIkRf8f9DZ0D+hsc8Y/KIMPPo45TUhoZe3MAkBGHZRn4yGrvg1GcsS5/T7COEdY2KvF0Ynn12uEAejugnaE0D4Q7qlLcXORGH7b0TyuGJ1K8dZ85lvaQOce7w+iHeLjVAfXLhWPZfHNqOb1Y3gurQ0K/x6bjqgqhrwtrNuVDx4KUkdtY1EZJmS0PDN8TUJwgO5wZk0/brwMG6H3ahd2OLKtWAlXOR4YLl0L7TA0D52+j7rHXkWZ4BG+GggASW+ttYSLuMRUMB3XmEDPkoJBRyLGcSY4flDdxuHsiTIxosNjiTjMpFhj59AiIMrz9GCOgSoJwqaM1FaGSLzSE9eABOaks67fFmhU2WLnxrRo2ddQWQ6oH/ZZNfjpdLbWSa4Q5zfEglAXMsqsYmXJ2kVGkPSrEJupqBUlqIa3m34o/DJ9eAPK3SAcTy8gDp4wH56lrchc6PBqay02ALKZIXm4Yu3Y6/1uBfqSzyHlTsnQKuzqK9Xm7X5WxfTRg81FZ0qQNJqbO2aeH8SJfL6CRs+8Wdo919EAv4+gTG0brO/+qI5eXxCr/tgRGoUcb3F9oW5QB/0nmicKjPMe5USteufQYOZxM3AuCcs8HDb9uKcj/OaCm0nnqGfU1kGWY3dUdLJV6w6L5NTREr3/CxEKD8FyPZtH1bDGGl6fRjrfZHm8VJNOtXjkg== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR12MB3681.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(4326008)(71200400001)(5660300002)(316002)(55016002)(8676002)(86362001)(66476007)(52536014)(186003)(30864003)(66556008)(8936002)(76116006)(64756008)(66446008)(66946007)(7416002)(83380400001)(26005)(38100700002)(53546011)(9686003)(38070700005)(7696005)(508600001)(54906003)(122000001)(6506007)(110136005)(33656002)(2906002)(579004); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?+OXXxcOzRdfLKwHzBXtwsNhbokW3Kur9dl1jGGcMkVEmS4i3uBsPphJjAp2m?= =?us-ascii?Q?68ktq0C+0v96mKBedJqga8ISbau5UKFzS57BPmNCGD5QRJSN8+IUNPch5ipE?= =?us-ascii?Q?OI8Y6for/TTm3YIE/MsNnCJTpFzL1JjO0yMC8tnZaGiUliJbsD8Uff0TJjGE?= =?us-ascii?Q?fKUBbOL9fh2UnmzOUyl/HVQ/Tv772OOMs6PW2IGNimMyHzmN3wFgkgo2z5mV?= =?us-ascii?Q?l1tvWEkFuENxKGPVSDJxmFQv0bbQuMzqcsyKkQnJqvYpafrFqfsDzd/Of7Be?= =?us-ascii?Q?JzmrHfzMWTM26wCoFIShQ4yWPInkRre8OLhC66GudcnGbjyPZPBc1QKtl1ZX?= =?us-ascii?Q?lCCb7bzgo60xRxxVvrkrEcsIIyzcRNTn82vvoSWy1OOZetIlm2gi+ew+VfU3?= =?us-ascii?Q?q+WKFsOZMqyWt5l9YqavzkZl9YCI/Tk1UR/Kp172uRDDckJOJmN2p/bOITUv?= =?us-ascii?Q?SgyXYbyZoYhPXfhYHVLrB0k1xTDGb0kSlCzXHdPuy/19OQWJiZKuOHsgq4+b?= =?us-ascii?Q?K1LxnLqOUY3Cmcr3iYERrwCRALs0Lr+SVXMJiSP5au89M1DpNPaJrE22CNkr?= =?us-ascii?Q?QYxrS8T9BVouz3YfzBK0jRF5f+Ll+DjQtfGDZdDcfxk56OyA4jcWpvkUpHhH?= =?us-ascii?Q?6rk8bTyzkQ14ieysAylvcTWIiW7Mi7SqCeYiYOr94yef7pOPcAViXRgjJDTN?= =?us-ascii?Q?CQsBzuxzT/9iGpSRuinpcG1MX/5P/so4qwhfFRHQHLkxJR5BDTkLDh4fQtxz?= =?us-ascii?Q?cjTiwGP8d+bAzjjwnF5/LlXVsNIonQABRG0hISEmw7VDcBn2b5JEPyTjFepL?= =?us-ascii?Q?RZHRXwKFjMrCg5eMf3AZKlvFtKpj03XF4jPw8Dmg/6HvvoWp7szEbUKdHGmi?= =?us-ascii?Q?S/EmBix00U/tj/uN6GYomPn9Luj7Z20VFBU3KXUEmW/x3+lS0+ml8ZxBJDYo?= =?us-ascii?Q?1zAjPhr9bhbxHVbM3G67278YajhQMB49hR7or47xFzCYHGItHPgRciSgwoud?= =?us-ascii?Q?E9CfY0utNK0EpVxd7WrqPKFnFEW3r8AgTCtqQEeWqLAVfURc/0tfTTka2MoV?= =?us-ascii?Q?t1LP/N0kcdY9bB2stdT3z7rel8HqNr+qi+/bVZG0wsGKd6g60m/U4Be34X+5?= =?us-ascii?Q?nZnFyB9+3sLExyXd/1xaFpdmSUrylKU6rAfL6t2lvcPGKyvfUP5Hvp6WDNkd?= =?us-ascii?Q?QPmdOfiofAp+G9bTOPpeIWRbfoy9hxm5iOaxbuTebA5g041KkP4ft+Yh93Oh?= =?us-ascii?Q?SzOQhQG1V/kQdynHdre/RammgKNawOk2i8FcwIyKrBLI+CTCbbcofJGCJnbC?= =?us-ascii?Q?rVWNnyF+Hu/1BX06JWyjP6R/?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB3681.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f013dc26-80d8-476f-a749-08d994c56da8 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Oct 2021 19:03:11.7704 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: keessong@amd.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB3826 X-Mailman-Approved-At: Thu, 21 Oct 2021 21:29:00 +0200 Subject: Re: [dpdk-dev] [PATCH v2 1/2] lib/eal: add amd epyc2 memcpy routine to eal 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 Sender: "dev" [AMD Official Use Only] Hi Thomas, I've already asked our AMD tools team, but they're saying they are not real= ly familiar with C code implementation. We need your approval for now since= we really need to get this patch submitted to 21.11 LTS. Thanks, Keesang -----Original Message----- From: Thomas Monjalon Sent: Thursday, October 21, 2021 11:42 AM To: Aman Kumar ; Song, Keesang Cc: Ananyev, Konstantin ; dev@dpdk.org; rasla= nd@nvidia.com; asafp@nvidia.com; shys@nvidia.com; viacheslavo@nvidia.com; a= kozyrev@nvidia.com; matan@nvidia.com; Burakov, Anatoly ; aman.kumar@vvdntech.in; jerinjacobk@gmail.com; Richardson, Bruce <= bruce.richardson@intel.com>; david.marchand@redhat.com Subject: Re: [dpdk-dev] [PATCH v2 1/2] lib/eal: add amd epyc2 memcpy routin= e to eal [CAUTION: External Email] Please convert it to C code, thanks. 21/10/2021 20:12, Song, Keesang: > [AMD Official Use Only] > > Hi Ananyev, > > The current memcpy implementation in Glibc is based out of assembly codin= g. > Although memcpy could have been implemented with intrinsic, but since our= AMD library developers are working on the Glibc functions, they have provi= ded a tailored implementation based out of inline assembly coding. > > Thanks for your support, > Keesang > > -----Original Message----- > From: Ananyev, Konstantin > Sent: Thursday, October 21, 2021 10:40 AM > To: Song, Keesang ; Thomas Monjalon > ; Aman Kumar > Cc: dev@dpdk.org; rasland@nvidia.com; asafp@nvidia.com; > shys@nvidia.com; viacheslavo@nvidia.com; akozyrev@nvidia.com; > matan@nvidia.com; Burakov, Anatoly ; > aman.kumar@vvdntech.in; jerinjacobk@gmail.com; Richardson, Bruce > ; david.marchand@redhat.com > Subject: RE: [dpdk-dev] [PATCH v2 1/2] lib/eal: add amd epyc2 memcpy > routine to eal > > [AMD Official Use Only] > > [CAUTION: External Email] > > > > > Hi Thomas, > > > > I hope this can make some explanation to your question. > > We(AMD Linux library support team) have implemented the custom > > tailored memcpy solution which is a close match with DPDK use case requ= irements like the below. > > 1) Min 64B length data packet with cache aligned Source and Destin= ation. > > 2) Non-Temporal load and temporal store for cache aligned source f= or both RX and TX paths. Could not implement the non-temporal > > store for TX_PATH, as non-Temporal load/stores works only with 32B alig= ned addresses for AVX2 > > 3) This solution works for all AVX2 supported AMD machines. > > > > Internally we have completed the integrity testing and benchmarking > > of the solution and found gains of 8.4% to 14.5% specifically on > > Milan CPU(3rd Gen of EPYC Processor) > > It still not clear to me why it has to be written in assembler. > Why similar stuff can't be written in C with instincts, as rest of rte_me= mcpy.h does? > > > > > Thanks for your support, > > Keesang > > > > -----Original Message----- > > From: Thomas Monjalon > > Sent: Tuesday, October 19, 2021 5:31 AM > > To: Aman Kumar > > Cc: dev@dpdk.org; rasland@nvidia.com; asafp@nvidia.com; > > shys@nvidia.com; viacheslavo@nvidia.com; akozyrev@nvidia.com; > > matan@nvidia.com; anatoly.burakov@intel.com; Song, Keesang > > ; aman.kumar@vvdntech.in; > > jerinjacobk@gmail.com; bruce.richardson@intel.com; > > konstantin.ananyev@intel.com; david.marchand@redhat.com > > Subject: Re: [dpdk-dev] [PATCH v2 1/2] lib/eal: add amd epyc2 memcpy > > routine to eal > > > > [CAUTION: External Email] > > > > 19/10/2021 12:47, Aman Kumar: > > > This patch provides rte_memcpy* calls optimized for AMD EPYC > > > platforms. Use config/x86/x86_amd_epyc_linux_gcc as cross-file > > > with meson to build dpdk for AMD EPYC platforms. > > > > Please split in 2 patches: platform & memcpy. > > > > What optimization is specific to EPYC? > > > > I dislike the asm code below. > > What is AMD specific inside? > > Can it use compiler intrinsics as it is done elsewhere? > > > > > +static __rte_always_inline void * > > > +rte_memcpy_aligned_ntload_tstore16_amdepyc2(void *dst, > > > + const void *src, > > > + size_t size) { > > > + asm volatile goto("movq %0, %%rsi\n\t" > > > + "movq %1, %%rdi\n\t" > > > + "movq %2, %%rdx\n\t" > > > + "cmpq $(128), %%rdx\n\t" > > > + "jb 202f\n\t" > > > + "201:\n\t" > > > + "vmovntdqa (%%rsi), %%ymm0\n\t" > > > + "vmovntdqa 32(%%rsi), %%ymm1\n\t" > > > + "vmovntdqa 64(%%rsi), %%ymm2\n\t" > > > + "vmovntdqa 96(%%rsi), %%ymm3\n\t" > > > + "vmovdqu %%ymm0, (%%rdi)\n\t" > > > + "vmovdqu %%ymm1, 32(%%rdi)\n\t" > > > + "vmovdqu %%ymm2, 64(%%rdi)\n\t" > > > + "vmovdqu %%ymm3, 96(%%rdi)\n\t" > > > + "addq $128, %%rsi\n\t" > > > + "addq $128, %%rdi\n\t" > > > + "subq $128, %%rdx\n\t" > > > + "jz %l[done]\n\t" > > > + "cmpq $128, %%rdx\n\t" /*Vector Size 32B. */ > > > + "jae 201b\n\t" > > > + "202:\n\t" > > > + "cmpq $64, %%rdx\n\t" > > > + "jb 203f\n\t" > > > + "vmovntdqa (%%rsi), %%ymm0\n\t" > > > + "vmovntdqa 32(%%rsi), %%ymm1\n\t" > > > + "vmovdqu %%ymm0, (%%rdi)\n\t" > > > + "vmovdqu %%ymm1, 32(%%rdi)\n\t" > > > + "addq $64, %%rsi\n\t" > > > + "addq $64, %%rdi\n\t" > > > + "subq $64, %%rdx\n\t" > > > + "jz %l[done]\n\t" > > > + "203:\n\t" > > > + "cmpq $32, %%rdx\n\t" > > > + "jb 204f\n\t" > > > + "vmovntdqa (%%rsi), %%ymm0\n\t" > > > + "vmovdqu %%ymm0, (%%rdi)\n\t" > > > + "addq $32, %%rsi\n\t" > > > + "addq $32, %%rdi\n\t" > > > + "subq $32, %%rdx\n\t" > > > + "jz %l[done]\n\t" > > > + "204:\n\t" > > > + "cmpb $16, %%dl\n\t" > > > + "jb 205f\n\t" > > > + "vmovntdqa (%%rsi), %%xmm0\n\t" > > > + "vmovdqu %%xmm0, (%%rdi)\n\t" > > > + "addq $16, %%rsi\n\t" > > > + "addq $16, %%rdi\n\t" > > > + "subq $16, %%rdx\n\t" > > > + "jz %l[done]\n\t" > > > + "205:\n\t" > > > + "cmpb $2, %%dl\n\t" > > > + "jb 208f\n\t" > > > + "cmpb $4, %%dl\n\t" > > > + "jbe 207f\n\t" > > > + "cmpb $8, %%dl\n\t" > > > + "jbe 206f\n\t" > > > + "movq -8(%%rsi,%%rdx), %%rcx\n\t" > > > + "movq (%%rsi), %%rsi\n\t" > > > + "movq %%rcx, -8(%%rdi,%%rdx)\n\t" > > > + "movq %%rsi, (%%rdi)\n\t" > > > + "jmp %l[done]\n\t" > > > + "206:\n\t" > > > + "movl -4(%%rsi,%%rdx), %%ecx\n\t" > > > + "movl (%%rsi), %%esi\n\t" > > > + "movl %%ecx, -4(%%rdi,%%rdx)\n\t" > > > + "movl %%esi, (%%rdi)\n\t" > > > + "jmp %l[done]\n\t" > > > + "207:\n\t" > > > + "movzwl -2(%%rsi,%%rdx), %%ecx\n\t" > > > + "movzwl (%%rsi), %%esi\n\t" > > > + "movw %%cx, -2(%%rdi,%%rdx)\n\t" > > > + "movw %%si, (%%rdi)\n\t" > > > + "jmp %l[done]\n\t" > > > + "208:\n\t" > > > + "movzbl (%%rsi), %%ecx\n\t" > > > + "movb %%cl, (%%rdi)" > > > + : > > > + : "r"(src), "r"(dst), "r"(size) > > > + : "rcx", "rdx", "rsi", "rdi", "ymm0", "ymm1", "ymm2", "ymm3", "= memory" > > > + : done > > > + ); > > > +done: > > > + return dst; > > > +} > > > + > > > +static __rte_always_inline void * rte_memcpy_generic(void *dst, > > > +const void *src, size_t len) { > > > + asm goto("movq %0, %%rsi\n\t" > > > + "movq %1, %%rdi\n\t" > > > + "movq %2, %%rdx\n\t" > > > + "movq %%rdi, %%rax\n\t" > > > + "cmp $32, %%rdx\n\t" > > > + "jb 101f\n\t" > > > + "cmp $(32 * 2), %%rdx\n\t" > > > + "ja 108f\n\t" > > > + "vmovdqu (%%rsi), %%ymm0\n\t" > > > + "vmovdqu -32(%%rsi,%%rdx), %%ymm1\n\t" > > > + "vmovdqu %%ymm0, (%%rdi)\n\t" > > > + "vmovdqu %%ymm1, -32(%%rdi,%%rdx)\n\t" > > > + "vzeroupper\n\t" > > > + "jmp %l[done]\n\t" > > > + "101:\n\t" > > > + /* Less than 1 VEC. */ > > > + "cmpb $32, %%dl\n\t" > > > + "jae 103f\n\t" > > > + "cmpb $16, %%dl\n\t" > > > + "jae 104f\n\t" > > > + "cmpb $8, %%dl\n\t" > > > + "jae 105f\n\t" > > > + "cmpb $4, %%dl\n\t" > > > + "jae 106f\n\t" > > > + "cmpb $1, %%dl\n\t" > > > + "ja 107f\n\t" > > > + "jb 102f\n\t" > > > + "movzbl (%%rsi), %%ecx\n\t" > > > + "movb %%cl, (%%rdi)\n\t" > > > + "102:\n\t" > > > + "jmp %l[done]\n\t" > > > + "103:\n\t" > > > + /* From 32 to 63. No branch when size =3D=3D 32. */ > > > + "vmovdqu (%%rsi), %%ymm0\n\t" > > > + "vmovdqu -32(%%rsi,%%rdx), %%ymm1\n\t" > > > + "vmovdqu %%ymm0, (%%rdi)\n\t" > > > + "vmovdqu %%ymm1, -32(%%rdi,%%rdx)\n\t" > > > + "vzeroupper\n\t" > > > + "jmp %l[done]\n\t" > > > + /* From 16 to 31. No branch when size =3D=3D 16. */ > > > + "104:\n\t" > > > + "vmovdqu (%%rsi), %%xmm0\n\t" > > > + "vmovdqu -16(%%rsi,%%rdx), %%xmm1\n\t" > > > + "vmovdqu %%xmm0, (%%rdi)\n\t" > > > + "vmovdqu %%xmm1, -16(%%rdi,%%rdx)\n\t" > > > + "jmp %l[done]\n\t" > > > + "105:\n\t" > > > + /* From 8 to 15. No branch when size =3D=3D 8. */ > > > + "movq -8(%%rsi,%%rdx), %%rcx\n\t" > > > + "movq (%%rsi), %%rsi\n\t" > > > + "movq %%rcx, -8(%%rdi,%%rdx)\n\t" > > > + "movq %%rsi, (%%rdi)\n\t" > > > + "jmp %l[done]\n\t" > > > + "106:\n\t" > > > + /* From 4 to 7. No branch when size =3D=3D 4. */ > > > + "movl -4(%%rsi,%%rdx), %%ecx\n\t" > > > + "movl (%%rsi), %%esi\n\t" > > > + "movl %%ecx, -4(%%rdi,%%rdx)\n\t" > > > + "movl %%esi, (%%rdi)\n\t" > > > + "jmp %l[done]\n\t" > > > + "107:\n\t" > > > + /* From 2 to 3. No branch when size =3D=3D 2. */ > > > + "movzwl -2(%%rsi,%%rdx), %%ecx\n\t" > > > + "movzwl (%%rsi), %%esi\n\t" > > > + "movw %%cx, -2(%%rdi,%%rdx)\n\t" > > > + "movw %%si, (%%rdi)\n\t" > > > + "jmp %l[done]\n\t" > > > + "108:\n\t" > > > + /* More than 2 * VEC and there may be overlap between destinati= on */ > > > + /* and source. */ > > > + "cmpq $(32 * 8), %%rdx\n\t" > > > + "ja 111f\n\t" > > > + "cmpq $(32 * 4), %%rdx\n\t" > > > + "jb 109f\n\t" > > > + /* Copy from 4 * VEC to 8 * VEC, inclusively. */ > > > + "vmovdqu (%%rsi), %%ymm0\n\t" > > > + "vmovdqu 32(%%rsi), %%ymm1\n\t" > > > + "vmovdqu (32 * 2)(%%rsi), %%ymm2\n\t" > > > + "vmovdqu (32 * 3)(%%rsi), %%ymm3\n\t" > > > + "vmovdqu -32(%%rsi,%%rdx), %%ymm4\n\t" > > > + "vmovdqu -(32 * 2)(%%rsi,%%rdx), %%ymm5\n\t" > > > + "vmovdqu -(32 * 3)(%%rsi,%%rdx), %%ymm6\n\t" > > > + "vmovdqu -(32 * 4)(%%rsi,%%rdx), %%ymm7\n\t" > > > + "vmovdqu %%ymm0, (%%rdi)\n\t" > > > + "vmovdqu %%ymm1, 32(%%rdi)\n\t" > > > + "vmovdqu %%ymm2, (32 * 2)(%%rdi)\n\t" > > > + "vmovdqu %%ymm3, (32 * 3)(%%rdi)\n\t" > > > + "vmovdqu %%ymm4, -32(%%rdi,%%rdx)\n\t" > > > + "vmovdqu %%ymm5, -(32 * 2)(%%rdi,%%rdx)\n\t" > > > + "vmovdqu %%ymm6, -(32 * 3)(%%rdi,%%rdx)\n\t" > > > + "vmovdqu %%ymm7, -(32 * 4)(%%rdi,%%rdx)\n\t" > > > + "vzeroupper\n\t" > > > + "jmp %l[done]\n\t" > > > + "109:\n\t" > > > + /* Copy from 2 * VEC to 4 * VEC. */ > > > + "vmovdqu (%%rsi), %%ymm0\n\t" > > > + "vmovdqu 32(%%rsi), %%ymm1\n\t" > > > + "vmovdqu -32(%%rsi,%%rdx), %%ymm2\n\t" > > > + "vmovdqu -(32 * 2)(%%rsi,%%rdx), %%ymm3\n\t" > > > + "vmovdqu %%ymm0, (%%rdi)\n\t" > > > + "vmovdqu %%ymm1, 32(%%rdi)\n\t" > > > + "vmovdqu %%ymm2, -32(%%rdi,%%rdx)\n\t" > > > + "vmovdqu %%ymm3, -(32 * 2)(%%rdi,%%rdx)\n\t" > > > + "vzeroupper\n\t" > > > + "110:\n\t" > > > + "jmp %l[done]\n\t" > > > + "111:\n\t" > > > + "cmpq %%rsi, %%rdi\n\t" > > > + "ja 113f\n\t" > > > + /* Source =3D=3D destination is less common. */ > > > + "je 110b\n\t" > > > + /* Load the first VEC and last 4 * VEC to > > > + * support overlapping addresses. > > > + */ > > > + "vmovdqu (%%rsi), %%ymm4\n\t" > > > + "vmovdqu -32(%%rsi, %%rdx), %%ymm5\n\t" > > > + "vmovdqu -(32 * 2)(%%rsi, %%rdx), %%ymm6\n\t" > > > + "vmovdqu -(32 * 3)(%%rsi, %%rdx), %%ymm7\n\t" > > > + "vmovdqu -(32 * 4)(%%rsi, %%rdx), %%ymm8\n\t" > > > + /* Save start and stop of the destination buffer. */ > > > + "movq %%rdi, %%r11\n\t" > > > + "leaq -32(%%rdi, %%rdx), %%rcx\n\t" > > > + /* Align destination for aligned stores in the loop. Compute *= / > > > + /* how much destination is misaligned. */ > > > + "movq %%rdi, %%r8\n\t" > > > + "andq $(32 - 1), %%r8\n\t" > > > + /* Get the negative of offset for alignment. */ > > > + "subq $32, %%r8\n\t" > > > + /* Adjust source. */ > > > + "subq %%r8, %%rsi\n\t" > > > + /* Adjust destination which should be aligned now. */ > > > + "subq %%r8, %%rdi\n\t" > > > + /* Adjust length. */ > > > + "addq %%r8, %%rdx\n\t" > > > + /* Check non-temporal store threshold. */ > > > + "cmpq $(1024*1024), %%rdx\n\t" > > > + "ja 115f\n\t" > > > + "112:\n\t" > > > + /* Copy 4 * VEC a time forward. */ > > > + "vmovdqu (%%rsi), %%ymm0\n\t" > > > + "vmovdqu 32(%%rsi), %%ymm1\n\t" > > > + "vmovdqu (32 * 2)(%%rsi), %%ymm2\n\t" > > > + "vmovdqu (32 * 3)(%%rsi), %%ymm3\n\t" > > > + "addq $(32 * 4), %%rsi\n\t" > > > + "subq $(32 * 4), %%rdx\n\t" > > > + "vmovdqa %%ymm0, (%%rdi)\n\t" > > > + "vmovdqa %%ymm1, 32(%%rdi)\n\t" > > > + "vmovdqa %%ymm2, (32 * 2)(%%rdi)\n\t" > > > + "vmovdqa %%ymm3, (32 * 3)(%%rdi)\n\t" > > > + "addq $(32 * 4), %%rdi\n\t" > > > + "cmpq $(32 * 4), %%rdx\n\t" > > > + "ja 112b\n\t" > > > + /* Store the last 4 * VEC. */ > > > + "vmovdqu %%ymm5, (%%rcx)\n\t" > > > + "vmovdqu %%ymm6, -32(%%rcx)\n\t" > > > + "vmovdqu %%ymm7, -(32 * 2)(%%rcx)\n\t" > > > + "vmovdqu %%ymm8, -(32 * 3)(%%rcx)\n\t" > > > + /* Store the first VEC. */ > > > + "vmovdqu %%ymm4, (%%r11)\n\t" > > > + "vzeroupper\n\t" > > > + "jmp %l[done]\n\t" > > > + "113:\n\t" > > > + /* Load the first 4*VEC and last VEC to support overlapping add= resses.*/ > > > + "vmovdqu (%%rsi), %%ymm4\n\t" > > > + "vmovdqu 32(%%rsi), %%ymm5\n\t" > > > + "vmovdqu (32 * 2)(%%rsi), %%ymm6\n\t" > > > + "vmovdqu (32 * 3)(%%rsi), %%ymm7\n\t" > > > + "vmovdqu -32(%%rsi,%%rdx), %%ymm8\n\t" > > > + /* Save stop of the destination buffer. */ > > > + "leaq -32(%%rdi, %%rdx), %%r11\n\t" > > > + /* Align destination end for aligned stores in the loop. Compu= te */ > > > + /* how much destination end is misaligned. */ > > > + "leaq -32(%%rsi, %%rdx), %%rcx\n\t" > > > + "movq %%r11, %%r9\n\t" > > > + "movq %%r11, %%r8\n\t" > > > + "andq $(32 - 1), %%r8\n\t" > > > + /* Adjust source. */ > > > + "subq %%r8, %%rcx\n\t" > > > + /* Adjust the end of destination which should be aligned now. = */ > > > + "subq %%r8, %%r9\n\t" > > > + /* Adjust length. */ > > > + "subq %%r8, %%rdx\n\t" > > > + /* Check non-temporal store threshold. */ > > > + "cmpq $(1024*1024), %%rdx\n\t" > > > + "ja 117f\n\t" > > > + "114:\n\t" > > > + /* Copy 4 * VEC a time backward. */ > > > + "vmovdqu (%%rcx), %%ymm0\n\t" > > > + "vmovdqu -32(%%rcx), %%ymm1\n\t" > > > + "vmovdqu -(32 * 2)(%%rcx), %%ymm2\n\t" > > > + "vmovdqu -(32 * 3)(%%rcx), %%ymm3\n\t" > > > + "subq $(32 * 4), %%rcx\n\t" > > > + "subq $(32 * 4), %%rdx\n\t" > > > + "vmovdqa %%ymm0, (%%r9)\n\t" > > > + "vmovdqa %%ymm1, -32(%%r9)\n\t" > > > + "vmovdqa %%ymm2, -(32 * 2)(%%r9)\n\t" > > > + "vmovdqa %%ymm3, -(32 * 3)(%%r9)\n\t" > > > + "subq $(32 * 4), %%r9\n\t" > > > + "cmpq $(32 * 4), %%rdx\n\t" > > > + "ja 114b\n\t" > > > + /* Store the first 4 * VEC. */ > > > + "vmovdqu %%ymm4, (%%rdi)\n\t" > > > + "vmovdqu %%ymm5, 32(%%rdi)\n\t" > > > + "vmovdqu %%ymm6, (32 * 2)(%%rdi)\n\t" > > > + "vmovdqu %%ymm7, (32 * 3)(%%rdi)\n\t" > > > + /* Store the last VEC. */ > > > + "vmovdqu %%ymm8, (%%r11)\n\t" > > > + "vzeroupper\n\t" > > > + "jmp %l[done]\n\t" > > > + > > > + "115:\n\t" > > > + /* Don't use non-temporal store if there is overlap between */ > > > + /* destination and source since destination may be in cache */ > > > + /* when source is loaded. */ > > > + "leaq (%%rdi, %%rdx), %%r10\n\t" > > > + "cmpq %%r10, %%rsi\n\t" > > > + "jb 112b\n\t" > > > + "116:\n\t" > > > + /* Copy 4 * VEC a time forward with non-temporal stores. */ > > > + "prefetcht0 (32*4*2)(%%rsi)\n\t" > > > + "prefetcht0 (32*4*2 + 64)(%%rsi)\n\t" > > > + "prefetcht0 (32*4*3)(%%rsi)\n\t" > > > + "prefetcht0 (32*4*3 + 64)(%%rsi)\n\t" > > > + "vmovdqu (%%rsi), %%ymm0\n\t" > > > + "vmovdqu 32(%%rsi), %%ymm1\n\t" > > > + "vmovdqu (32 * 2)(%%rsi), %%ymm2\n\t" > > > + "vmovdqu (32 * 3)(%%rsi), %%ymm3\n\t" > > > + "addq $(32*4), %%rsi\n\t" > > > + "subq $(32*4), %%rdx\n\t" > > > + "vmovntdq %%ymm0, (%%rdi)\n\t" > > > + "vmovntdq %%ymm1, 32(%%rdi)\n\t" > > > + "vmovntdq %%ymm2, (32 * 2)(%%rdi)\n\t" > > > + "vmovntdq %%ymm3, (32 * 3)(%%rdi)\n\t" > > > + "addq $(32*4), %%rdi\n\t" > > > + "cmpq $(32*4), %%rdx\n\t" > > > + "ja 116b\n\t" > > > + "sfence\n\t" > > > + /* Store the last 4 * VEC. */ > > > + "vmovdqu %%ymm5, (%%rcx)\n\t" > > > + "vmovdqu %%ymm6, -32(%%rcx)\n\t" > > > + "vmovdqu %%ymm7, -(32 * 2)(%%rcx)\n\t" > > > + "vmovdqu %%ymm8, -(32 * 3)(%%rcx)\n\t" > > > + /* Store the first VEC. */ > > > + "vmovdqu %%ymm4, (%%r11)\n\t" > > > + "vzeroupper\n\t" > > > + "jmp %l[done]\n\t" > > > + "117:\n\t" > > > + /* Don't use non-temporal store if there is overlap between */ > > > + /* destination and source since destination may be in cache */ > > > + /* when source is loaded. */ > > > + "leaq (%%rcx, %%rdx), %%r10\n\t" > > > + "cmpq %%r10, %%r9\n\t" > > > + "jb 114b\n\t" > > > + "118:\n\t" > > > + /* Copy 4 * VEC a time backward with non-temporal stores. */ > > > + "prefetcht0 (-32 * 4 * 2)(%%rcx)\n\t" > > > + "prefetcht0 (-32 * 4 * 2 - 64)(%%rcx)\n\t" > > > + "prefetcht0 (-32 * 4 * 3)(%%rcx)\n\t" > > > + "prefetcht0 (-32 * 4 * 3 - 64)(%%rcx)\n\t" > > > + "vmovdqu (%%rcx), %%ymm0\n\t" > > > + "vmovdqu -32(%%rcx), %%ymm1\n\t" > > > + "vmovdqu -(32 * 2)(%%rcx), %%ymm2\n\t" > > > + "vmovdqu -(32 * 3)(%%rcx), %%ymm3\n\t" > > > + "subq $(32*4), %%rcx\n\t" > > > + "subq $(32*4), %%rdx\n\t" > > > + "vmovntdq %%ymm0, (%%r9)\n\t" > > > + "vmovntdq %%ymm1, -32(%%r9)\n\t" > > > + "vmovntdq %%ymm2, -(32 * 2)(%%r9)\n\t" > > > + "vmovntdq %%ymm3, -(32 * 3)(%%r9)\n\t" > > > + "subq $(32 * 4), %%r9\n\t" > > > + "cmpq $(32 * 4), %%rdx\n\t" > > > + "ja 118b\n\t" > > > + "sfence\n\t" > > > + /* Store the first 4 * VEC. */ > > > + "vmovdqu %%ymm4, (%%rdi)\n\t" > > > + "vmovdqu %%ymm5, 32(%%rdi)\n\t" > > > + "vmovdqu %%ymm6, (32 * 2)(%%rdi)\n\t" > > > + "vmovdqu %%ymm7, (32 * 3)(%%rdi)\n\t" > > > + /* Store the last VEC. */ > > > + "vmovdqu %%ymm8, (%%r11)\n\t" > > > + "vzeroupper\n\t" > > > + "jmp %l[done]" > > > + : > > > + : "r"(src), "r"(dst), "r"(len) > > > + : "rax", "rcx", "rdx", "rdi", "rsi", "r8", "r9", "r10", "r11", = "r12", "ymm0", > > > + "ymm1", "ymm2", "ymm3", "ymm4", "ymm5", "ymm6", "ymm7", "ymm8",= "memory" > > > + : done > > > + ); > > > +done: > > > + return dst; > > > +} > > > > > >