Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MacOS with ARM CPUs (CMake + GitHub Action) #25

Draft
wants to merge 24 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
639f0d2
First draft of macOS support in CMakeLists and Github Actions recipe …
siggmo Oct 4, 2024
28b16b6
fix typo in FFTW package name for brew
siggmo Oct 4, 2024
06fed09
Rename macOS workflow to not clash with the Ubuntu workflow
siggmo Oct 4, 2024
5670265
test if OpenMP is really required at all
siggmo Oct 4, 2024
f3e52ea
Remove not used dependency OpenMP
siggmo Oct 4, 2024
2a9ccbd
Merge branch 'bugfix/remove-openmp-dependency' into feature/macOS_M1_…
siggmo Oct 4, 2024
6cfc2a0
Test if setting C++ standard to 11 helps with the whitespace required…
siggmo Oct 4, 2024
9d3970b
Test if setting C++ standard to 14 helps with auto not allowed in lam…
siggmo Oct 4, 2024
05272cd
Test brew hdf5 package without mpi
siggmo Oct 4, 2024
ffd4955
Add macOS installation instructions
siggmo Oct 4, 2024
32bd02a
Test both brew packages hdf5 and hdf5-mpi at the same time (conflicti…
siggmo Oct 4, 2024
8672551
Revert "Test both brew packages hdf5 and hdf5-mpi at the same time (c…
siggmo Oct 4, 2024
120f4a4
Add libomp to macOS dependency installation instructions
siggmo Oct 9, 2024
9415190
Merge branch 'develop' into feature/macOS_M1_support
siggmo Oct 9, 2024
026dffe
Revert "Remove not used dependency OpenMP"
siggmo Oct 9, 2024
8e72fd2
Add libomp to github action
siggmo Oct 9, 2024
ec0c126
Set OpenMP_ROOT in github action recipe to enable CMake on macOS to f…
siggmo Oct 9, 2024
b82d5d9
test explicit path to libomp instead
siggmo Oct 9, 2024
7164b6e
Revert "test explicit path to libomp instead"
siggmo Oct 9, 2024
7323793
Merge branch 'develop' into feature/macOS_M1_support
siggmo Oct 9, 2024
019fcde
try another fix for OpenMP problem
siggmo Oct 9, 2024
c8bd9a9
add missing backslash in multiline command
siggmo Oct 9, 2024
f6a550d
remove cmake from brew install commands as it's included in macos-14 …
siggmo Oct 9, 2024
cc551c4
Mention OpenMP macOS issue with CMake in the README
siggmo Oct 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/build_and_test-mac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build and Test macOS 14 (M1)
# 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 openmpi eigen fftw

- 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
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include(CMakePackageConfigHelpers)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
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
Expand Down Expand Up @@ -56,7 +57,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}/")
Expand All @@ -81,8 +86,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)
Expand Down Expand Up @@ -175,8 +178,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)

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion cmake/FANSConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to be unrelated to this pull request. Please revert.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is part of the remove OpenMP dependency PR. I merged it into this PR to make it work temporarily.

find_dependency(MPI)
find_dependency(FFTW3 COMPONENTS DOUBLE MPI)

Expand Down
Loading