From: Nathan Bossart <nathandbossart@gmail.com>
To: Devulapalli, Raghuveer <raghuveer.devulapalli@intel.com>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: Use __attribute__((target(sse4.2))) for SSE42 CRC32C
Date: Thu, 7 Nov 2024 15:36:38 -0600
Message-ID: <Zy0y5qZi27ITnC1q@nathan> (raw)
In-Reply-To: <PH8PR11MB82868168DEB5CA1FBE9EEDC1FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com>
References: <PH8PR11MB8286BE735A463468415D46B5FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com>
<Zy0qg7cnI3uMr-qn@nathan>
<PH8PR11MB82868168DEB5CA1FBE9EEDC1FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com>
On Thu, Nov 07, 2024 at 09:30:32PM +0000, Devulapalli, Raghuveer wrote:
>> # Check for Intel SSE 4.2 intrinsics to do CRC calculations.
>> #
>> -# First check if the _mm_crc32_u8 and _mm_crc32_u64 intrinsics can be used -#
>> with the default compiler flags. If not, check if adding the -msse4.2 -# flag helps.
>> CFLAGS_CRC is set to -msse4.2 if that's required.
>> +# Check if the _mm_crc32_u8 and _mm_crc32_u64 intrinsics can be used #
>> +with the __attribute__((target("sse4.2"))).
>> PGAC_SSE42_CRC32_INTRINSICS([])
>> -if test x"$pgac_sse42_crc32_intrinsics" != x"yes"; then
>> - PGAC_SSE42_CRC32_INTRINSICS([-msse4.2])
>> -fi
>>
>> IIUC this means we will never set USE_SSE42_CRC32C_WITH_RUNTIME_CHECK.
>
> I don't think so. USE_SSE42_CRC32C additionally requires SSE4_2_TARGETED
> to be true which will only happen when explicitly built with -msse4.2.
> When this explicit compiler flag is missing, we set
> USE_SSE42_CRC32C_WITH_RUNTIME_CHECK to true. This logic is further down
> in the configure.ac file:
>
> if test x"$pgac_sse42_crc32_intrinsics" = x"yes" && test x"$SSE4_2_TARGETED" = x"1" ; then
> USE_SSE42_CRC32C=1
> else
Oh, you are right, sorry.
>> + 'pg_crc32c_sse42_choose.c',
>> + 'pg_crc32c_sse42.c',
>>
>> Can we combine these?
>
> Knowing the AVX-512 will come next, I think it makes sense to keep the
> runtime choose function separate. Otherwise this gets polluted with
> runtime choose function, sse42 algorithm and the avx512 algorithm in the
> next patch. Does that make sense??
Is the idea that we will put both "choose" functions in one file and the
actual CRC-32C code in another? I'm okay with that.
--
nathan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: nathandbossart@gmail.com, raghuveer.devulapalli@intel.com
Subject: Re: Use __attribute__((target(sse4.2))) for SSE42 CRC32C
In-Reply-To: <Zy0y5qZi27ITnC1q@nathan>
References: <PH8PR11MB8286BE735A463468415D46B5FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com> <Zy0qg7cnI3uMr-qn@nathan> <PH8PR11MB82868168DEB5CA1FBE9EEDC1FB5C2@PH8PR11MB8286.namprd11.prod.outlook.com> <Zy0y5qZi27ITnC1q@nathan>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox