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 1rgAgq-004axE-Kw for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Mar 2024 21:45:13 +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 1rgAgn-00F8QV-1n for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Mar 2024 21:45:09 +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 1rgAgm-00F8QM-Oo for pgsql-hackers@lists.postgresql.org; Fri, 01 Mar 2024 21:45:09 +0000 Received: from mail-yb1-xb29.google.com ([2607:f8b0:4864:20::b29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rgAgf-002JcG-P3 for pgsql-hackers@lists.postgresql.org; Fri, 01 Mar 2024 21:45:08 +0000 Received: by mail-yb1-xb29.google.com with SMTP id 3f1490d57ef6-dc6d8bd618eso2852495276.3 for ; Fri, 01 Mar 2024 13:45:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709329500; x=1709934300; 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=T9IH0ePgkmPsdQ+ZEulsnrtQeAbA4vHP+j4pGawO7fY=; b=mM/GaCbdnZgpY0e4aWN8i6WjLqhw31jfm8qUxV+fAvJ+swFhZaGD/uYB6Va886wNrU 8b8TIZzXBMKpN1JE+6TkvSsxc/XAoPrC858Y0vj2pBmAFEUU2AnC4xUIrPC/KHBLc2EF tcy9pevVPvvL6ztF9Er1FJk9oLr886xxVDPbsFyjh+DmSI8W7VswETw6MHrt6ezAR27z AsFhW1UwwIg3r3V/KF/M9YWcVwqQOjz17fSHGxZCHJN0/gnh1iTVoZXC22YSkkCXn+Ct tND5ytUj/UsynByqGehk5bPU5kMEZqHdxsmfO2uglleBLDinHGPsxT3qUBsH251XhmEl BjZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709329500; x=1709934300; 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=T9IH0ePgkmPsdQ+ZEulsnrtQeAbA4vHP+j4pGawO7fY=; b=TIcN5vWQQef2ff2OHeh3YidI8GAHnwEmqp8ZPRtrroNHBjR9AOMwrF6vgtmT321h0c I7eb0mEAtE/aH/K1De+c1mN0GK++dFPGmlXC3FkrGX3cjyvrtH2aeiWsns7ik8UMn8jY BVjT9sGb7+AXZnXhVerz/IxM4qj2cvtEamfdmVkxEZwfE7YbdOt2MFOzK/fqkWL9dvif pIBQ8W/NgEUJkM/06jdzsC4vCiZdybALU3LLT/tXnpj1P0kb4AFnZobw3PjkrOtH3b/d QLEC0XLvalAa5SDlL0G8X5APd37vKi41kSYS8ev4Mmvds9JeinGaNfsun2cJ9bq7JyVt acfg== X-Forwarded-Encrypted: i=1; AJvYcCV+q5n9PWVb9cCL1udSWrfIFQ9fs3m3hqZIGmWSVRjFIP+LsW8sOQMH72Xtm9qXI/Zci0T9D4mEZHOwqDvwYXVDu6NejdIpnuFzPKZ9sb0sW99Z X-Gm-Message-State: AOJu0Yx9CGV5DzDuCfu9UfMq4XWmEG3ERMhqT3xNoBmKlvwwtd/YyvP9 TO75r6TQlRTvehqf0wvKW4W6uJDPqWUYBl95HSNPL5Nogn20nz6c X-Google-Smtp-Source: AGHT+IFXOZD7HPQqgSX4Q/zY+0qCokaex15q176e9YwLOpnwYb4/YPpy6MnYNqMltF07SgfbQR9o+Q== X-Received: by 2002:a25:86cb:0:b0:dcc:273e:1613 with SMTP id y11-20020a2586cb000000b00dcc273e1613mr2680564ybm.40.1709329499953; Fri, 01 Mar 2024 13:44:59 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id g13-20020a25ae4d000000b00dc74258241fsm1006260ybe.45.2024.03.01.13.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 13:44:59 -0800 (PST) Date: Fri, 1 Mar 2024 15:44:57 -0600 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: <20240301214457.GA3024365@nathanxps13> References: <202402071013.reqe3bdnjjuj@alvherre.pgsql> <20240209183450.snllkk7erharc73y@awork3.anarazel.de> <20240212203714.u4p7yeu7isuemmze@awork3.anarazel.de> 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 Thanks for the new version of the patch. I didn't see a commitfest entry for this one, and unfortunately I think it's too late to add it for the March commitfest. I would encourage you to add it to July's commitfest [0] so that we can get some routine cfbot coverage. On Tue, Feb 27, 2024 at 08:46:06PM +0000, Amonson, Paul D wrote: > After consulting some Intel internal experts on MSVC the linking issue as > it stood was not resolved. Instead, I created a MSVC ONLY work-around. > This adds one extra functional call on the Windows builds (The linker > resolves a real function just fine but not a function pointer of the same > name). This extra latency does not exist on any of the other platforms. I > also believe I addressed all issues raised in the previous reviews. The > new pg_popcnt_x86_64_accel.c file is now the ONLY file compiled with the > AVX512 compiler flags. I added support for the MSVC compiler flag as > well. Both meson and autoconf are updated with the new refactor. > > I am attaching the new patch. I think this patch might be missing the new files. -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) IME this means that the autoconf you are using has been patched. A quick search on the mailing lists seems to indicate that it might be specific to Debian [1]. -static int pg_popcount32_slow(uint32 word); -static int pg_popcount64_slow(uint64 word); +int pg_popcount32_slow(uint32 word); +int pg_popcount64_slow(uint64 word); +uint64 pg_popcount_slow(const char *buf, int bytes); This patch appears to do a lot of refactoring. Would it be possible to break out the refactoring parts into a prerequisite patch that could be reviewed and committed independently from the AVX512 stuff? -#if SIZEOF_VOID_P >= 8 +#if SIZEOF_VOID_P == 8 /* Process in 64-bit chunks if the buffer is aligned. */ - if (buf == (const char *) TYPEALIGN(8, buf)) + if (buf == (const char *)TYPEALIGN(8, buf)) { - const uint64 *words = (const uint64 *) buf; + const uint64 *words = (const uint64 *)buf; while (bytes >= 8) { @@ -309,9 +213,9 @@ pg_popcount(const char *buf, int bytes) bytes -= 8; } - buf = (const char *) words; + buf = (const char *)words; } -#else +#elif SIZEOF_VOID_P == 4 /* Process in 32-bit chunks if the buffer is aligned. */ if (buf == (const char *) TYPEALIGN(4, buf)) { Most, if not all, of these changes seem extraneous. Do we actually need to more strictly check SIZEOF_VOID_P? [0] https://commitfest.postgresql.org/48/ [1] https://postgr.es/m/20230211020042.uthdgj72kp3xlqam%40awork3.anarazel.de -- Nathan Bossart Amazon Web Services: https://aws.amazon.com