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 1t99Az-0082Ps-8S for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Nov 2024 20:32: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 1t99Av-0029Le-4B for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Nov 2024 20:32:17 +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 1t99Au-0029LW-Rx for pgsql-hackers@lists.postgresql.org; Thu, 07 Nov 2024 20:32:17 +0000 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t99Ar-000jTL-BV for pgsql-hackers@lists.postgresql.org; Thu, 07 Nov 2024 20:32:16 +0000 Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-83aba237c03so56756439f.3 for ; Thu, 07 Nov 2024 12:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731011532; x=1731616332; 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=e2Y+Zk3C3UMW+bIUsx4O41a2LQIXopEsB2wefkkO77o=; b=Hw4AOOCPGI+2+6esrjEZ2yy8+7Q+4kWNXKYWLLu7M1/uRpOpEeo1wYaq93av56M21p aF1GXwVS8VPu7tzigji75r840nMg/srgq9AVHAzEEdnuzCJ9cC0VW8QfgtkjYRpwgHDU N+1BHlwFk6IF604SFzz135f3jENJdUfPlmAJ/irGvumLez6lHC3ZMsKaEdDaaW1QKmbf YkknpfcyXcEDwuNOnDpFusgi3SJQrEHZZF6glgVpPESmIl7BZ5FbrFz5VZY8WGyPAUfr L29ierrr7fqlBJVxU+l+uxj6ra57kFWte0ZPNDpMp52CmKnfw1U7017EfKNltHLdv0Ji il9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731011532; x=1731616332; 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=e2Y+Zk3C3UMW+bIUsx4O41a2LQIXopEsB2wefkkO77o=; b=RV73Ceuk+eNmnsn05/mghiOTiCX9QuVkaYpcAGxsLfCdexfhGIn8vvDKvpx83Skun2 rX3Q6WNvAPQbzkoztFGT1Q9TRBAZBHDYR3Gdiry64tdyVR65fgg01psDV2iBZgFo3aCI O47SRDvLou3suj5mEsvpSM1ji0GQbnBYrrDxvTbkEaNQ81/K7o2bHQEkXjIBYc53OSdU 5AiLZxZZzhy6iOfOf6Dhp5FIL68PGIlfyzImieOREoKpGvXPsZS1E4fNcS3shTLsN77Q H95Xik/p4XZGj/ECMoAHCrMxnuPoB4pPHgAfQvKq0J5b2VCuJlWPjDh34o41Q5N0/jLb krOA== X-Forwarded-Encrypted: i=1; AJvYcCW6xDh2pqIxGhumWaWRS6bK1JpdBrq/tqK6qtvi5p7Xdpc2ouhE+0QNSJkdcgOW4J7e/japb+4w8r2zcv0d@lists.postgresql.org X-Gm-Message-State: AOJu0YyUKNEnk7PL3Q3pEepqc+hMbjayX46IY4W5Ntxq9E9syOGra7Yz /4RCP1Qsc3WjwHtdDFHTRGBV5nQz/r/ZmXIsT138cYBjyrjnoIiN X-Google-Smtp-Source: AGHT+IG5g0y81qu9K1sop+HDEgYQf0M3yZ8/hpsds7Pi0s8kTZKbfmQr4sT2VeQhNUeTcnCAeTLqcw== X-Received: by 2002:a05:6602:15c9:b0:83a:b901:3150 with SMTP id ca18e2360f4ac-83e032b837amr30737839f.8.1731011532476; Thu, 07 Nov 2024 12:32:12 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-83df5066ba9sm46685739f.24.2024.11.07.12.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Nov 2024 12:32:11 -0800 (PST) Date: Thu, 7 Nov 2024 14:32:09 -0600 From: Nathan Bossart To: Andres Freund Cc: "Devulapalli, Raghuveer" , "pgsql-hackers@lists.postgresql.org" Subject: Re: Popcount optimization using AVX512 Message-ID: References: <173022983862.1162.9439822012408182864.pgcf@coridan.postgresql.org> <173032159044.1162.17669652767784249811.pgcf@coridan.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="+Tuk9Rw2VxqNrotZ" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --+Tuk9Rw2VxqNrotZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Nov 07, 2024 at 02:03:04PM -0600, Nathan Bossart wrote: > Committed. Of course, as soon as I committed this, I noticed that it's broken. It seems that compilers are rather picky about how multiple target options are specified. AFAICT the commonly supported syntax is to put the entire list within one pair of quotes and to use only commas as delimiters, i.e., no spaces. I plan to commit the attached shortly once I've had a chance to verify it fixes the problem on cfbot. -- nathan --+Tuk9Rw2VxqNrotZ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-fix-__attribute__-target-.-usage.patch" From a5ade18a867377fa424347465bbc5f631eff4f96 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Thu, 7 Nov 2024 14:28:57 -0600 Subject: [PATCH 1/1] fix __attribute__((target(...))) usage --- config/c-compiler.m4 | 2 +- configure | 2 +- meson.build | 2 +- src/port/pg_popcount_avx512.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index c7eb896f14..a129edb88e 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -733,7 +733,7 @@ AC_DEFUN([PGAC_AVX512_POPCNT_INTRINSICS], AC_CACHE_CHECK([for _mm512_popcnt_epi64], [Ac_cachevar], [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include #if defined(__has_attribute) && __has_attribute (target) - __attribute__((target("avx512vpopcntdq","avx512bw"))) + __attribute__((target("avx512vpopcntdq,avx512bw"))) #endif static int popcount_test(void) { diff --git a/configure b/configure index 3a7332f834..4b01b682b1 100755 --- a/configure +++ b/configure @@ -17324,7 +17324,7 @@ else /* end confdefs.h. */ #include #if defined(__has_attribute) && __has_attribute (target) - __attribute__((target("avx512vpopcntdq","avx512bw"))) + __attribute__((target("avx512vpopcntdq,avx512bw"))) #endif static int popcount_test(void) { diff --git a/meson.build b/meson.build index 9eddd72a27..5b0510cef7 100644 --- a/meson.build +++ b/meson.build @@ -2184,7 +2184,7 @@ if host_cpu == 'x86_64' #include #if defined(__has_attribute) && __has_attribute (target) -__attribute__((target("avx512vpopcntdq","avx512bw"))) +__attribute__((target("avx512vpopcntdq,avx512bw"))) #endif int main(void) { diff --git a/src/port/pg_popcount_avx512.c b/src/port/pg_popcount_avx512.c index b598e86554..1ab2847bf2 100644 --- a/src/port/pg_popcount_avx512.c +++ b/src/port/pg_popcount_avx512.c @@ -106,7 +106,7 @@ pg_popcount_avx512_available(void) * pg_popcount_avx512 * Returns the number of 1-bits in buf */ -pg_attribute_target("avx512vpopcntdq", "avx512bw") +pg_attribute_target("avx512vpopcntdq,avx512bw") uint64 pg_popcount_avx512(const char *buf, int bytes) { @@ -162,7 +162,7 @@ pg_popcount_avx512(const char *buf, int bytes) * pg_popcount_masked_avx512 * Returns the number of 1-bits in buf after applying the mask to each byte */ -pg_attribute_target("avx512vpopcntdq", "avx512bw") +pg_attribute_target("avx512vpopcntdq,avx512bw") uint64 pg_popcount_masked_avx512(const char *buf, int bytes, bits8 mask) { -- 2.39.5 (Apple Git-154) --+Tuk9Rw2VxqNrotZ--