OpenMathLib / OpenBLAS

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
http://www.openblas.net
BSD 3-Clause "New" or "Revised" License
6.43k stars 1.51k forks source link

icelake cpu detected as haswell #4057

Closed WilliamTambellini closed 1 year ago

WilliamTambellini commented 1 year ago

On a Intel(R) Xeon(R) Platinum 8375C CPU (icelake)

make
...
cc -O2 -DSMALL_MATRIX_OPT -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DC_LAPACK -DNO_AVX512 -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8 -DMAX_PARALLEL_NUMBER=1 -DBUILD_SINGLE=1 -DBUILD_DOUBLE=1 -DBUILD_COMPLEX=1 -DBUILD_COMPLEX16=1 -DVERSION=\"0.3.23\" -msse3 -mssse3 -msse4.1 -mavx -mavx2 -mavx2 -UASMNAME -UASMFNAME -UNAME -UCNAME -UCHAR_NAME -UCHAR_CNAME -DASMNAME=c_cblat2c -DASMFNAME=c_cblat2c_ -DNAME=c_cblat2c_ -DCNAME=c_cblat2c -DCHAR_NAME=\"c_cblat2c_\" -DCHAR_CNAME=\"c_cblat2c\" -DNO_AFFINITY -I.. -DADD_ -DCBLAS   -c -o c_cblat2c.o c_cblat2c.c
...
libopenblas_haswellp-r0.3.23.a

I know make allows to set the cpu arch target but I dont see icelake in the target list: https://github.com/xianyi/OpenBLAS/blob/develop/TargetList.txt

haswell has been released in 2013 https://en.wikipedia.org/wiki/Haswell_(microarchitecture) and did nt have avx512, whereas icelake cpus usually support avx512: https://en.wikipedia.org/wiki/Ice_Lake_(microprocessor)

brada4 commented 1 year ago

Could not find your CPU in Intel ARK database? https://ark.intel.com/content/www/us/en/ark/products/codename/74979/products-formerly-ice-lake.html

Please post CPU-Z screenshot if on Windows, or last CPU part from /proc/cpuinfo if on Linux, from inside and outside of virtualisation if such is used.

martin-frbg commented 1 year ago

Ice Lake should be detected as SkylakeX, unless you are running in an (emulator) environment where AVX512 is not active, or building with a very old compiler toolchain that does not support AVX512 instructions

martin-frbg commented 1 year ago

Found the CPUID elsewhere (amusingly in a support ticket for a vendor compiler that was claimed to be misdetecting it as Haswell too), family 6 model 106 (or family 6, extended model 6, model 10 in the format our getarch tool uses internally. This

https://github.com/xianyi/OpenBLAS/blob/7796068930e99b65f9e1478475fcd827c9be1daf/cpuid_x86.c#L1434-L1440 shows it is recognized, and supported through the BLAS kernels of Cooper Lake, Sky Lake or Haswell depending on the level of AVX512 support enabled.

WilliamTambellini commented 1 year ago

@brada4

last CPU part from /proc/cpuinfo if on Linux

processor   : 3
vendor_id   : GenuineIntel
cpu family  : 6
model       : 106
model name  : Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
stepping    : 6
microcode   : 0xd000331
cpu MHz     : 2899.966
cache size  : 55296 KB
physical id : 0
siblings    : 8
core id     : 3
cpu cores   : 4
apicid      : 6
initial apicid  : 6
fpu     : yes
fpu_exception   : yes
cpuid level : 27
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nop
l xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm 
abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt 
clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 ida arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq md_cle
ar spec_ctrl intel_stibp flush_l1d arch_capabilities
bogomips    : 5799.93
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:
martin-frbg commented 1 year ago

Matches what I found, thanks. What is your operating system and C compiler, any emulation involved ?

brada4 commented 1 year ago

vmx is not visible, it must be virtualisation.

WilliamTambellini commented 1 year ago

What is your operating system and C compiler, any emulation involved ?

centos7 and gcc 11. AWS EC2 machine so probably emulation. I m more interested to know how to to get the best perf on that cpu with openblas 0.3.23. Tks

martin-frbg commented 1 year ago

Chances are that AVX512 is actually not available in that setup (getarch queries both that the cpu is capable, and that the operating system enables it by saving/restoring the zmm registers). So forcing TARGET=SKYLAKEX will most likely result in an "illegal instruction" abort at runtime, and the autodetected TARGET=HASWELL should be your best choice. But of course you can try for yourself. (Or ask AWS support why you can't get AVX512 on "your" machine - maybe it is to avoid resource contention between customer vms, maybe EC2 is backed by a mix of Xeon and non-Xeon hardware and "your machine" can end up on actual Haswell-generation hardware at any time.

brada4 commented 1 year ago

You need devtoolset compiler what includes AVX-512 capable binutils. https://github.com/xianyi/OpenBLAS/wiki/faq#binutils

martin-frbg commented 1 year ago

Is that still true for Centos 7 ? (Anyway it should be clear from a build log - if it has NO_AVX512 among the options then the toolchain was unable to compile a tiny AVX512 code snippet embedded in the c_check script.)

brada4 commented 1 year ago

Since 7.9 update no major fixes are added, so no, it will not compile AVX-512 with default compiler. Better way would be to go with Alma or Rocky 9 (whichever amazon deploys for free) and not suffer for next 10 years.

conradsnicta commented 1 year ago

CentOS 7 will be EOL in about a year (June 2024), so it shouldn't be used in any new projects. It's in a semi-zombie state already, getting only occasional security fixes until EOL.

As per the suggestion of @brada4, it's best to use the remaining time to migrate existing projects to Alma Linux 9 or Rocky Linux 9, which should be supported until 2032 (as per RHEL 9 maintenance schedule).

brada4 commented 1 year ago

Thank you for expanding. @WilliamTambellini - look for AWS images for those distributions. To complete list - Oracle Enterprise Linux 9, or go with fedora, it upgrades well between major releases twice a year.

One can have precompiled Fedora package on EL, it is rather old if looking at EL7 though. https://github.com/xianyi/OpenBLAS/wiki/Precompiled-installation-packages#fedoracentosrhel