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 1t9SrB-00ALQi-Gs for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Nov 2024 17:33:12 +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 1t9Sr8-00BZSJ-Vk for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Nov 2024 17:33:11 +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 1t9SpQ-00BWnH-PI for pgsql-hackers@lists.postgresql.org; Fri, 08 Nov 2024 17:31:25 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t9SpN-000swe-Dn for pgsql-hackers@lists.postgresql.org; Fri, 08 Nov 2024 17:31:24 +0000 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3a6c2077afcso8240955ab.0 for ; Fri, 08 Nov 2024 09:31:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731087080; x=1731691880; 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=GbQX8xUjiX2TyC+8dzhG48twwtB+IVE2xr5bQr9/4+o=; b=fWrXJj8Da+ChjT8OVAyS6+4EiKD5aZCL1B8atLIxTgaCW9PxwYeKmp8m7kV4Bj9RrC /CTz6DjlyAJMWOJyzz95F68cOjjwa630YAX4WJhTUUWdjg/Wm/ceL58leAxeX98LizNs KMTqg7j/YfofEviwAlJCyc8+p8lvwAN6uB+C3RM4vWcPv7oOpJ2qHV+kTdvXdn9dVPe6 9IZvUZNZ3d+T551ZrHjN530gQhOV+RkfHcCpbJg5IY9HNRXhlxCwgUbRBQB+XZrkAYVJ 9/TfF/rzuv02jVws4Lpe4J6OnxBTZhXm7Bvs2LJ13TsshnTJlIVszDOq8N13qw9EysD0 8mdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731087080; x=1731691880; 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=GbQX8xUjiX2TyC+8dzhG48twwtB+IVE2xr5bQr9/4+o=; b=Qjx+dugHqChk9Ka5gVz0+dgj9AJyiX6Wm1EbyS4KaThTnz18gbR+Etmcj4P11Wx+GW GaIR/k4mzA4PxABC8kpDaxlTFh9bLvFankx8nssJORaEmLKB3sjuSBRfUvnpqmGMnsYb ectkbbr9LQC4PpwXUDo0GT51CcBGJHI93NCXSjy6WTD/E8TmRtksm/jS8ZKiJ37mnALH WtMkrpdNIn4l4WgEq9lbyKQeN+lPcjgQR0m0fYxz4PhTVCULPj/vy5BPjKWgMJHPBXvc HrU3IqablvKeaMMZpCkiIG7rMxtx+jV1ytXU6nbGslr2YKNNv4KPv4j8zTPQVvVRD2Bx 58GA== X-Gm-Message-State: AOJu0YyTQlcKbarbhCcbmrAsOp8FsxM/wxiRzDlTy9Qodyi7Qjmmq/5k /x73Che0mkm+H3WihXAaM+J6a9ZZDRqo3m+y9fIqPsYg68ajbgmmIRZJbg== X-Google-Smtp-Source: AGHT+IGGeKnayqdxf7gNjCyll2F0sS57p7MvnPu75Da86+HAOKBIs8fmeRAIASgb6uS0ESlVh30uhg== X-Received: by 2002:a05:6e02:194b:b0:3a6:c716:ab1f with SMTP id e9e14a558f8ab-3a6f19a0347mr41541365ab.9.1731087080156; Fri, 08 Nov 2024 09:31:20 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a6eacaa12fsm9835105ab.23.2024.11.08.09.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2024 09:31:19 -0800 (PST) Date: Fri, 8 Nov 2024 11:31:17 -0600 From: Nathan Bossart To: "Devulapalli, Raghuveer" Cc: "pgsql-hackers@lists.postgresql.org" Subject: Re: Use __attribute__((target(sse4.2))) for SSE42 CRC32C Message-ID: References: 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 - prog = ''' + sse42_crc_prog = ''' nitpick: Why does this need to be renamed? +#ifdef TEST_SSE42_WITH_ATTRIBUTE +#if defined(__has_attribute) && __has_attribute (target) +__attribute__((target("sse4.2"))) +#endif +#endif So, for meson builds, we do test with and without __attribute___((target(..."))), but for autoconf builds, we check for __SSE4_2__ to determine whether we need a runtime check. This difference isn't the fault of your patch, but it's a little odd. That being said, I'm not sure there's a problem with either approach. +if host_cpu == 'x86' or host_cpu == 'x86_64' + pgport_sources += files( + 'pg_crc32c_sse42_choose.c', + 'pg_crc32c_sse42.c', + ) +endi We could probably just build these unconditionally (i.e., put them in the first list of pgport_sources in this file) instead of keeping this complexity in the build scripts. +#if defined(USE_SSE42_CRC32C) || defined(USE_SSE42_CRC32C_WITH_RUNTIME_CHECK) Can we move this to just below #include "c.h"? The reason I didn't do this for the AVX-512 stuff is because TRY_POPCNT_FAST is defined in pg_bitutils.h, but looking again, I may be able to at least move the check for USE_AVX512_POPCNT_WITH_RUNTIME_CHECK up similarly. -- nathan