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 1rkTUZ-00Cyyv-Qm for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Mar 2024 18:38:20 +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 1rkTUY-00AVXs-5I for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Mar 2024 18:38:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rkTUX-00AVVR-Rk for pgsql-hackers@lists.postgresql.org; Wed, 13 Mar 2024 18:38:18 +0000 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rkTUV-004Lrr-7R for pgsql-hackers@lists.postgresql.org; Wed, 13 Mar 2024 18:38:17 +0000 Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-3662e41370fso974025ab.2 for ; Wed, 13 Mar 2024 11:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710355094; x=1710959894; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=s+HQNHocTj8XlSTtNCU2i1wol74BKR9a982eQKX9sSg=; b=JeU5pyx8SdnU9WAHReA3Fe1tP2JN0bLFQyEKzw8zHrPAzoW6nsbf/PiOUc4f5vqA3i Vg9umPXCJOBCs3PV3KUjmIzqFfgwP9ktn6JE5XgfiGuXjyn1vkHQqi5P6PiRefVPIIFn PWgsERlTc2AyGMjGPCRByHzzWWygk/jyJU9Uta6nNjtxwDU02FX68BckRSs5yWRFsDFt EC0Nj/Dl/9ZqgDN0N+y5XvtgGwFVFQ7nkem95zqZmYJLH7k30z1ZDZD/k9hg/DjMqvZz JcVinC8iXnBsOfX0Q8zNWIUn71F63cOz9R2v+VpwlbMZanptI0Jb4hinwtEUgndsyb9y hCqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710355094; x=1710959894; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s+HQNHocTj8XlSTtNCU2i1wol74BKR9a982eQKX9sSg=; b=Qf8c3ohToP4yJkASuqVAE2BG7URtSim7JcsPk4Nwtamo1LYHKDRjwT/1bk68ZwXJYX 9a3LSe4bsPCFgr0Pp3paf3GMq2ENwk8GYc6huMraArouEYgbtqxgL8WQ4F9Yh9hDVg1o oAlS9Q6L0AhXP/eDyF8HzYwsgE2Qc+I33Di4IhTsusKPRwpTvTP6tVibe4hdT+MrDCVj 2i2dtroli657WJ5uX0FoFaumqfJYej23IwvgauYRLI+IqRrtukalEeFPG0JMCh5SyWTL AIsUGVLNpvrsps+isjARp09JVJpcnBxIM7VoXV+j1vRFZqQiDqVYa6+53L7NR/exSDn4 e3jw== X-Forwarded-Encrypted: i=1; AJvYcCULLi5Oad9k9+ZWm/rkwVaKWBCZcbupg3uH3hjGWNKCnfesXHv7QVNxxpOA6f/jEOoOhwisZAvF34n1lfN7alhSSFXOscg7gai7I/wSmLQVvmeH X-Gm-Message-State: AOJu0YwzfuQ66amMUuR5YRO8HTGKrAXdnj9qP3a3y6BaumFILzR3nENQ hfF7tESDAzXJjhDottcqBNIe6xC7VKO+7QRH1EcjTDL7KkVJkZFH X-Google-Smtp-Source: AGHT+IG00xp/SdiIRUlq6gJ3n3Dq5XrkYygA2yBkLtzdxRHyBGFQUgD7mr2MKh6sbD00Ae3BzKDU2Q== X-Received: by 2002:a05:6e02:1a09:b0:365:1749:cae0 with SMTP id s9-20020a056e021a0900b003651749cae0mr1043428ild.7.1710355093772; Wed, 13 Mar 2024 11:38:13 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id y13-20020a02c00d000000b00474f03236fasm3046784jai.85.2024.03.13.11.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 11:38:13 -0700 (PDT) Date: Wed, 13 Mar 2024 13:38:11 -0500 From: Nathan Bossart To: "Amonson, Paul D" Cc: Andres Freund , Alvaro Herrera , "Shankaran, Akash" , Noah Misch , Tom Lane , Matthias van de Meent , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: <20240313183811.GA2563626@nathanxps13> References: <20240304222118.GB3367383@nathanxps13> <20240305163730.GA3479896@nathanxps13> <20240307173318.GA455851@nathanxps13> <20240307213600.GA563369@nathanxps13> <20240312013436.GA1787866@nathanxps13> <20240313163904.GA2560056@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 13, 2024 at 05:52:14PM +0000, Amonson, Paul D wrote: >> I think we want these to be architecture-specific, i.e., only built for >> x86_64 if the compiler knows how to use the relevant instructions. There is a >> good chance that we'll want to add similar support for other systems. >> The CRC32C files are probably a good reference point for how to do this. > > I will look at this for the 'pg_popcnt_x86_64_accel.c' file but the > 'pg_popcnt_choose.c' file is intended to be for any platform that may > need accelerators including a possible future ARM accelerator. I worry that using the same file for *_choose.c for all architectures would become rather #ifdef heavy. Since we are already separating out this code into new files, IMO we might as well try to avoid too many #ifdefs, too. But this is admittedly less important right now because there's almost no chance of any new architecture support here for v17. >> +#ifdef TRY_POPCNT_FAST >> >> IIUC this macro can be set if either 1) the popcntq test in the autoconf/meson >> scripts passes or 2) we're building with MSVC on x86_64. I wonder if it would >> be better to move the MSVC/x86_64 check to the autoconf/meson scripts so >> that we could avoid surrounding large portions of the popcount code with this >> macro. This might even be a necessary step towards building these files in an >> architecture-specific fashion. > > I see the point here; however, this will take some time to get right > especially since I don't have a Windows box to do compiles on. Should I > attempt to do this in this patch? This might also be less important given the absence of any imminent new architecture support in this area. I'm okay with it, given we are just maintaining the status quo. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com