easybuilders / easybuild-easyconfigs

A collection of easyconfig files that describe which software to build using which build options with EasyBuild.
https://easybuild.io
GNU General Public License v2.0
377 stars 701 forks source link

OpenBLAS/0.3.7-GCC-8.3.0 with optarch=GENERIC builds with avx512. #9754

Open terjekv opened 4 years ago

terjekv commented 4 years ago

OpenBLAS/0.3.7-GCC-8.3.0 built with optarch=GENERIC returns an illegal instruction when used via R on an i5 without avx512. OpenBLAS/0.3.5-GCC-8.2.0-2.31.1 does not suffer from this issue.

Interesting feature here, these are all built on the same host with the same optarch=GENERIC:

$ pwd; ls -1 */lib/
/opt/uio/modules/rhel8/easybuild/software/OpenBLAS
0.3.1-GCC-7.3.0-2.30/lib/:
cmake
libopenblas.a
libopenblas_haswellp-r0.3.1.a
libopenblas_haswellp-r0.3.1.so
libopenblas.so
libopenblas.so.0
pkgconfig

0.3.5-GCC-8.2.0-2.31.1/lib/:
cmake
libopenblas.a
libopenblas_haswellp-r0.3.5.a
libopenblas_haswellp-r0.3.5.so
libopenblas.so
libopenblas.so.0
pkgconfig

0.3.7-GCC-8.3.0/lib/:
cmake
libopenblas.a
libopenblas_skylakexp-r0.3.7.a
libopenblas_skylakexp-r0.3.7.so
libopenblas.so
libopenblas.so.0
pkgconfig
terjekv commented 4 years ago

When built on the i5 itself, 0.3.7-GCC-8.3.0 produces libopenblas_haswellp-r0.3.7.so as expected.

terjekv commented 4 years ago

Well, I found out why. OpenBLAS with EasyBuild never supported optarch. And it's documented as a special case: https://easybuild.readthedocs.io/en/latest/Controlling_compiler_optimization_flags.html#caveats

For example, the OpenBLAS build system will autodetect the processor architecture in the build host, and will optimize for that processor architecture by default.

If you want a generic OpenBLAS build you will need to tweak the OpenBLAS easyconfig file to define the desired TARGET to use. For this you will need to modify the buildopts easyconfig parameter, for example:

buildopts = 'TARGET=PRESCOTT BINARY=64 ' + threading + ' CC="$CC" FC="$F77"'

I might have to see if there is a way to resolve this somehow in the OpenBLAS EasyBlock, so at least the optarch is adhered to.

boegel commented 4 years ago

This can probably be fixed in the easyblock, indeed. I think the documentation dates from before we had a custom easyblock for OpenBLAS (when we were still using ConfigureMake).

BerndDoser commented 4 years ago

Same behavior with OpenBLAS-0.3.9-GCC-9.3.0.eb. Using --optarch=march=skylake compiles with both flags -march=skylake -march=skylake-avx512. Is there a workaround?

terjekv commented 4 years ago

@BerndDoser There is no workaround directly in EasyBuild right now. I have not had time to look at this in a long while, sorry. There is an old WIP here https://github.com/easybuilders/easybuild-easyblocks/pull/1946 that requires a bit of work right now. As such, the options are basically:

1) Build OpenBLAS on a node with the desired architecture, or 2) manually edit https://github.com/easybuilders/easybuild-easyblocks/blob/develop/easybuild/easyblocks/o/openblas.py to ensure that TARGET is set to an appropriate arch based on TargetList.txt in the OpenBLAS source.

I really should sit down and work on that PR. Sorry. :-(