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 1rqEuW-00BKnX-Ns for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 16:16:57 +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 1rqEuV-002kF0-3N for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Mar 2024 16:16:55 +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 1rqEuU-002kEs-QB for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 16:16:54 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rqEuM-007JhI-Th for pgsql-hackers@lists.postgresql.org; Fri, 29 Mar 2024 16:16:54 +0000 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7d026c0a08aso94290439f.1 for ; Fri, 29 Mar 2024 09:16:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711729005; x=1712333805; 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=GYXLtHMJev39dv5fnY6qka1ZT4RKqOPcH2qWku4Pj2w=; b=SEK/F7i1oaLcIS9GCwdJBhjkiHQG3bp1pSqla+Iy0ZA0xC8xD/Gvz01eH/w1ZC5kCK ZGiLtbEOru6KyjDZv2dU0diyKrGYIedJJxMupbzFYihaFXhCvM4SJo4DJB/DIn7dyVt4 4geLQgredhnYMux4nD8zgv2tcaODDFPhDWbUO8EvmV9S59PQCYFks/3htn/vJFSbkxQv HVRs/J/J/6MfS07EYbxVQIwfCCMPvwMAsfnGr3Dnrvq/vA4qaXZjFy48oVUvvZLHZ9oD BYNORB3WEn59vJ7PUwn8sTPkKELXHsAwWyqJ93ZXRB9MZDdWK9S3l7/P86aENc1CPa9I eDtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711729005; x=1712333805; 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=GYXLtHMJev39dv5fnY6qka1ZT4RKqOPcH2qWku4Pj2w=; b=UMxHWbI+XH+KdQx6Pmcu7Wa6k/BlymaAH+yuzSYI4yiaTMFyMvXThjApqgZYpQ311q 1q8SzD5R+fx5Jfy6+uHRnlQwFxcHYcv11XR+yRpqXLmpDbRz5qxOlqFCcxyDNNpgGirC fuRnkw3t+AXhw8Udthd6mVHiPDgjhRSa+440etr9baHN8wGdrZSt6n+ME1J3pgEelAMB 7sY+ZbxkFWrynYM9YBkmIDWV3QJS4LBE2IJVtcjdDObLDdEhKWkGLDuy9t7W+ilA8cmt NLCbiU4ubCyWQUnpGfgYoieHki4w0sQrYlF6zPiPJxG7sRRWzPMaR197tFN4eMIcS2ez 9DNw== X-Forwarded-Encrypted: i=1; AJvYcCUGPgHQlFpoVuhe5V0129EGnnZuJZ3opJhVW5vVfvazbFqcLLfuPL2biUtM5iF00uiTS5qyzSQF2jHdPnz37CWIdF8pXzLvOmNdh8bvV/+0xJGl X-Gm-Message-State: AOJu0Yxp1r63IE4vBahuw7JumzPwQbQbB5aoe26FtvSavoGaVi6hOEa8 8SOiCo98Rihq7OqON8pQPY9zULM8zuUh3otAFAASSJhXYnHpo9Wm X-Google-Smtp-Source: AGHT+IHBEcLjJe8cPV/4wdRdolU3kHHviqqf52b7jEqH6KY3RW+rSmFNMBAKnQDdf4JYOqUQwOWr3Q== X-Received: by 2002:a5e:890b:0:b0:7d0:25d8:bbc4 with SMTP id k11-20020a5e890b000000b007d025d8bbc4mr2705295ioj.18.1711729005092; Fri, 29 Mar 2024 09:16:45 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id gm14-20020a0566382b8e00b004773d7a010dsm1022088jab.76.2024.03.29.09.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 09:16:44 -0700 (PDT) Date: Fri, 29 Mar 2024 11:16:42 -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: <20240329161642.GA1106154@nathanxps13> References: <2490633.1711379522@sss.pgh.pa.us> <20240325200551.GB2924132@nathanxps13> <20240327220010.GA231058@nathanxps13> <20240328213854.GA916732@nathanxps13> <20240329153515.GA1046039@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 Fri, Mar 29, 2024 at 04:06:17PM +0000, Amonson, Paul D wrote: >> Yeah, I understand that much, but I want to know how portable the XGETBV >> instruction is. Unless I can assume that all x86_64 systems and compilers >> support that instruction, we might need an additional configure check and/or >> CPUID check. It looks like MSVC has had support for the _xgetbv intrinsic for >> quite a while, but I'm still researching the other cases. > > I see google web references to the xgetbv instruction as far back as 2009 > for Intel 64 bit HW and 2010 for AMD 64bit HW, maybe you could test for > _xgetbv() MSVC built-in. How far back do you need to go? Hm. It seems unlikely that a compiler would understand AVX512 intrinsics and not XGETBV then. I guess the other question is whether CPUID indicating AVX512 is enabled implies the availability of XGETBV on the CPU. If that's not safe, we might need to add another CPUID test. It would probably be easy enough to add a couple of tests for this, but if we don't have reason to believe there's any practical case to do so, I don't know why we would. I'm curious what others think about this. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com