From 639f0d26cd45d55ac40042c90ea50a504944a7dd Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 17:15:50 +0200 Subject: [PATCH 01/28] First draft of macOS support in CMakeLists and Github Actions recipe for build and test --- .github/workflows/build_and_test-mac.yaml | 71 +++++++++++++++++++++++ CMakeLists.txt | 6 +- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build_and_test-mac.yaml diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml new file mode 100644 index 0000000..8ccb880 --- /dev/null +++ b/.github/workflows/build_and_test-mac.yaml @@ -0,0 +1,71 @@ +name: Build and Test +# Builds FANS for macOS 14 on M1 CPU and runs the tests. + +on: + push: + branches: + - main + - develop + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{github.event_name == 'pull_request'}} + +jobs: + build: + name: macOS 14 (M1) + runs-on: macos-14 + env: + FANS_BUILD_DIR: build + strategy: + fail-fast: false + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install FANS dependencies + run: brew install cmake hdf5-mpi openmpi eigen fttw + + - name: Generate build directory + run: mkdir -p ${{ env.FANS_BUILD_DIR }} + + - name: Configure + working-directory: ${{ env.FANS_BUILD_DIR }} + run: | + cmake --version + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. + + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: macOS 14 (M1) CMakeCache + path: ${{ env.FANS_BUILD_DIR }}/CMakeCache.txt + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: macOS 14 (M1) CMakeLogs + path: '${{ env.FANS_BUILD_DIR }}/CMakeFiles/*.log' + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: macOS 14 (M1) CompileCommands + path: ${{ env.FANS_BUILD_DIR }}/compile_commands.json + + - name: Compile + working-directory: ${{ env.FANS_BUILD_DIR }} + run: + cmake --build . -j $(nproc) || cmake --build . -j1 + + - name: Tests + working-directory: ${{ env.FANS_BUILD_DIR }} + env: + CTEST_OUTPUT_ON_FAILURE: 1 + run: ctest + + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: macOS 14 (M1) CTest logs + path: ${{ env.FANS_BUILD_DIR }}/Testing/Temporary/LastTest.log diff --git a/CMakeLists.txt b/CMakeLists.txt index 1918e68..6bc6f64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,11 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # From https://stackoverflow.com/questions/73248130/how-to-avoid-the-removal-of-the-rpath-during-cmake-install-step # Set RPATH to be relative and honor user overrides, whether at the command line or FetchContent -set(RPATH_BASE "$ORIGIN") +if(APPLE) + set(RPATH_BASE "@loader_path") +else() + set(RPATH_BASE "$ORIGIN") +endif() file(RELATIVE_PATH REL_PATH_LIB "/${CMAKE_INSTALL_BINDIR}/" "/${CMAKE_INSTALL_LIBDIR}/") From 28b16b600c5430b9bbe9ba314f44fcea71ffea1c Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 17:21:31 +0200 Subject: [PATCH 02/28] fix typo in FFTW package name for brew --- .github/workflows/build_and_test-mac.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index 8ccb880..9477ca1 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: brew install cmake hdf5-mpi openmpi eigen fttw + run: brew install cmake hdf5-mpi openmpi eigen fftw - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From 06fed0915a73c88e98107adfbe3f5d3e87d90bd3 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 17:24:03 +0200 Subject: [PATCH 03/28] Rename macOS workflow to not clash with the Ubuntu workflow --- .github/workflows/build_and_test-mac.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index 9477ca1..fbeb96b 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -1,4 +1,4 @@ -name: Build and Test +name: Build and Test macOS 14 (M1) # Builds FANS for macOS 14 on M1 CPU and runs the tests. on: From 5670265fc3ffe4dbc985cef3dc96c5eba3e1e93c Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 17:29:04 +0200 Subject: [PATCH 04/28] test if OpenMP is really required at all --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bc6f64..960b42e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ find_package(HDF5 REQUIRED COMPONENTS CXX) find_package(Eigen3 REQUIRED) -find_package(OpenMP REQUIRED) +# find_package(OpenMP REQUIRED) find_package(MPI REQUIRED) From f3e52ea5afecce409d52193bf7380ad9814aa724 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 17:37:17 +0200 Subject: [PATCH 05/28] Remove not used dependency OpenMP --- CMakeLists.txt | 4 ---- cmake/FANSConfig.cmake.in | 1 - 2 files changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1918e68..828fa8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,8 +81,6 @@ find_package(HDF5 REQUIRED COMPONENTS CXX) find_package(Eigen3 REQUIRED) -find_package(OpenMP REQUIRED) - find_package(MPI REQUIRED) find_package(FFTW3 REQUIRED COMPONENTS DOUBLE MPI) @@ -175,8 +173,6 @@ target_compile_definitions(FANS_FANS PUBLIC ${FFTW3_DEFINITIONS}) target_link_libraries(FANS_FANS PUBLIC Eigen3::Eigen) -target_link_libraries(FANS_FANS PUBLIC OpenMP::OpenMP_CXX) - target_link_libraries(FANS_main PRIVATE FANS::FANS) diff --git a/cmake/FANSConfig.cmake.in b/cmake/FANSConfig.cmake.in index 86ffcbd..1bb55c3 100644 --- a/cmake/FANSConfig.cmake.in +++ b/cmake/FANSConfig.cmake.in @@ -18,7 +18,6 @@ if (NOT HDF5_C_IS_PARALLEL) message(FATAL_ERROR "Parallel HDF5 implementation (mpi) required but not found!") endif() find_dependency(Eigen3) -find_dependency(OpenMP) find_dependency(MPI) find_dependency(FFTW3 COMPONENTS DOUBLE MPI) From 6cfc2a00cde05371f26995ccd82a080d705deab5 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 17:50:36 +0200 Subject: [PATCH 06/28] Test if setting C++ standard to 11 helps with the whitespace required error --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54f8d8a..3af8034 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ include(CMakePackageConfigHelpers) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD 11) # with -fno-implicit-templates I get linker errors when using std:: stuff # TODO: should be developer specific, by using e.g. CMake Presets From 9d3970b18654cc5c9e52057d6512634093d72bd2 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 17:52:51 +0200 Subject: [PATCH 07/28] Test if setting C++ standard to 14 helps with auto not allowed in lambda parameter --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3af8034..0eab86d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(CMakePackageConfigHelpers) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 14) # with -fno-implicit-templates I get linker errors when using std:: stuff # TODO: should be developer specific, by using e.g. CMake Presets From 05272cd9cd0cd1809bf84b75eb32794945ba76a7 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 17:58:50 +0200 Subject: [PATCH 08/28] Test brew hdf5 package without mpi --- .github/workflows/build_and_test-mac.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index fbeb96b..c90a175 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: brew install cmake hdf5-mpi openmpi eigen fftw + run: brew install cmake hdf5 openmpi eigen fftw - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From ffd49559c04003db76cd9a7177cbd85fdb955ed9 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 18:12:41 +0200 Subject: [PATCH 09/28] Add macOS installation instructions --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 2c56764..0d4c0e3 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,17 @@ apt-get install \ libfftw3-mpi-dev ``` +On macOS you can obtain the dependencies using `brew`: + +```zsh +brew install \ + cmake \ + hdf5 \ + openmpi \ + eigen \ + fftw +``` + Also, we recommend to set up a Python virtual environment for the `FANS_Dashboard`: ```bash From 32bd02ac947d8bc878fa1844d9ae8c4ee83cedd7 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 18:17:09 +0200 Subject: [PATCH 10/28] Test both brew packages hdf5 and hdf5-mpi at the same time (conflicting?) --- .github/workflows/build_and_test-mac.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index c90a175..1d1707c 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: brew install cmake hdf5 openmpi eigen fftw + run: brew install cmake hdf5 hdf5-mpi openmpi eigen fftw - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From 8672551f99c03529bfc45fd8f5c30a1a2b5f8479 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Fri, 4 Oct 2024 18:19:04 +0200 Subject: [PATCH 11/28] Revert "Test both brew packages hdf5 and hdf5-mpi at the same time (conflicting?)" This reverts commit 32bd02ac947d8bc878fa1844d9ae8c4ee83cedd7. --- .github/workflows/build_and_test-mac.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index 1d1707c..c90a175 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: brew install cmake hdf5 hdf5-mpi openmpi eigen fftw + run: brew install cmake hdf5 openmpi eigen fftw - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From 120f4a4453bff6a65b30bf9e9fcfd5e5ec880956 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 12:31:04 +0200 Subject: [PATCH 12/28] Add libomp to macOS dependency installation instructions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0d4c0e3..0d8ecd1 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,11 @@ apt-get install \ libfftw3-mpi-dev ``` -On macOS you can obtain the dependencies using `brew`: +On macOS, you can obtain the dependencies using `brew`. Since Clang is the preferred compiler on macOS, you'll need the `libomp` package to enable OpenMP support: ```zsh brew install \ - cmake \ + libomp \ hdf5 \ openmpi \ eigen \ From 026dffef38e2c74a5dc48de72fb1d202afdf86fb Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 12:32:13 +0200 Subject: [PATCH 13/28] Revert "Remove not used dependency OpenMP" This reverts commit f3e52ea5afecce409d52193bf7380ad9814aa724. --- CMakeLists.txt | 4 ++++ cmake/FANSConfig.cmake.in | 1 + 2 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eab86d..ec377ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,8 @@ find_package(HDF5 REQUIRED COMPONENTS CXX) find_package(Eigen3 REQUIRED) +find_package(OpenMP REQUIRED) + find_package(MPI REQUIRED) find_package(FFTW3 REQUIRED COMPONENTS DOUBLE MPI) @@ -178,6 +180,8 @@ target_compile_definitions(FANS_FANS PUBLIC ${FFTW3_DEFINITIONS}) target_link_libraries(FANS_FANS PUBLIC Eigen3::Eigen) +target_link_libraries(FANS_FANS PUBLIC OpenMP::OpenMP_CXX) + target_link_libraries(FANS_main PRIVATE FANS::FANS) diff --git a/cmake/FANSConfig.cmake.in b/cmake/FANSConfig.cmake.in index 1bb55c3..86ffcbd 100644 --- a/cmake/FANSConfig.cmake.in +++ b/cmake/FANSConfig.cmake.in @@ -18,6 +18,7 @@ if (NOT HDF5_C_IS_PARALLEL) message(FATAL_ERROR "Parallel HDF5 implementation (mpi) required but not found!") endif() find_dependency(Eigen3) +find_dependency(OpenMP) find_dependency(MPI) find_dependency(FFTW3 COMPONENTS DOUBLE MPI) From 8e72fd21532c9694cf5882581d4f5d870a0aee4f Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 12:33:12 +0200 Subject: [PATCH 14/28] Add libomp to github action --- .github/workflows/build_and_test-mac.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index c90a175..530319d 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: brew install cmake hdf5 openmpi eigen fftw + run: brew install libomp cmake hdf5 openmpi eigen fftw - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From ec0c126b75b3d784be06ab5e90d55522670ea659 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 12:36:14 +0200 Subject: [PATCH 15/28] Set OpenMP_ROOT in github action recipe to enable CMake on macOS to find OpenMP --- .github/workflows/build_and_test-mac.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index 530319d..d787c6b 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -26,7 +26,9 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: brew install libomp cmake hdf5 openmpi eigen fftw + run: | + brew install libomp cmake hdf5 openmpi eigen fftw + export OpenMP_ROOT=$(brew --prefix)/opt/libomp - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From b82d5d94f9eaa73d13c2d39011f097c1e6ee1729 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 12:41:29 +0200 Subject: [PATCH 16/28] test explicit path to libomp instead --- .github/workflows/build_and_test-mac.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index d787c6b..0ecf00b 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -14,7 +14,7 @@ concurrency: cancel-in-progress: ${{github.event_name == 'pull_request'}} jobs: - build: + build-macOS: name: macOS 14 (M1) runs-on: macos-14 env: @@ -28,7 +28,7 @@ jobs: - name: Install FANS dependencies run: | brew install libomp cmake hdf5 openmpi eigen fftw - export OpenMP_ROOT=$(brew --prefix)/opt/libomp + export OpenMP_ROOT=/opt/homebrew/opt/libomp - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From 7164b6e750e647f4436eff028642050daed8ac93 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 12:43:08 +0200 Subject: [PATCH 17/28] Revert "test explicit path to libomp instead" This reverts commit b82d5d94f9eaa73d13c2d39011f097c1e6ee1729. --- .github/workflows/build_and_test-mac.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index 0ecf00b..d787c6b 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -14,7 +14,7 @@ concurrency: cancel-in-progress: ${{github.event_name == 'pull_request'}} jobs: - build-macOS: + build: name: macOS 14 (M1) runs-on: macos-14 env: @@ -28,7 +28,7 @@ jobs: - name: Install FANS dependencies run: | brew install libomp cmake hdf5 openmpi eigen fftw - export OpenMP_ROOT=/opt/homebrew/opt/libomp + export OpenMP_ROOT=$(brew --prefix)/opt/libomp - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From 019fcdeaf3f38959473023c5e6a11a77c50a72de Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 15:05:22 +0200 Subject: [PATCH 18/28] try another fix for OpenMP problem --- .github/workflows/build_and_test-mac.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index d787c6b..01b9cde 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -26,9 +26,7 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: | - brew install libomp cmake hdf5 openmpi eigen fftw - export OpenMP_ROOT=$(brew --prefix)/opt/libomp + run: brew install libomp cmake hdf5 openmpi eigen fftw - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} @@ -37,7 +35,17 @@ jobs: working-directory: ${{ env.FANS_BUILD_DIR }} run: | cmake --version - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DOpenMP_CXX_FLAG="-Xclang -fopenmp" + -DOpenMP_CXX_INCLUDE_DIR=$(brew --prefix)/opt/libomp/include \ + -DOpenMP_CXX_LIB_NAMES=libomp \ + -DOpenMP_C_FLAG="-Xclang -fopenmp" \ + -DOpenMP_C_INCLUDE_DIR=$(brew --prefix)/opt/libomp/include \ + -DOpenMP_C_LIB_NAMES=libomp \ + -DOpenMP_libomp_LIBRARY=$(brew --prefix)/opt/libomp/lib/libomp.dylib \ + .. - uses: actions/upload-artifact@v4 if: failure() From c8bd9a9ad0430478062526f8443c0999cf82e119 Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 15:06:31 +0200 Subject: [PATCH 19/28] add missing backslash in multiline command --- .github/workflows/build_and_test-mac.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index 01b9cde..ac730b0 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -38,7 +38,7 @@ jobs: cmake \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DOpenMP_CXX_FLAG="-Xclang -fopenmp" + -DOpenMP_CXX_FLAG="-Xclang -fopenmp" \ -DOpenMP_CXX_INCLUDE_DIR=$(brew --prefix)/opt/libomp/include \ -DOpenMP_CXX_LIB_NAMES=libomp \ -DOpenMP_C_FLAG="-Xclang -fopenmp" \ From f6a550d4f9d5a14c39f821139f24b75f5ddfcb0e Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 15:08:44 +0200 Subject: [PATCH 20/28] remove cmake from brew install commands as it's included in macos-14 runner anyway --- .github/workflows/build_and_test-mac.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index ac730b0..8966999 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -26,7 +26,7 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: brew install libomp cmake hdf5 openmpi eigen fftw + run: brew install libomp hdf5 openmpi eigen fftw - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} From cc551c48efa0e88053d896bd8791d65bee5bf38f Mon Sep 17 00:00:00 2001 From: Moritz Sigg Date: Wed, 9 Oct 2024 15:13:27 +0200 Subject: [PATCH 21/28] Mention OpenMP macOS issue with CMake in the README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index bed645a..0abbd0f 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ brew install \ fftw ``` +If you're facing problems regarding CMake and OpenMP, have a look at this [CMake issue](https://gitlab.kitware.com/cmake/cmake/-/issues/24097) providing a workaround, and this [thread](https://discourse.cmake.org/t/how-to-find-openmp-with-clang-on-macos/8860) in the CMake forums also discussing the issue. + Also, we recommend to set up a Python virtual environment for the `FANS_Dashboard`: ```bash From d7aede701f52a5a72db4502dcf9d2cce8a2f9eb9 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 2 May 2025 13:51:48 +0200 Subject: [PATCH 22/28] Do not set C++14 standard --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb30f8d..9720f35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(CMakePackageConfigHelpers) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 14) +#set(CMAKE_CXX_STANDARD 14) # with -fno-implicit-templates I get linker errors when using std:: stuff # TODO: should be developer specific, by using e.g. CMake Presets From 8e101df4d7134cf500658e2018ee05d157b23385 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 2 May 2025 14:00:41 +0200 Subject: [PATCH 23/28] Try using the macos-15 image, and set C++11 standard --- .github/workflows/build_and_test-mac.yaml | 6 +++--- CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test-mac.yaml index 8966999..3c6cc96 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test-mac.yaml @@ -14,9 +14,9 @@ concurrency: cancel-in-progress: ${{github.event_name == 'pull_request'}} jobs: - build: - name: macOS 14 (M1) - runs-on: macos-14 + build-macos: + name: macOS 15 (M1) + runs-on: macos-15 env: FANS_BUILD_DIR: build strategy: diff --git a/CMakeLists.txt b/CMakeLists.txt index 9720f35..74adf6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(CMakePackageConfigHelpers) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -#set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 11) # with -fno-implicit-templates I get linker errors when using std:: stuff # TODO: should be developer specific, by using e.g. CMake Presets From 26ddbbb2c9aa7ae73a81d72c259cb9ebe69d87e1 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 2 May 2025 14:04:34 +0200 Subject: [PATCH 24/28] Do not set any C++ standard in the CMakeLists --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74adf6b..9720f35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ include(CMakePackageConfigHelpers) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD 11) +#set(CMAKE_CXX_STANDARD 14) # with -fno-implicit-templates I get linker errors when using std:: stuff # TODO: should be developer specific, by using e.g. CMake Presets From a011ff5f185e706bf27579d133f45c2144aba61d Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 2 May 2025 14:26:59 +0200 Subject: [PATCH 25/28] Rename file and workflow --- ...build_and_test-mac.yaml => build_and_test_mac.yaml} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename .github/workflows/{build_and_test-mac.yaml => build_and_test_mac.yaml} (91%) diff --git a/.github/workflows/build_and_test-mac.yaml b/.github/workflows/build_and_test_mac.yaml similarity index 91% rename from .github/workflows/build_and_test-mac.yaml rename to .github/workflows/build_and_test_mac.yaml index 3c6cc96..d1fc7ba 100644 --- a/.github/workflows/build_and_test-mac.yaml +++ b/.github/workflows/build_and_test_mac.yaml @@ -1,4 +1,4 @@ -name: Build and Test macOS 14 (M1) +name: Build and test macOS 15 (M1) # Builds FANS for macOS 14 on M1 CPU and runs the tests. on: @@ -50,17 +50,17 @@ jobs: - uses: actions/upload-artifact@v4 if: failure() with: - name: macOS 14 (M1) CMakeCache + name: macOS 15 (M1) CMakeCache path: ${{ env.FANS_BUILD_DIR }}/CMakeCache.txt - uses: actions/upload-artifact@v4 if: failure() with: - name: macOS 14 (M1) CMakeLogs + name: macOS 15 (M1) CMakeLogs path: '${{ env.FANS_BUILD_DIR }}/CMakeFiles/*.log' - uses: actions/upload-artifact@v4 if: failure() with: - name: macOS 14 (M1) CompileCommands + name: macOS 15 (M1) CompileCommands path: ${{ env.FANS_BUILD_DIR }}/compile_commands.json - name: Compile @@ -77,5 +77,5 @@ jobs: - uses: actions/upload-artifact@v4 if: failure() with: - name: macOS 14 (M1) CTest logs + name: macOS 15 (M1) CTest logs path: ${{ env.FANS_BUILD_DIR }}/Testing/Temporary/LastTest.log From e80b36e343329e819ad70217c33bdef3ecbb2f93 Mon Sep 17 00:00:00 2001 From: ac133718 Date: Fri, 2 May 2025 18:37:18 +0200 Subject: [PATCH 26/28] first native macos build config --- .github/workflows/build_and_test_mac.yaml | 21 +++++++++------------ CMakeLists.txt | 2 +- README.md | 13 ++++--------- include/general.h | 18 ++++++++++++------ test/run_tests.sh | 11 +++++++---- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build_and_test_mac.yaml b/.github/workflows/build_and_test_mac.yaml index d1fc7ba..9999afe 100644 --- a/.github/workflows/build_and_test_mac.yaml +++ b/.github/workflows/build_and_test_mac.yaml @@ -26,7 +26,10 @@ jobs: uses: actions/checkout@v4 - name: Install FANS dependencies - run: brew install libomp hdf5 openmpi eigen fftw + run: | + brew install gnu-time cmake gcc@14 + brew install open-mpi --build-from-source --cc=gcc-14 + brew install fftw hdf5-mpi eigen - name: Generate build directory run: mkdir -p ${{ env.FANS_BUILD_DIR }} @@ -35,17 +38,11 @@ jobs: working-directory: ${{ env.FANS_BUILD_DIR }} run: | cmake --version - cmake \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DOpenMP_CXX_FLAG="-Xclang -fopenmp" \ - -DOpenMP_CXX_INCLUDE_DIR=$(brew --prefix)/opt/libomp/include \ - -DOpenMP_CXX_LIB_NAMES=libomp \ - -DOpenMP_C_FLAG="-Xclang -fopenmp" \ - -DOpenMP_C_INCLUDE_DIR=$(brew --prefix)/opt/libomp/include \ - -DOpenMP_C_LIB_NAMES=libomp \ - -DOpenMP_libomp_LIBRARY=$(brew --prefix)/opt/libomp/lib/libomp.dylib \ - .. + cmake .. \ + -DCMAKE_C_COMPILER=gcc-14 \ + -DCMAKE_CXX_COMPILER=g++-14 \ + -DMPI_C_COMPILER=mpicc \ + -DMPI_CXX_COMPILER=mpicxx - uses: actions/upload-artifact@v4 if: failure() diff --git a/CMakeLists.txt b/CMakeLists.txt index b77bd71..592bfa0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ endif () add_library(FANS::FANS ALIAS FANS_FANS) if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64") - target_compile_options(FANS_FANS PUBLIC -march=armv8-a+simd+fp+crypto) + elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") # Detecting if there is avx2 and fma support on linux # Deteced together, because these flags were introduced by Intel Haskell 4th. Gen diff --git a/README.md b/README.md index 842ed7c..fada561 100644 --- a/README.md +++ b/README.md @@ -37,19 +37,14 @@ apt-get install \ libfftw3-mpi-dev ``` -On macOS, you can obtain the dependencies using `brew`. Since Clang is the preferred compiler on macOS, you'll need the `libomp` package to enable OpenMP support: +On macOS, you can obtain the dependencies using `brew`. ```zsh -brew install \ - libomp \ - hdf5 \ - openmpi \ - eigen \ - fftw +brew install gnu-time cmake gcc@14 +brew install open-mpi --build-from-source --cc=gcc-14 +brew install fftw hdf5-mpi eigen ``` -If you're facing problems regarding CMake and OpenMP, have a look at this [CMake issue](https://gitlab.kitware.com/cmake/cmake/-/issues/24097) providing a workaround, and this [thread](https://discourse.cmake.org/t/how-to-find-openmp-with-clang-on-macos/8860) in the CMake forums also discussing the issue. - Also, we recommend to set up a Python virtual environment for the `FANS_Dashboard`: ```bash diff --git a/include/general.h b/include/general.h index 395d089..c7bad72 100644 --- a/include/general.h +++ b/include/general.h @@ -41,14 +41,20 @@ using namespace Eigen; #define FANS_MALLOC_H /* Usage: V *data = FANS_malloc(n); */ - template -inline V *FANS_malloc(size_t n) +inline V* FANS_malloc(std::size_t n) { - // V* out = new V[n]; - V *out = (V *) aligned_alloc(4 * sizeof(V), n * sizeof(V)); - - return out; + if (n == 0) + throw std::invalid_argument("FANS_malloc: zero-byte request"); + void* p = fftw_malloc(n * sizeof(V)); // SIMD-friendly alignment + if (!p) + throw std::bad_alloc(); + return static_cast(p); +} +template +inline void FANS_free(V* p) +{ + fftw_free(p); } #endif // FANS_MALLOC_H diff --git a/test/run_tests.sh b/test/run_tests.sh index ef95e54..5e50e25 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -8,11 +8,14 @@ fi num_processes=$2 +TIME_CMD="command time -v" +[[ "$OSTYPE" == "darwin"* ]] && TIME_CMD="command gtime -v" + # Run the jobs serially -command time -v mpiexec -n $num_processes ./FANS input_files/test_LinearThermal.json test_LinearThermal.h5 > test_LinearThermal.log 2>&1 +$TIME_CMD mpiexec -n $num_processes ./FANS input_files/test_LinearThermal.json test_LinearThermal.h5 > test_LinearThermal.log 2>&1 -command time -v mpiexec -n $num_processes ./FANS input_files/test_LinearElastic.json test_LinearElastic.h5 > test_LinearElastic.log 2>&1 +$TIME_CMD mpiexec -n $num_processes ./FANS input_files/test_LinearElastic.json test_LinearElastic.h5 > test_LinearElastic.log 2>&1 -command time -v mpiexec -n $num_processes ./FANS input_files/test_PseudoPlastic.json test_PseudoPlastic.h5 > test_PseudoPlastic.log 2>&1 +$TIME_CMD mpiexec -n $num_processes ./FANS input_files/test_PseudoPlastic.json test_PseudoPlastic.h5 > test_PseudoPlastic.log 2>&1 -command time -v mpiexec -n $num_processes ./FANS input_files/test_J2Plasticity.json test_J2Plasticity.h5 > test_J2Plasticity.log 2>&1 +$TIME_CMD mpiexec -n $num_processes ./FANS input_files/test_J2Plasticity.json test_J2Plasticity.h5 > test_J2Plasticity.log 2>&1 From ade29fe19f0c95dc59924cd01fa67fc1d243c251 Mon Sep 17 00:00:00 2001 From: ac133718 Date: Fri, 2 May 2025 19:01:37 +0200 Subject: [PATCH 27/28] Empty-Commit From f85d2b8ea387c10e2b11c74672f780159ab06ede Mon Sep 17 00:00:00 2001 From: ac133718 Date: Fri, 2 May 2025 19:02:44 +0200 Subject: [PATCH 28/28] manual pre-commit trigger --- CMakeLists.txt | 2 +- include/general.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 592bfa0..07f456e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ endif () add_library(FANS::FANS ALIAS FANS_FANS) if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch64") - + elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") # Detecting if there is avx2 and fma support on linux # Deteced together, because these flags were introduced by Intel Haskell 4th. Gen diff --git a/include/general.h b/include/general.h index c7bad72..62c9d2c 100644 --- a/include/general.h +++ b/include/general.h @@ -42,17 +42,17 @@ using namespace Eigen; /* Usage: V *data = FANS_malloc(n); */ template -inline V* FANS_malloc(std::size_t n) +inline V *FANS_malloc(std::size_t n) { if (n == 0) throw std::invalid_argument("FANS_malloc: zero-byte request"); - void* p = fftw_malloc(n * sizeof(V)); // SIMD-friendly alignment + void *p = fftw_malloc(n * sizeof(V)); // SIMD-friendly alignment if (!p) throw std::bad_alloc(); - return static_cast(p); + return static_cast(p); } template -inline void FANS_free(V* p) +inline void FANS_free(V *p) { fftw_free(p); }