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 1rmx0A-00AnID-84 for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Mar 2024 14:33:10 +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 1rmx08-005Y3Q-SA for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Mar 2024 14:33: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 1rmwyV-005UV6-5x for pgsql-hackers@lists.postgresql.org; Wed, 20 Mar 2024 14:31:27 +0000 Received: from mail-io1-xd2c.google.com ([2607:f8b0:4864:20::d2c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rmwyO-005Yky-5b for pgsql-hackers@postgresql.org; Wed, 20 Mar 2024 14:31:26 +0000 Received: by mail-io1-xd2c.google.com with SMTP id ca18e2360f4ac-7c7476a11e0so188872839f.3 for ; Wed, 20 Mar 2024 07:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710945078; x=1711549878; darn=postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=JuJ154v70DcTHUwm4U21jXjbCct6SFQDR7zqvwbEtXY=; b=RP+kapHMiSU32elm7TevdtHbDFpazcxzIMdiemmlKdN0MBZQjI7nFk2AzJ9h0zFCKn 8vzWDALpyeKcvZe0IBGXx8B2b8Cadc0NGr8PXCSlE9Oav9mNh1Q1TsWoHEGJq9AWp9jL aC2InF/LVcvdMq2izvSpgNoAcueFoPaCwKxCdLpHi/VP84LoCmDLG3G6ZhZIcUtsLv0J G/JKdWmvqcdUQKqyNRstJ7QghUDaec4otUBZl1lq0HC1DnUNsmHWFQZVqQ9X6aMBLFXw tEaXSEyl4FJ6y/B7i6+CEQF+lRplg4vO43mR3j2YaGwHqtrYd7EhfOuR/h7rZ86JYbge rp/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710945078; x=1711549878; h=in-reply-to:content-transfer-encoding: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=JuJ154v70DcTHUwm4U21jXjbCct6SFQDR7zqvwbEtXY=; b=QQUhpoSIbeRUuaOefOvYNRlZt+l62qJBp4RcypnOV7+mOm70jZw4w3B3tGlEwp0/ys iQbc0DuKR0jntkR5PLWX6RLOXi8a/LhX/eO3OJCyiT3DjaGk2WIKlRtKo5axqE9l9Y8x 6oN35iwIthBItQmosTk33pgFxFn0u+MpYe0hb2ZguAZTZIC+3Ui0hMrjvoJz1L48H2IQ wtc7MmTbPw4pIQTn4zKHTJSIvnuleGsrFtxWpjr5rFuiXStroB4Ce4syFfH+iVoQjGSA H86wS9gAVK2IWW0D+UBIj3g6fJ1up+0wzUM0XZpjRhDNvdci2Uv5xT7YQ2pLHLsqGaMD vNUw== X-Forwarded-Encrypted: i=1; AJvYcCUTfM5t4p+Vv0PDgaVAbdQZat1+01TumuHA1ItyiswudPcZZNYlsBTzGq3CLk+xAndr64hT//aCDLnJgbXxcs+3/6wtQCJ/P+UXcbA1 X-Gm-Message-State: AOJu0YzXsYhvqsuIz6BqCge303fU3vBMgTmWzUPLL8dSYtlxm4NIKi/K 1iuhzGvPL7Op/i7v3MktkwIgQXLHl5BxxB6opZpRBGW0nX+QNsT1 X-Google-Smtp-Source: AGHT+IGy2lqfndZMiEhb0e+3y7Ew29QhSgD2NLj9lo95VNJ/M6yhSRRkVAiUDStr5C/Xp4QOuGG5ug== X-Received: by 2002:a5d:8710:0:b0:7cc:9dc:70a6 with SMTP id u16-20020a5d8710000000b007cc09dc70a6mr11222108iom.21.1710945078328; Wed, 20 Mar 2024 07:31:18 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id h4-20020a02cd24000000b004770d600487sm3535093jaq.48.2024.03.20.07.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:31:18 -0700 (PDT) Date: Wed, 20 Mar 2024 09:31:16 -0500 From: Nathan Bossart To: John Naylor Cc: Ants Aasma , pgsql-hackers@postgresql.org Subject: Re: add AVX2 support to simd.h Message-ID: <20240320143116.GA1313857@nathanxps13> References: <20240315174149.GA3837823@nathanxps13> <20240315194016.GA3896616@nathanxps13> <20240319020341.GA823987@nathanxps13> <20240319031601.GA828141@nathanxps13> <20240319163033.GA952199@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Mar 20, 2024 at 01:57:54PM +0700, John Naylor wrote: > On Tue, Mar 19, 2024 at 11:30 PM Nathan Bossart > wrote: >> I tried to trim some of the branches, and came up with the attached patch. >> I don't think this is exactly what you were suggesting, but I think it's >> relatively close. My testing showed decent benefits from using 2 vectors >> when there aren't enough elements for 4, so I've tried to keep that part >> intact. > > I would caution against that if the benchmark is repeatedly running > against a static number of elements, because the branch predictor will > be right all the time (except maybe when it exits a loop, not sure). > We probably don't need to go to the trouble to construct a benchmark > with some added randomness, but we have be careful not to overfit what > the test is actually measuring. I don't mind removing the 2-register stuff if that's what you think we should do. I'm cautiously optimistic that it'd help more than the extra branch prediction might hurt, and it'd at least help avoid regressing the lower end for the larger AVX2 registers, but I probably won't be able to prove that without constructing another benchmark. And TBH I'm not sure it'll significantly impact any real-world workload, anyway. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com