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 1rqEzj-00BLBK-6f for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 16:22:19 +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 1rqEzh-002nTs-Tn for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 16:22:17 +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 1rqEzh-002nTi-Ke for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 16:22:17 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rqEzd-0074t5-AN for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 16:22:16 +0000 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-7d0486cf91aso94209039f.1 for ; Fri, 29 Mar 2024 09:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711729334; x=1712334134; 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=CHzD6LnwSgHYqlBLfvEH/1Y44PnWRmwrAddzkqY9DQM=; b=FYbLevSl3FCJi2SWs9PBQWtx4AqAQhjVPJ66dcZTSndLMorGU4QlYiLR8k92pzb00+ 0mRG/XAe0tPmUa8m4onEWkDpHD0yZJ+dw4t6oIPTCvlSVP3xMFMYOLIKxtuClvbsVpzc acUZcsex+MFJJ7979BSZazql7PejefwYlqiZFN3M7R486j+nMZSxpqPDWtCk/E4ljaWX qL87Y99jV7u4vy1WPdXrhrdmVQViKTm4obZL00dvhnS39YiCwKycTg6acgeEmDWS3tqL Jf6c1Q1eGRz2xr6mSgZbxJ2OlJusn+iMw6/6s+8jzB+MSY5z+hNomdyagbAxD+O63JnF FXKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711729334; x=1712334134; 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=CHzD6LnwSgHYqlBLfvEH/1Y44PnWRmwrAddzkqY9DQM=; b=vRI10itW1AfYXen/TkwvjmuiWZ+1yDkLY0raPQYe14RvcR3Bqa5PB73kgF4OKGolQj BMBAqMDb5RXL9D3rqkShA3GlYkoSjsBQTmX/jeO8yVbO8w/lyk7lmVuMj/wXUTnXSK9l hiA2xOcl34qL/vt2o1RZcF9zQc0r9Tnx4iWpRh3uoaH+oL28O7Fs1LcBlhDP79GnYTnl Dyo7Wo1yGYif2UePBkAddTmA2S77vymmGXIWMXRiQN8qZDgX7ogIuZ7x+d9qPQLM7EV8 j8HRIgI1SvVCyw02Z/JCgNs1eKDjaG8Z1lGvSrKnkAdWU8VQTyS50mmAWGeVH1IzDJ5r FOtQ== X-Forwarded-Encrypted: i=1; AJvYcCX8cipONCSQb684AX/HjpVY7pGZLxHvcZ88H7r46aq2JH1EovCqkKlSlfksRVL5NaGuYSOGUVy0YYq9V2Frj0zG3s80sOvfRT8+xbvRwktyOQIe X-Gm-Message-State: AOJu0YwFeV1kYV9zXQKbmjiA0FibGrFBG53LUyrIFf2v5OakXhVgctRh vF38hmjr7inlXR88aoH77N59+Gi+e7krqGTQFJUWl5eVG5p0Aafm X-Google-Smtp-Source: AGHT+IE6+j2drHWFqh3Be0rH7+4VOvcJJR8zMO4DEakdWTFnl+DihiVcyq1L2CrZ5TkglVKFQs4C8g== X-Received: by 2002:a05:6e02:1a09:b0:368:a724:f74e with SMTP id s9-20020a056e021a0900b00368a724f74emr2657578ild.27.1711729333918; Fri, 29 Mar 2024 09:22: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 i16-20020a056e020ed000b003687950b384sm1164472ilk.18.2024.03.29.09.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 09:22:13 -0700 (PDT) Date: Fri, 29 Mar 2024 11:22:11 -0500 From: Nathan Bossart To: "Amonson, Paul D" 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 Message-ID: <20240329162211.GB1106154@nathanxps13> References: <2490633.1711379522@sss.pgh.pa.us> <20240325200551.GB2924132@nathanxps13> <20240327220010.GA231058@nathanxps13> <20240328213854.GA916732@nathanxps13> <20240329155940.GC1046039@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240329155940.GC1046039@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 29, 2024 at 10:59:40AM -0500, Nathan Bossart wrote: > It might be nice if we conditionally built pg_popcount_avx512.o in autoconf > builds, too, but AFAICT we still need to wrap most of that code with > macros, so I'm not sure it's worth the trouble. I'll take another look at > this... If we assumed that TRY_POPCNT_FAST would be set and either HAVE__GET_CPUID_COUNT or HAVE__CPUIDEX would be set whenever USE_AVX512_POPCNT_WITH_RUNTIME_CHECK is set, we could probably remove the surrounding macros and just compile pg_popcount_avx512.c conditionally based on USE_AVX512_POPCNT_WITH_RUNTIME_CHECK. However, the surrounding code seems to be pretty cautious about these assumptions (e.g., the CPUID macros are checked before setting TRY_POPCNT_FAST), so this would stray from the nearby precedent a bit. A counterexample is the CRC32C code. AFAICT we assume the presence of CPUID in that code (and #error otherwise). I imagine its probably safe to assume the compiler understands CPUID if it understands AVX512 intrinsics, but that is still mostly a guess. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com