Re: Popcount optimization using AVX512
От | Nathan Bossart |
---|---|
Тема | Re: Popcount optimization using AVX512 |
Дата | |
Msg-id | ZqlhLn9PwBTpdy-n@nathan обсуждение исходный текст |
Ответ на | Re: Popcount optimization using AVX512 (Nathan Bossart <nathandbossart@gmail.com>) |
Список | pgsql-hackers |
On Tue, Jul 30, 2024 at 04:32:07PM -0500, Nathan Bossart wrote: > On Tue, Jul 30, 2024 at 02:07:01PM -0700, Andres Freund wrote: >> Afaict we could just check for predefined preprocessor macros: >> >> echo|time gcc -c -mxsave -mavx512vpopcntdq -mavx512bw -xc -dM -E - -o -|grep -E '__XSAVE__|__AVX512BW__|__AVX512VPOPCNTDQ__' >> #define __AVX512BW__ 1 >> #define __AVX512VPOPCNTDQ__ 1 >> #define __XSAVE__ 1 >> 0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 13292maxresident)k >> >> echo|time gcc -c -march=nehalem -xc -dM -E - -o -|grep -E '__XSAVE__|__AVX512BW__|__AVX512VPOPCNTDQ__' >> 0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 10972maxresident)k > > Seems promising. I can't think of a reason that wouldn't work. > >> Now, a reasonable counter-argument would be that only some of these macros are >> defined for msvc ([1]). However, as it turns out, the test is broken >> today, as msvc doesn't error out when using an intrinsic that's not >> "available" by the target architecture, it seems to assume that the caller did >> a cpuid check ahead of time. Hm. Upon further inspection, I see that MSVC appears to be missing __XSAVE__ and __AVX512VPOPCNTDQ__, which is unfortunate. Still, I think the worst case scenario is that the CPUID check fails and we don't use AVX-512 instructions. AFAICT we aren't adding new function pointers in any builds that don't already have them, just compiling some extra unused code. -- nathan
В списке pgsql-hackers по дате отправления: