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 1rKiu7-004Bli-Ef for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jan 2024 17:50:15 +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 1rKiu5-000KuR-UO for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jan 2024 17:50:13 +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 1rKiu5-000Ktp-Kf for pgsql-hackers@lists.postgresql.org; Tue, 02 Jan 2024 17:50:13 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rKity-00DPFJ-T7 for pgsql-hackers@postgresql.org; Tue, 02 Jan 2024 17:50:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 402Ho4Mr4105102; Tue, 2 Jan 2024 12:50:04 -0500 From: Tom Lane To: Nathan Bossart cc: John Naylor , Ants Aasma , pgsql-hackers@postgresql.org Subject: Re: add AVX2 support to simd.h In-reply-to: <20240102161123.GA955987@nathanxps13> References: <20231129171526.GA857928@nathanxps13> <20240102161123.GA955987@nathanxps13> Comments: In-reply-to Nathan Bossart message dated "Tue, 02 Jan 2024 10:11:23 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4105100.1704217804.1@sss.pgh.pa.us> Date: Tue, 02 Jan 2024 12:50:04 -0500 Message-ID: <4105101.1704217804@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Nathan Bossart writes: > I'm tempted to propose that we move forward with this patch as-is after > adding a buildfarm machine that compiles with -mavx2 or -march=x86-64-v3. > There is likely still follow-up work to make these improvements more > accessible, but I'm not sure that is a strict prerequisite here. The patch needs better comments (as in, more than "none whatsoever"). It doesn't need to be much though, perhaps like +#if defined(__AVX2__) + +/* + * When compiled with -mavx2 or allied options, we prefer AVX2 instructions. + */ +#include +#define USE_AVX2 +typedef __m256i Vector8; +typedef __m256i Vector32; Also, do you really want to structure the header so that USE_SSE2 doesn't get defined? In that case you are committing to provide an AVX2 replacement every single place that there's USE_SSE2, which doesn't seem like a great thing to require. OTOH, maybe there's no choice given than we need a different definition for Vector8 and Vector32? regards, tom lane