Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rpxqH-009jNy-NK for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Mar 2024 22:03:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rpxqG-0057Fh-PA for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Mar 2024 22:03:24 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rpxqF-0057FY-QX for pgsql-hackers@lists.postgresql.org; Thu, 28 Mar 2024 22:03:24 +0000 Received: from mgamail.intel.com ([198.175.65.9]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rpxqA-006wzM-IJ for pgsql-hackers@lists.postgresql.org; Thu, 28 Mar 2024 22:03:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711663400; x=1743199400; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=xI7k+Ol6G1jlAGAehJddi+yF/a29fJXyaSEDi3fIFc4=; b=DoH5Cq4adSdYjSS3y6GV5F+oNZKLE/MB9gDk4DSj1myq8eioPrC/iyRD bZ4OPP9MX9Tb26FgXjO50Fcr8HpzJbwSnRjJ7WETVtdDko/QkBok2dMoa 0O9IjpX7gTr1wfk7S5PXq59G4D54AKdxfjHxoNTefL+ZD7BNnHKlPm1lH 9CF0UTqGS9acjZlERMbJno7scqULHee6EEVPb3CYIYR4ICrr2E4XzofAt l0yLPaX/Z73n3BP0HGfa+nmw5r7aFywFEwGMhKnZDtd+JG2aGqMpdHvdC JJ1Y/0+y1tqZwkC9M8s1fCshdQTV7LgoglzCxPhvWHhPRLZ02D4uwWVVo Q==; X-CSE-ConnectionGUID: xoNgSIN6R/ylU9eV1RyH9A== X-CSE-MsgGUID: Or1nGAorS52cZTEkh1iP+A== X-IronPort-AV: E=McAfee;i="6600,9927,11027"; a="29330710" X-IronPort-AV: E=Sophos;i="6.07,162,1708416000"; d="scan'208";a="29330710" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2024 15:03:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,162,1708416000"; d="scan'208";a="47754560" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 28 Mar 2024 15:03:09 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 28 Mar 2024 15:03:09 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 28 Mar 2024 15:03:08 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Thu, 28 Mar 2024 15:03:08 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 28 Mar 2024 15:03:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e30sx2pJND7bsLLValvsuOE0pYJXuL6vVm0CsIYxthLZPMJlNL58pE3EObNhfPrBuRD2Z8EvF+TpOABiSimM+ZxjqP7zHgcYJ008tNUQtLhwo+O5i+9O1B1txBZmC79zVO43uWdACFHB7x4dmKKGOXD+ZciEMdUaPMvGr+xgnSUAB8XCGbI9CF4TZP+/C0TeiGFLUEviv54OkAf19xjX5u9q7C7mOvLmm35iYrcGV6BEE2ZArYFrcEALm96vKg/wi2hj2AYg2IVoj2zQd/fo0TA/74aVhJqzmg3k4A4lUOCT73Ej6KAbIaQYaWKBgFpAGMh5GZ/UbSo4EyfASuJA4w== 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=nhedO9+oXFbTJcVeo6y4I3OaJzL+wmQCyH5p7sLSUbw=; b=Q2kHOG0tOyHnGblMgkoPdVSKIYU/NvmnM5DnRIJ2BBt+UX+Q6aA4wpu/zJ3eINe45Aq1pKMHtRWtAA6CHTv7+0yLUQl0zcPWFKYSlnEhw2/EI1PGKddjWkiWc0Xt5S6TlSFcv0d1CFnvCWvTxyKXmgmNGRzqLn6dw0L76jzXwiU9PLPhlzyqlOsS1c0LP/IwNyYmXUdJ8zO1a+jcYrh+gBRszWYZ9VcVorVmgIDDUvR9G9pfXftlRc5dKldkOp0ouDWrl2RC/jgX2Oywd1BT2DJ3u7TnvHWTiSYtb6PJ53MEnbe28Dk0Fzm/Pk4Jsz7yt2yzkFmdLwlh/GJNMD38eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from BL1PR11MB5304.namprd11.prod.outlook.com (2603:10b6:208:316::20) by MW5PR11MB5884.namprd11.prod.outlook.com (2603:10b6:303:1a0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Thu, 28 Mar 2024 22:03:05 +0000 Received: from BL1PR11MB5304.namprd11.prod.outlook.com ([fe80::c3d7:736f:7cf2:4d0f]) by BL1PR11MB5304.namprd11.prod.outlook.com ([fe80::c3d7:736f:7cf2:4d0f%4]) with mapi id 15.20.7409.031; Thu, 28 Mar 2024 22:03:04 +0000 From: "Amonson, Paul D" To: Nathan Bossart CC: Tom Lane , David Rowley , "Andres Freund" , Alvaro Herrera , "Shankaran, Akash" , Noah Misch , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: RE: Popcount optimization using AVX512 Thread-Topic: Popcount optimization using AVX512 Thread-Index: AdoNliAXaie8RHrzTICrAiLVKKiYCgAsQKyAALaJTAAAAQ7nAAAAxSWAAAGNHgAAA/mZgAAeFdGAAZKQbBAAAw6egA3NuLcAAAvVM4ACbQuxsAAhlXkAAHPWMbAAAkOrAACYCUjgAAMc3wABvefW4AD8TV6wADf+AoAAmWkVgACOpocAAAl+RwAAJXNxYAAA1VoAAABadxAAZi2hAAAIeekAAMiJepAACPYvAAAbpMKQAJeTLYAAcNGUAAAm2oYAAAFGgCAAAIPdAAACb8MAAAdpgwAAADR0AAAAsQcAAAAMEoAAAWCPgAAC3eIAACrnWQAABeBEkAA1zxYAACb9mpAAwL24cAAATJYAAAAxGQAABx2FwABrjaAVAADz8kAAMJJ6AAAAVz0w Date: Thu, 28 Mar 2024 22:03:04 +0000 Message-ID: References: <2490633.1711379522@sss.pgh.pa.us> <20240325200551.GB2924132@nathanxps13> <20240327220010.GA231058@nathanxps13> <20240328213854.GA916732@nathanxps13> In-Reply-To: <20240328213854.GA916732@nathanxps13> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BL1PR11MB5304:EE_|MW5PR11MB5884:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: t87saBfEMzbp4b7DlMH+svwaokgttNF5kkFXvS/f6250aAtx3et//Irihml6FWx3ciz8oLmsjpcXG2svKnTKeM7evpLHbSP+GKG3bdNe0U4Pe+qedbrPhlLgOXZjh6HJgywPTztA4IOPMgAhwSg+kr2wdCQluYqhoQudHUIDE4SyAO+bS9kKRoDQ8B6FZaRtO5C1DfM2tn7ZPkJlpCFFFEUuRAiu/FQHOsaXbAY8QW5z4ByPCIt+/VCNwdIL+en3AvRk/RuPm4qaHWse6BflbSqUvvbMg3qkrxKD09pPoOwJztb+nfm3RJekAFKmcWR5HMvsUmnSCLKJttQiP+dHdzXAVeDwfsvDfbefp2agCi4Pp86kcw+SHVWIeaI7lFm+RzbTTX/+8BzMxCohjb0JSOlb06ul3vWLDWHmtDdT/CHX6kfnaxlAUwIBjkOPRyqpYo+Kxbr6nAwtMaSI49Gdz2H1qm4rMjvO6nhuKhFdOeB+z5vrK1kPlTo4b9SdKVkA5SuSbfkOrZBNISaCMIEcIbstHg5bjO/wO90kD+RJmkwOuYKTMmSVZ3KWmhCViQQt41yWznvxoWxUdyEKBJzc0xRkO98OurcHSMKYsKt/qFbF3hE7+OGZt+/UeQr27Q7akoQi658BqE71ppOK/X2UTY9lOVQtrTovIXVsmrglDEY= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR11MB5304.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?IIftBOSwax8rJytsGutbs3YfwAxd/z4yDD/KKTFRJtwbeGPvHYcOL/Qzi/Jc?= =?us-ascii?Q?ebyZx6SUVevEjYfFE0g1351ZWP0r73lEpj76s70bdldHBoZ8aJu3D6HD9m6J?= =?us-ascii?Q?vR5RfQGew0U58lr6TalOnrSww92F1MsVHVCEjRHqP345PM32NmmHzu3Ab8D8?= =?us-ascii?Q?P7JFw2EQgS3BFxCP+QhNGuwGMhhPC+iRltcnBFAGxni8dqE1kSlP/CFFJe08?= =?us-ascii?Q?V0T/cxcqN4dqpjGWPWwR3O0bFnh25l6C03TVDfSgFF2Ix+5PnkkkXz6V0M+B?= =?us-ascii?Q?qfoqK8vNV/NzoIgLTNfBb57oI9ATkLG6cZ3fjz94Lv6zoO9vfao/8N7GUsnB?= =?us-ascii?Q?OunMW7gEibbaupEY9sBzetSqa6vmGdcWEhvyANHAuDSfiVRrLzN+TbMoZwP8?= =?us-ascii?Q?CnP3L38yaUYQuX2nwyDAvF3jjlubs6doVjiX9nHAxFh+iFPlg8xE+l4/MzB+?= =?us-ascii?Q?nfrdwA1MiA08aaaB9bfWKABmDFuFxBJh9Ht2eIqKktk04/jEa29kXVLSe4zL?= =?us-ascii?Q?vdc9JZF/7SqeVpwURR+apro+5pWlKC6CN1uB36vVZqq0WA+H/tRjIeZqWJ4+?= =?us-ascii?Q?Dlprw3eAtSITf7YKGgRVIOaE6Y6nknv1mLkoSv+S3MVNepwAJAszRSOOKheP?= =?us-ascii?Q?fvWbC/BZGtr3mTcjoRVI9MOMHbgvkMuIcMdEG1suuntG7FDfgtuy9FtMIVN3?= =?us-ascii?Q?KMiWN51/FDro8x/m5KH5chvwB5OLjZ86ELzzXQUxX6zYZ8M2h31FKp0odva5?= =?us-ascii?Q?AhfujCSTRTMffUDA5XrbYWrooAfqn/v25URMk4V1V7WHlhB/e7C/W3gQsoLj?= =?us-ascii?Q?cT1VzRa7jUlCKJrAwbxnIg9mUsPmd+e3ss49pfCYO1k3kJCKMnNSuh2PIC3w?= =?us-ascii?Q?+pbyttR2GbArFSdsdRvfLppbDlIfg9DTXcTENZriBymQHGLTycYJ7pbL1afX?= =?us-ascii?Q?M8xKjtKfArnw8HebpLMQ1QAv3sgIETLrDlRNsQ2FevoxuE/ZwgL8vcOGG1aZ?= =?us-ascii?Q?VVWmirINOTEUOgiFRASKtCkk4JhjnHN0euNkThhgMOogeWCGyamsUYFZuCcb?= =?us-ascii?Q?dl+mE+fZ+Kmbj0rkSE4FKRgC7NsQaBN0y3UtVx6BUTGpTcBSRlQ3ngLs29nq?= =?us-ascii?Q?AV1WeeqZexQttYUlxp0zIqrNm2a257HE0g6YBVYZIMvo7JDfbwVHzl0hyeLE?= =?us-ascii?Q?mbixWTMFkW6U07rEMS0UFKk91N9eru1KBqwdkkx2+tJI+s0p+RhkNCvssGID?= =?us-ascii?Q?4s1xq03pW6IrUjOtug3YbybCCdt8bpJVpCV11KLMkIqKPFqS4GA37uKdg4qw?= =?us-ascii?Q?Pp84sLx6bAwlOmTNeyTrmwMoHgr+EYhh361hAAtkU48lNF/7WM5E8AtYXkOI?= =?us-ascii?Q?g74Y79hwlJByRE+fo9c9TPKGjQDTvRql7lq2Rwixrf/iEShnf8IqYFIbeQnv?= =?us-ascii?Q?3pM9vwpx6UqpnthpDJQCJMZKfe5zjAgGSUkhM1d7NQWW0OQIML+MBm9nDxRZ?= =?us-ascii?Q?cHiaEJKJcYWX4TaKeN01kdFTPzkT8smeqitJTymC+yPn/IfFRxKthvyQy4FC?= =?us-ascii?Q?C1hd88f0+65fKAa6WGD1zsjTUYheu/MmXHhCAP+m?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BL1PR11MB5304.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82f97b5a-baef-45be-b7d9-08dc4f72d7f5 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Mar 2024 22:03:04.7778 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ikwUstq4hRPf+H+PSy4Nf2vWK2cxnXL0A8+q+YNCWXucvl+UAettxoIJO4Xp0JuTPp4qeU6+S6a2OyxyK81lp27alFN5RqUlLoItgn4ZwWg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR11MB5884 X-OriginatorOrg: intel.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > -----Original Message----- > From: Nathan Bossart > Sent: Thursday, March 28, 2024 2:39 PM > To: Amonson, Paul D >=20 > * The latest patch set from Paul Amonson appeared to support MSVC in the > meson build, but not the autoconf one. I don't have much expertise her= e, > so the v14 patch doesn't have any autoconf/meson support for MSVC, whic= h > I thought might be okay for now. IIUC we assume that 64-bit/MSVC build= s > can always compile the x86_64 popcount code, but I don't know whether > that's safe for AVX512. I also do not know how to integrate MSVC+Autoconf, the CI uses MSVC+Meson+N= inja so I stuck with that. =20 > * I think we need to verify there isn't a huge performance regression for > smaller arrays. IIUC those will still require an AVX512 instruction or > two as well as a function call, which might add some noticeable overhea= d. Not considering your changes, I had already tested small buffers. At less t= han 512 bytes there was no measurable regression (there was one extra condi= tion check) and for 512+ bytes it moved from no regression to some gains be= tween 512 and 4096 bytes. Assuming you introduced no extra function calls, = it should be the same. > I forgot to mention that I also want to understand whether we can actuall= y assume availability of XGETBV when CPUID says we support AVX512: You cannot assume as there are edge cases where AVX-512 was found on system= one during compile but it's not actually available in a kernel on a second= system at runtime despite the CPU actually having the hardware feature. I will review the new patch to see if there are anything that jumps out at = me. Thanks, Paul