From e513b06688e983e202719058dcd0f4aab60b46b0 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan <583379+adrn@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:31:34 -0400 Subject: [PATCH 1/3] test a workflow for building EXP on Mac --- .github/workflows/build-mac.yml | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/build-mac.yml diff --git a/.github/workflows/build-mac.yml b/.github/workflows/build-mac.yml new file mode 100644 index 000000000..c84822cd4 --- /dev/null +++ b/.github/workflows/build-mac.yml @@ -0,0 +1,69 @@ +name: "Build and Test pyEXP on Mac" + +on: + push: + branches: + - '*' + pull_request: + branches: + - main + - devel +jobs: + exp: + strategy: + matrix: + os: [macos-latest] + + name: "Test pyEXP Build on Mac" + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install EXP dependencies (Mac) + run: | + brew install eigen fftw open-mpi hdf5 libomp + + echo CC=mpicc >> $GITHUB_ENV + echo CXX=mpicxx >> $GITHUB_ENV + echo OMPI_CC="clang" >> $GITHUB_ENV + echo OMPI_CXX="clang++" >> $GITHUB_ENV + + - name: Build EXP + run: | + # Get Python version info + PYTHON_VERSION=$(python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')") + PYTHON_EXEC=$(which python) + PYTHON_LIBRARY_PATH=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") + + # Set Python library path based on OS + if [[ "$RUNNER_OS" == "macOS" ]]; then + PYTHON_LIBRARY=${PYTHON_LIBRARY_PATH}/libpython${PYTHON_VERSION}.dylib + else + PYTHON_LIBRARY=${PYTHON_LIBRARY_PATH}/libpython${PYTHON_VERSION}.so + fi + + cmake -G Ninja -B build \ + -DCMAKE_INSTALL_RPATH=$PWD/install/lib \ + --install-prefix $PWD/install \ + -DENABLE_NBODY=YES \ + -DENABLE_PYEXP=YES \ + -DPYTHON_EXECUTABLE=${PYTHON_EXEC} \ + -DPYTHON_LIBRARY=${PYTHON_LIBRARY} + + # Build and install EXP + cmake --build build + cmake --install build + + # Add the pyEXP dir as a pyEXP.pth file in Python site-packages: + SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])") + echo "$PWD/install/lib/python${PYTHON_VERSION}/site-packages" > "${SITE_PACKAGES}/pyEXP.pth" + + - name: CTest Quick + run: ctest --output-on-failure -L quick + + - name: Test pyEXP + run: | + python -c "import pyEXP; print('pyEXP successfully imported')" From 491b4f38e7e324794b3e1c980715b19367ad5556 Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan <583379+adrn@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:38:34 -0400 Subject: [PATCH 2/3] add cmake option to disable openmp compile flags --- .github/workflows/build-mac.yml | 1 + expui/CMakeLists.txt | 4 +++- pyEXP/CMakeLists.txt | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-mac.yml b/.github/workflows/build-mac.yml index c84822cd4..169c99654 100644 --- a/.github/workflows/build-mac.yml +++ b/.github/workflows/build-mac.yml @@ -50,6 +50,7 @@ jobs: --install-prefix $PWD/install \ -DENABLE_NBODY=YES \ -DENABLE_PYEXP=YES \ + -DDISABLE_OPENMP_COMPILE_FLAGS=YES \ -DPYTHON_EXECUTABLE=${PYTHON_EXEC} \ -DPYTHON_LIBRARY=${PYTHON_LIBRARY} diff --git a/expui/CMakeLists.txt b/expui/CMakeLists.txt index 25f438d0a..4472dbaa7 100644 --- a/expui/CMakeLists.txt +++ b/expui/CMakeLists.txt @@ -58,6 +58,8 @@ add_executable(testread testread.cc) foreach(program ${bin_PROGRAMS}) target_link_libraries(${program} expui exputil ${common_LINKLIB}) target_include_directories(${program} PUBLIC ${common_INCLUDE}) - target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS}) + if(NOT DISABLE_OPENMP_COMPILE_FLAGS) + target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS}) + endif() install(TARGETS ${program} DESTINATION bin) endforeach() diff --git a/pyEXP/CMakeLists.txt b/pyEXP/CMakeLists.txt index dc8cebf0e..be04e98ae 100644 --- a/pyEXP/CMakeLists.txt +++ b/pyEXP/CMakeLists.txt @@ -40,7 +40,9 @@ pybind11_add_module(pyEXP PyWrappers.cc CoefWrappers.cc ParticleReaderWrappers.cc MSSAWrappers.cc EDMDWrappers.cc) target_link_libraries(pyEXP PUBLIC expui exputil ${common_LINKLIB}) target_include_directories(pyEXP PUBLIC ${common_INCLUDE}) -target_compile_options(pyEXP PUBLIC ${OpenMP_CXX_FLAGS}) +if(NOT DISABLE_OPENMP_COMPILE_FLAGS) + target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS}) +endif() get_target_property(cxxflags pyEXP COMPILE_OPTIONS) message("The project has set the following flags: ${cxxflags}") From d01e170e98a9c8168e54fe1b38167a4840b4669d Mon Sep 17 00:00:00 2001 From: Adrian Price-Whelan <583379+adrn@users.noreply.github.com> Date: Fri, 13 Jun 2025 15:43:15 -0400 Subject: [PATCH 3/3] try getting OMP working --- .github/workflows/build-mac.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-mac.yml b/.github/workflows/build-mac.yml index 169c99654..368c6775a 100644 --- a/.github/workflows/build-mac.yml +++ b/.github/workflows/build-mac.yml @@ -31,6 +31,10 @@ jobs: echo OMPI_CC="clang" >> $GITHUB_ENV echo OMPI_CXX="clang++" >> $GITHUB_ENV + echo OMP_HOME=${HOMEBREW_PATH}/opt/libomp/ >> $GITHUB_ENV + echo LDFLAGS="-L${OMP_HOME}/lib" >> $GITHUB_ENV + echo CPPFLAGS="-I${OMP_HOME}/include" >> $GITHUB_ENV + - name: Build EXP run: | # Get Python version info @@ -52,7 +56,9 @@ jobs: -DENABLE_PYEXP=YES \ -DDISABLE_OPENMP_COMPILE_FLAGS=YES \ -DPYTHON_EXECUTABLE=${PYTHON_EXEC} \ - -DPYTHON_LIBRARY=${PYTHON_LIBRARY} + -DPYTHON_LIBRARY=${PYTHON_LIBRARY} \ + -DOpenMP_CXX_INCLUDE_DIR=${OMP_HOME}/include \ + -DOpenMP_C_INCLUDE_DIR=${OMP_HOME}/include # Build and install EXP cmake --build build