From f047ca31114d5749386660d65b7166e82e82d058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 5 Aug 2023 13:32:20 +0200 Subject: [PATCH 1/4] cmake: Check for Fortran compiler early on --- CMakeLists.txt | 11 +++++++++++ cmake/f_check.cmake | 7 +------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35077f3c2..f3cb0eed4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,17 @@ endif() message(WARNING "CMake support is experimental. It does not yet support all build options and may not produce the same Makefiles that OpenBLAS ships with.") +if(NOT NOFORTRAN) + # Check for working Fortran compiler + include(CheckLanguage) + check_language(Fortran) + if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) + else() + set(NOFORTRAN 1) + endif() +endif() + include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake") include("${PROJECT_SOURCE_DIR}/cmake/system.cmake") diff --git a/cmake/f_check.cmake b/cmake/f_check.cmake index df3a4858d..df9716cb7 100644 --- a/cmake/f_check.cmake +++ b/cmake/f_check.cmake @@ -20,12 +20,7 @@ # NEEDBUNDERSCORE # NEED2UNDERSCORES -include(CheckLanguage) -check_language(Fortran) -if(CMAKE_Fortran_COMPILER) - enable_language(Fortran) -else() - set (NOFORTRAN 1) +if(NOT CMAKE_Fortran_COMPILER) if (NOT NO_LAPACK) if (NOT XXXXX) message(STATUS "No Fortran compiler found, can build only BLAS and f2c-converted LAPACK") From 6a05bef0259ea5197ca9c4b9adb3d2ee7c1df1d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 5 Aug 2023 16:43:25 +0200 Subject: [PATCH 2/4] Disable AVX512 instructions for LLVM Flang before version 17 or with LLVM Flang on Windows. --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3cb0eed4..d35172c96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,19 @@ if(NOT NOFORTRAN) endif() endif() +if (NOT NOFORTRAN AND CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang") + if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 17 OR WIN32) + # The *blas3 tests fail on hardware with AVX512 instruction when using + # LLVM Flang before version 17 or when using LLVM Flang on Windows. + # Tested with LLVM Flang 16 and LLVM Flang 17 on Windows (MSYS2/CLANG64). + # FIXME: Revisit with LLVM Flang 18. + if (NOT NO_AVX512) + message(STATUS "Disabling AVX512 instructions for LLVM Flang before version 17 or on Windows.") + endif() + set(NO_AVX512 1) + endif() +endif() + include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake") include("${PROJECT_SOURCE_DIR}/cmake/system.cmake") From 3f86013201c9280bf78b52356ceb2f60870ab428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 5 Aug 2023 16:48:04 +0200 Subject: [PATCH 3/4] CI: Let the build system decide whether or not to build with NO_AVX512. --- .github/workflows/dynamic_arch.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/dynamic_arch.yml b/.github/workflows/dynamic_arch.yml index 4fe6e63fc..85b20c060 100644 --- a/.github/workflows/dynamic_arch.yml +++ b/.github/workflows/dynamic_arch.yml @@ -167,9 +167,6 @@ jobs: idx: int32 target-prefix: mingw-w64-clang-x86_64 fc-pkg: fc - # Compiling with Flang 16 seems to cause test errors on machines - # with AVX512 instructions. Revisit after MSYS2 distributes Flang 17. - no-avx512-flags: -DNO_AVX512=1 - msystem: CLANG32 idx: int32 target-prefix: mingw-w64-clang-i686 @@ -185,9 +182,6 @@ jobs: idx64-flags: -DBINARY=64 -DINTERFACE64=1 target-prefix: mingw-w64-clang-x86_64 fc-pkg: fc - # Compiling with Flang 16 seems to cause test errors on machines - # with AVX512 instructions. Revisit after MSYS2 distributes Flang 17. - no-avx512-flags: -DNO_AVX512=1 - msystem: MINGW64 idx: int32 target-prefix: mingw-w64-x86_64 @@ -274,7 +268,6 @@ jobs: -DTARGET=CORE2 \ ${{ matrix.idx64-flags }} \ ${{ matrix.c-lapack-flags }} \ - ${{ matrix.no-avx512-flags }} \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_Fortran_COMPILER_LAUNCHER=ccache \ .. From d21c660a99faecfc1244da5cadb1f1bbd7b0f31d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Sat, 5 Aug 2023 16:59:34 +0200 Subject: [PATCH 4/4] Don't use OpenMP with LLVM Flang before version 17. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d35172c96..57767c598 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,14 @@ if (NOT NOFORTRAN AND CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang") endif() set(NO_AVX512 1) endif() + + if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 17) + # LLVM Flang before version 17 doesn't support necessary OpenMP constructs. + if (USE_OPENMP) + message(STATUS "Disabling OpenMP for LLVM Flang before version 17.") + set(USE_OPENMP 0) + endif() + endif() endif() include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake")