From 218e5309a3ca236f632caea17f8ed95e057b736f Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 31 Jan 2024 12:31:44 +0100 Subject: [PATCH 01/22] CI: Add github workflow using Apple M --- .github/workflows/apple_m.yml | 138 ++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 .github/workflows/apple_m.yml diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml new file mode 100644 index 0000000000..0e7d9ee940 --- /dev/null +++ b/.github/workflows/apple_m.yml @@ -0,0 +1,138 @@ +name: continuous build + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read # to fetch code (actions/checkout) + +jobs: + build: + if: "github.repository == 'OpenMathLib/OpenBLAS'" + runs-on: macos-14 + + strategy: + fail-fast: false + matrix: + build: [cmake, make] + + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Print system information + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + cat /proc/cpuinfo + elif [ "$RUNNER_OS" == "macOS" ]; then + sysctl -a | grep machdep.cpu + else + echo "::error::$RUNNER_OS not supported" + exit 1 + fi + + - name: Install Dependencies + run: | + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get install -y gfortran cmake ccache libtinfo5 + elif [ "$RUNNER_OS" == "macOS" ]; then + # It looks like "gfortran" isn't working correctly unless "gcc" is re-installed. + brew reinstall gcc + brew install coreutils cmake ccache + else + echo "::error::$RUNNER_OS not supported" + exit 1 + fi + + - name: Compilation cache + uses: actions/cache@v3 + with: + path: ~/.ccache + # We include the commit sha in the cache key, as new cache entries are + # only created if there is no existing entry for the key yet. + # GNU make and cmake call the compilers differently. It looks like + # that causes the cache to mismatch. Keep the ccache for both build + # tools separate to avoid polluting each other. + key: ccache-${{ runner.os }}-${{ matrix.build }}-${{ matrix.fortran }}-${{ github.ref }}-${{ github.sha }} + # Restore a matching ccache cache entry. Prefer same branch and same Fortran compiler. + restore-keys: | + ccache-${{ runner.os }}-${{ matrix.build }}-${{ matrix.fortran }}-${{ github.ref }} + ccache-${{ runner.os }}-${{ matrix.build }}-${{ matrix.fortran }} + ccache-${{ runner.os }}-${{ matrix.build }} + + - name: Configure ccache + run: | + if [ "${{ matrix.build }}" = "make" ]; then + # Add ccache to path + if [ "$RUNNER_OS" = "Linux" ]; then + echo "/usr/lib/ccache" >> $GITHUB_PATH + elif [ "$RUNNER_OS" = "macOS" ]; then + echo "$(brew --prefix)/opt/ccache/libexec" >> $GITHUB_PATH + else + echo "::error::$RUNNER_OS not supported" + exit 1 + fi + fi + # Limit the maximum size and switch on compression to avoid exceeding the total disk or cache quota (5 GB). + test -d ~/.ccache || mkdir -p ~/.ccache + echo "max_size = 300M" > ~/.ccache/ccache.conf + echo "compression = true" >> ~/.ccache/ccache.conf + ccache -s + + - name: Build OpenBLAS + run: | + case "${{ matrix.build }}" in + "make") + make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=0 FC="ccache ${{ matrix.fortran }}" + ;; + "cmake") + mkdir build && cd build + cmake -DDYNAMIC_ARCH=1 \ + -DNOFORTRAN=0 \ + -DBUILD_WITHOUT_LAPACK=0 \ + -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_Fortran_COMPILER=${{ matrix.fortran }} \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_Fortran_COMPILER_LAUNCHER=ccache \ + .. + cmake --build . + ;; + *) + echo "::error::Configuration not supported" + exit 1 + ;; + esac + + - name: Show ccache status + continue-on-error: true + run: ccache -s + + - name: Run tests + timeout-minutes: 60 + run: | + case "${{ matrix.build }}" in + "make") + MAKE_FLAGS='DYNAMIC_ARCH=1 USE_OPENMP=0' + echo "::group::Tests in 'test' directory" + make -C test $MAKE_FLAGS FC="ccache ${{ matrix.fortran }}" + echo "::endgroup::" + echo "::group::Tests in 'ctest' directory" + make -C ctest $MAKE_FLAGS FC="ccache ${{ matrix.fortran }}" + echo "::endgroup::" + echo "::group::Tests in 'utest' directory" + make -C utest $MAKE_FLAGS FC="ccache ${{ matrix.fortran }}" + echo "::endgroup::" + ;; + "cmake") + cd build && ctest + ;; + *) + echo "::error::Configuration not supported" + exit 1 + ;; + esac From 7c884370709dcac3f5eaa0bfd8f6052b2c38cb02 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 31 Jan 2024 18:38:40 +0100 Subject: [PATCH 02/22] rename and fix reference to removed variable --- .github/workflows/apple_m.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 0e7d9ee940..357073ef39 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -1,4 +1,4 @@ -name: continuous build +name: apple m on: [push, pull_request] @@ -60,8 +60,7 @@ jobs: key: ccache-${{ runner.os }}-${{ matrix.build }}-${{ matrix.fortran }}-${{ github.ref }}-${{ github.sha }} # Restore a matching ccache cache entry. Prefer same branch and same Fortran compiler. restore-keys: | - ccache-${{ runner.os }}-${{ matrix.build }}-${{ matrix.fortran }}-${{ github.ref }} - ccache-${{ runner.os }}-${{ matrix.build }}-${{ matrix.fortran }} + ccache-${{ runner.os }}-${{ matrix.build }}-${{ github.ref }} ccache-${{ runner.os }}-${{ matrix.build }} - name: Configure ccache From 349a4bf0462470dbdd132d3ecccc841037118e41 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 31 Jan 2024 19:23:59 +0100 Subject: [PATCH 03/22] Update f_check.cmake --- cmake/f_check.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/f_check.cmake b/cmake/f_check.cmake index df3a4858d1..4c4f5ac044 100644 --- a/cmake/f_check.cmake +++ b/cmake/f_check.cmake @@ -64,6 +64,7 @@ else () "#define NEEDBUNDERSCORE 1\n") endif() +if (CMAKE_Fortran_COMPILER) get_filename_component(F_COMPILER ${CMAKE_Fortran_COMPILER} NAME_WE) string(TOUPPER ${F_COMPILER} F_COMPILER) - +endif() From 478f3bfd8a89c0dbb9433f9fe75d4a491cf26eb8 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 15 Feb 2024 18:57:47 +0100 Subject: [PATCH 04/22] Add configurations --- .github/workflows/apple_m.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 357073ef39..2444a85e39 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -18,8 +18,10 @@ jobs: fail-fast: false matrix: build: [cmake, make] - - + fortran: [gfortran, flang-new] + openmp: [0, 1] + ilp64: [0, 1] + steps: - name: Checkout repository uses: actions/checkout@v3 @@ -43,6 +45,10 @@ jobs: # It looks like "gfortran" isn't working correctly unless "gcc" is re-installed. brew reinstall gcc brew install coreutils cmake ccache + brew install llvm + - export PATH=/opt/homebrew/opt/llvm/bin:$PATH + - export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" + - export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" else echo "::error::$RUNNER_OS not supported" exit 1 @@ -60,7 +66,7 @@ jobs: key: ccache-${{ runner.os }}-${{ matrix.build }}-${{ matrix.fortran }}-${{ github.ref }}-${{ github.sha }} # Restore a matching ccache cache entry. Prefer same branch and same Fortran compiler. restore-keys: | - ccache-${{ runner.os }}-${{ matrix.build }}-${{ github.ref }} + ccache-${{ runner.os }}-${{ matrix.build }}-${{{matrix.fortran }}-${{ github.ref }} ccache-${{ runner.os }}-${{ matrix.build }} - name: Configure ccache @@ -86,11 +92,13 @@ jobs: run: | case "${{ matrix.build }}" in "make") - make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=0 FC="ccache ${{ matrix.fortran }}" + make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=${{matrix.openmp}} INTERFACE64=${{matrix.ilp64}} FC="ccache ${{ matrix.fortran }}" ;; "cmake") mkdir build && cd build cmake -DDYNAMIC_ARCH=1 \ + -DUSE_OPENMP=${{matrix.openmp}} + -DINTERFACE64=${{matrix.ilp64}} -DNOFORTRAN=0 \ -DBUILD_WITHOUT_LAPACK=0 \ -DCMAKE_VERBOSE_MAKEFILE=ON \ From 648347acc7b98718dded2abb6719ae09c7f65f27 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 15 Feb 2024 20:54:20 +0100 Subject: [PATCH 05/22] Update apple_m.yml --- .github/workflows/apple_m.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 2444a85e39..ff8ebe827b 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -46,9 +46,6 @@ jobs: brew reinstall gcc brew install coreutils cmake ccache brew install llvm - - export PATH=/opt/homebrew/opt/llvm/bin:$PATH - - export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" - - export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" else echo "::error::$RUNNER_OS not supported" exit 1 @@ -90,6 +87,9 @@ jobs: - name: Build OpenBLAS run: | + export PATH=/opt/homebrew/opt/llvm/bin:$PATH + export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" + export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" case "${{ matrix.build }}" in "make") make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=${{matrix.openmp}} INTERFACE64=${{matrix.ilp64}} FC="ccache ${{ matrix.fortran }}" From fdfc642afd2cd953d81a0152bc724cff8131bd35 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 15 Feb 2024 20:56:07 +0100 Subject: [PATCH 06/22] Update apple_m.yml --- .github/workflows/apple_m.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index ff8ebe827b..238107be0d 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -63,7 +63,7 @@ jobs: key: ccache-${{ runner.os }}-${{ matrix.build }}-${{ matrix.fortran }}-${{ github.ref }}-${{ github.sha }} # Restore a matching ccache cache entry. Prefer same branch and same Fortran compiler. restore-keys: | - ccache-${{ runner.os }}-${{ matrix.build }}-${{{matrix.fortran }}-${{ github.ref }} + ccache-${{ runner.os }}-${{ matrix.build }}-${{matrix.fortran }}-${{ github.ref }} ccache-${{ runner.os }}-${{ matrix.build }} - name: Configure ccache From 2a446bd051d8380168ee56b5f9bc153f9422bd26 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 15 Feb 2024 22:14:10 +0100 Subject: [PATCH 07/22] Update apple_m.yml --- .github/workflows/apple_m.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 238107be0d..1aa9d72d0c 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -74,6 +74,8 @@ jobs: echo "/usr/lib/ccache" >> $GITHUB_PATH elif [ "$RUNNER_OS" = "macOS" ]; then echo "$(brew --prefix)/opt/ccache/libexec" >> $GITHUB_PATH + echo "/opt/homebrew/opt/llvm/bin" >>$GITHUB_PATH + echo "" >>$GITHUB_PATH else echo "::error::$RUNNER_OS not supported" exit 1 @@ -87,7 +89,6 @@ jobs: - name: Build OpenBLAS run: | - export PATH=/opt/homebrew/opt/llvm/bin:$PATH export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" case "${{ matrix.build }}" in @@ -95,7 +96,9 @@ jobs: make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=${{matrix.openmp}} INTERFACE64=${{matrix.ilp64}} FC="ccache ${{ matrix.fortran }}" ;; "cmake") - mkdir build && cd build + pwd + mkdir build + cd build cmake -DDYNAMIC_ARCH=1 \ -DUSE_OPENMP=${{matrix.openmp}} -DINTERFACE64=${{matrix.ilp64}} From dbfc521502a6bb19b9f404fd1cf4f058236e2b2e Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 15 Feb 2024 22:50:13 +0100 Subject: [PATCH 08/22] Update apple_m.yml --- .github/workflows/apple_m.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 1aa9d72d0c..3d4ed2b065 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -64,6 +64,7 @@ jobs: # Restore a matching ccache cache entry. Prefer same branch and same Fortran compiler. restore-keys: | ccache-${{ runner.os }}-${{ matrix.build }}-${{matrix.fortran }}-${{ github.ref }} + ccache-${{ runner.os }}-${{ matrix.build }}-${{matrix.fortran }} ccache-${{ runner.os }}-${{ matrix.build }} - name: Configure ccache @@ -91,17 +92,16 @@ jobs: run: | export LDFLAGS="-L/opt/homebrew/opt/llvm/lib" export CPPFLAGS="-I/opt/homebrew/opt/llvm/include" + export CC="/opt/homebrew/opt/llvm/bin/clang" case "${{ matrix.build }}" in "make") make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=${{matrix.openmp}} INTERFACE64=${{matrix.ilp64}} FC="ccache ${{ matrix.fortran }}" ;; "cmake") - pwd - mkdir build - cd build + mkdir build && cd build cmake -DDYNAMIC_ARCH=1 \ - -DUSE_OPENMP=${{matrix.openmp}} - -DINTERFACE64=${{matrix.ilp64}} + -DUSE_OPENMP=${{matrix.openmp}} \ + -DINTERFACE64=${{matrix.ilp64}} \ -DNOFORTRAN=0 \ -DBUILD_WITHOUT_LAPACK=0 \ -DCMAKE_VERBOSE_MAKEFILE=ON \ From df286958e2b43387f44794ce394494b56dde72cd Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 15 Feb 2024 23:42:03 +0100 Subject: [PATCH 09/22] try to work around xcode15 linker bug --- .github/workflows/apple_m.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 3d4ed2b065..05b0494278 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -98,6 +98,7 @@ jobs: make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=${{matrix.openmp}} INTERFACE64=${{matrix.ilp64}} FC="ccache ${{ matrix.fortran }}" ;; "cmake") + export LINKFLAGS="-ld_classic" mkdir build && cd build cmake -DDYNAMIC_ARCH=1 \ -DUSE_OPENMP=${{matrix.openmp}} \ From 6de899e75c91f88fda5da5c87fcfa37d0b109702 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 16 Feb 2024 07:48:49 +0100 Subject: [PATCH 10/22] Update apple_m.yml --- .github/workflows/apple_m.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 05b0494278..b62bef6530 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -98,7 +98,7 @@ jobs: make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=${{matrix.openmp}} INTERFACE64=${{matrix.ilp64}} FC="ccache ${{ matrix.fortran }}" ;; "cmake") - export LINKFLAGS="-ld_classic" + export LDFLAGS="-Wö,-ld_classic" mkdir build && cd build cmake -DDYNAMIC_ARCH=1 \ -DUSE_OPENMP=${{matrix.openmp}} \ From 3e6e6183b010b1d1c43893ef6da4d4f239bd07da Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 16 Feb 2024 09:45:45 +0100 Subject: [PATCH 11/22] Update apple_m.yml --- .github/workflows/apple_m.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index b62bef6530..9c27fe4d0b 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -98,7 +98,7 @@ jobs: make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=${{matrix.openmp}} INTERFACE64=${{matrix.ilp64}} FC="ccache ${{ matrix.fortran }}" ;; "cmake") - export LDFLAGS="-Wö,-ld_classic" + export LDFLAGS="-Wl,-ld_classic" mkdir build && cd build cmake -DDYNAMIC_ARCH=1 \ -DUSE_OPENMP=${{matrix.openmp}} \ From 42d35f1084a41170199ba18683b195972e38657e Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 16 Feb 2024 11:59:02 +0100 Subject: [PATCH 12/22] Update apple_m.yml --- .github/workflows/apple_m.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 9c27fe4d0b..3fbbf41f0c 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: build: [cmake, make] - fortran: [gfortran, flang-new] + fortran: [gfortran, /opt/homebrew/opt/llvm/bin/flang-new] openmp: [0, 1] ilp64: [0, 1] From ba4ea7bb07b7cc07b95577916018401a81946dcd Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 16 Feb 2024 15:41:46 +0100 Subject: [PATCH 13/22] Link OpenMP clang+gfortran builds with libomp --- test/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d68b12d87c..33bc7771ca 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,6 +25,13 @@ endif() foreach(test_bin ${OpenBLAS_Tests}) add_executable(${test_bin} ${test_bin}.f) target_link_libraries(${test_bin} ${OpenBLAS_LIBNAME}) +if (USE_OPENMP) +if (CMAKE_Fortran_COMPILER_ID STREQUAL GNU) +if (CMAKE_C_COMPILER_ID STREQUAL CLANG) +target_link_libraries(${test_bin} omp) +endif() +endif() +endif() endforeach() # $1 exec, $2 input, $3 output_result From a75dac6401baedec1e01a8f1dea1a672834ca8cf Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Fri, 16 Feb 2024 15:46:07 +0100 Subject: [PATCH 14/22] Link OpenMP clang+gfortran build with -lomp --- ctest/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt index 91338b73b6..90f62d6b05 100644 --- a/ctest/CMakeLists.txt +++ b/ctest/CMakeLists.txt @@ -43,6 +43,9 @@ endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX") target_link_libraries(x${float_char}cblat1 m) endif() + if (USE_OPENMP AND CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_ID STREQUAL CLANG) + target_link_libraries(${test_bin} omp) + endif() add_test(NAME "x${float_char}cblat1" COMMAND $) @@ -68,6 +71,9 @@ endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX") target_link_libraries(x${float_char}cblat2 m) endif() + if (USE_OPENMP AND CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_ID STREQUAL CLANG) + target_link_libraries(${test_bin} omp) + endif() add_test(NAME "x${float_char}cblat2" COMMAND ${test_helper} $ "${PROJECT_SOURCE_DIR}/ctest/${float_char}in2") @@ -93,6 +99,9 @@ endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX") target_link_libraries(x${float_char}cblat3 m) endif() + if (USE_OPENMP AND CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_ID STREQUAL CLANG) + target_link_libraries(${test_bin} omp) + endif() add_test(NAME "x${float_char}cblat3" COMMAND ${test_helper} $ "${PROJECT_SOURCE_DIR}/ctest/${float_char}in3") From 1510f05121f540d51434507154425037c947d3cc Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 17 Feb 2024 14:38:56 +0100 Subject: [PATCH 15/22] No flang-new in the homebrew LLVM --- .github/workflows/apple_m.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index 3fbbf41f0c..f6d13c9922 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: build: [cmake, make] - fortran: [gfortran, /opt/homebrew/opt/llvm/bin/flang-new] + fortran: [gfortran] openmp: [0, 1] ilp64: [0, 1] From 1a2f5872d9686198ecb628155d64905aa0995ceb Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 20 Feb 2024 20:52:03 +0100 Subject: [PATCH 16/22] Add files via upload --- ctest/CMakeLists.txt | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt index 90f62d6b05..6e0a7f309e 100644 --- a/ctest/CMakeLists.txt +++ b/ctest/CMakeLists.txt @@ -40,12 +40,13 @@ else() c_${float_char}blas1.c) endif() target_link_libraries(x${float_char}cblat1 ${OpenBLAS_LIBNAME}) + if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang)) + string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + target_link_libraries(x${float_char}cblat1 omp pthread) + endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX") target_link_libraries(x${float_char}cblat1 m) endif() - if (USE_OPENMP AND CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_ID STREQUAL CLANG) - target_link_libraries(${test_bin} omp) - endif() add_test(NAME "x${float_char}cblat1" COMMAND $) @@ -68,12 +69,13 @@ else() constant.c) endif() target_link_libraries(x${float_char}cblat2 ${OpenBLAS_LIBNAME}) + if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang)) + string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + target_link_libraries(x${float_char}cblat2 omp pthread) + endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX") target_link_libraries(x${float_char}cblat2 m) endif() - if (USE_OPENMP AND CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_ID STREQUAL CLANG) - target_link_libraries(${test_bin} omp) - endif() add_test(NAME "x${float_char}cblat2" COMMAND ${test_helper} $ "${PROJECT_SOURCE_DIR}/ctest/${float_char}in2") @@ -96,12 +98,13 @@ else() constant.c) endif() target_link_libraries(x${float_char}cblat3 ${OpenBLAS_LIBNAME}) + if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang)) + string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + target_link_libraries(x${float_char}cblat3 omp pthread) + endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX") target_link_libraries(x${float_char}cblat3 m) endif() - if (USE_OPENMP AND CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_ID STREQUAL CLANG) - target_link_libraries(${test_bin} omp) - endif() add_test(NAME "x${float_char}cblat3" COMMAND ${test_helper} $ "${PROJECT_SOURCE_DIR}/ctest/${float_char}in3") From 4254db7b789101a8b55603c973352c978720fae1 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 20 Feb 2024 20:52:43 +0100 Subject: [PATCH 17/22] Add files via upload --- test/CMakeLists.txt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 33bc7771ca..ace20dffce 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,16 +21,13 @@ endif() if (BUILD_COMPLEX16) list (APPEND OpenBLAS_Tests zblat1 zblat2 zblat3) endif() - +message (STATUS CCOMP ${CMAKE_C_COMPILER_ID} FCOMP ${CMAKE_Fortran_COMPILER_ID}) foreach(test_bin ${OpenBLAS_Tests}) add_executable(${test_bin} ${test_bin}.f) target_link_libraries(${test_bin} ${OpenBLAS_LIBNAME}) -if (USE_OPENMP) -if (CMAKE_Fortran_COMPILER_ID STREQUAL GNU) -if (CMAKE_C_COMPILER_ID STREQUAL CLANG) -target_link_libraries(${test_bin} omp) -endif() -endif() +if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang)) + string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") +target_link_libraries(${test_bin} omp pthread) endif() endforeach() From c0b1fdd83cc06f8d1dfd473d0516b99d73c40194 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 20 Feb 2024 22:42:12 +0100 Subject: [PATCH 18/22] Update apple_m.yml --- .github/workflows/apple_m.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apple_m.yml b/.github/workflows/apple_m.yml index f6d13c9922..e34eada86b 100644 --- a/.github/workflows/apple_m.yml +++ b/.github/workflows/apple_m.yml @@ -98,7 +98,7 @@ jobs: make -j$(nproc) DYNAMIC_ARCH=1 USE_OPENMP=${{matrix.openmp}} INTERFACE64=${{matrix.ilp64}} FC="ccache ${{ matrix.fortran }}" ;; "cmake") - export LDFLAGS="-Wl,-ld_classic" + export LDFLAGS="$LDFLAGS -Wl,-ld_classic" mkdir build && cd build cmake -DDYNAMIC_ARCH=1 \ -DUSE_OPENMP=${{matrix.openmp}} \ From 03fc5623fab25b9b89274b7cd2331928514e080e Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 20 Feb 2024 23:38:29 +0100 Subject: [PATCH 19/22] Update CMakeLists.txt --- lapack-netlib/TESTING/EIG/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lapack-netlib/TESTING/EIG/CMakeLists.txt b/lapack-netlib/TESTING/EIG/CMakeLists.txt index e7236677ae..b694178532 100644 --- a/lapack-netlib/TESTING/EIG/CMakeLists.txt +++ b/lapack-netlib/TESTING/EIG/CMakeLists.txt @@ -107,6 +107,10 @@ set(ZDMDEIGTST zchkdmd.f90) macro(add_eig_executable name) add_executable(${name} ${ARGN}) target_link_libraries(${name} openblas${SUFFIX64_UNDERSCORE}) +if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang)) + string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") +target_link_libraries(${name} omp pthread) +endif() #${TMGLIB} ../${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) endmacro() From 5c5f1dddc605b40c1878cf6daa2e2138b2bfe546 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 20 Feb 2024 23:39:54 +0100 Subject: [PATCH 20/22] Update CMakeLists.txt --- lapack-netlib/TESTING/LIN/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lapack-netlib/TESTING/LIN/CMakeLists.txt b/lapack-netlib/TESTING/LIN/CMakeLists.txt index 143fd05972..9ae0cea795 100644 --- a/lapack-netlib/TESTING/LIN/CMakeLists.txt +++ b/lapack-netlib/TESTING/LIN/CMakeLists.txt @@ -240,6 +240,10 @@ set(ZLINTSTRFP zchkrfp.f zdrvrfp.f zdrvrf1.f zdrvrf2.f zdrvrf3.f zdrvrf4.f zerrr macro(add_lin_executable name) add_executable(${name} ${ARGN}) target_link_libraries(${name} openblas${SUFFIX64_UNDERSCORE}) + if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang)) + string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") + target_link_libraries(${name} omp pthread) + endif() #${TMGLIB} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) endmacro() From 251dcd2bc5a093186b5d7cea11faec3d7ea235b1 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 21 Feb 2024 23:41:16 +0100 Subject: [PATCH 21/22] fix missing INTERFACE64 setting for gfortran --- cmake/fc.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/fc.cmake b/cmake/fc.cmake index 5c30be843c..43949917c1 100644 --- a/cmake/fc.cmake +++ b/cmake/fc.cmake @@ -50,6 +50,9 @@ if (${F_COMPILER} STREQUAL "GFORTRAN" OR ${F_COMPILER} STREQUAL "F95" OR CMAKE_F # Don't include -lgfortran, when NO_LAPACK=1 or lsbcc set(EXTRALIB "${EXTRALIB} -lgfortran") endif () + if (INTERFACE64) + set(FCOMMON_OPT "${FCOMMON_OPT} -fdefault-integer-8") + endif () endif () if (NO_BINARY_MODE) if (MIPS64) From a8b7ba972068511a4bc2b01f98a441100c57a271 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 22 Feb 2024 20:07:47 +0100 Subject: [PATCH 22/22] Update fc.cmake --- cmake/fc.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/fc.cmake b/cmake/fc.cmake index 43949917c1..2ebeaed828 100644 --- a/cmake/fc.cmake +++ b/cmake/fc.cmake @@ -6,9 +6,6 @@ if (${F_COMPILER} STREQUAL "FLANG" AND NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang") # This is for classic Flang. LLVM Flang is handled with gfortran below. set(CCOMMON_OPT "${CCOMMON_OPT} -DF_INTERFACE_FLANG") - if (BINARY64 AND INTERFACE64) - set(FCOMMON_OPT "${FCOMMON_OPT} -i8") - endif () if (USE_OPENMP) set(FCOMMON_OPT "${FCOMMON_OPT} -fopenmp") endif () @@ -58,6 +55,9 @@ if (${F_COMPILER} STREQUAL "GFORTRAN" OR ${F_COMPILER} STREQUAL "F95" OR CMAKE_F if (MIPS64) if (BINARY64) set(FCOMMON_OPT "${FCOMMON_OPT} -mabi=64") + if (INTERFACE64) + set(FCOMMON_OPT "${FCOMMON_OPT} -fdefault-integer-8") + endif () else () set(FCOMMON_OPT "${FCOMMON_OPT} -mabi=n32") endif () @@ -86,6 +86,9 @@ if (${F_COMPILER} STREQUAL "GFORTRAN" OR ${F_COMPILER} STREQUAL "F95" OR CMAKE_F endif () endif () endif () + if (ARM64 AND INTERFACE64) + set(FCOMMON_OPT "${FCOMMON_OPT} -fdefault-integer-8") + endif () else () if (BINARY64) set(FCOMMON_OPT "${FCOMMON_OPT} -m64")