diff --git a/.github/workflows/branching-tests.yml b/.github/workflows/branching-tests.yml index 9c190b1..9439055 100644 --- a/.github/workflows/branching-tests.yml +++ b/.github/workflows/branching-tests.yml @@ -23,52 +23,63 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: + os: [ ubuntu-latest, macos-latest ] build_type: [ Release, Debug ] cpp_compiler: [ g++, clang++ ] mpi: [ ON, OFF ] + exclude: + - os: macos-latest + cpp_compiler: g++ + steps: - name: Checkout repository uses: actions/checkout@v3 - name: Install dependencies + if: matrix.os == 'ubuntu-latest' && matrix.mpi == 'ON' run: | - sudo apt install -y mpich python3-pybind11 python3-dev - + sudo apt install -y libopenmpi-dev + - name: Install dependencies + if: matrix.os == 'macos-latest' && matrix.mpi == 'ON' + run: | + brew install mpich + - name: Install and Test Python CUI (MPI) if: matrix.mpi == 'ON' run: | - pip install -U pip - USE_MPI=1 pip install -U . --verbose + pip install -U pip pybind11 + USE_MPI=1 CXX=${{ matrix.cpp_compiler }} pip install -U . --verbose echo -e 'p cnf 2 2\n1 2 0\n-1 -2 0' | mpirun -n 2 pysa-dpll sat - name: Install and Test Python CUI if: matrix.mpi == 'OFF' run: | - pip install -U pip - pip install -U . --verbose + pip install -U pip pybind11 + CXX=${{ matrix.cpp_compiler }} pip install -U . --verbose echo -e 'p cnf 2 2\n1 2 0\n-1 -2 0' | pysa-dpll sat - name: Configure CMake run: > - cmake -B ${{github.workspace}}/build \ - -S ${{ github.workspace }} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ - -DMPI=${{ matrix.mpi }} + CXX=${{ matrix.cpp_compiler }} \ + cmake -B ${{ github.workspace }}/build \ + -S ${{ github.workspace }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -Dpybind11_DIR=$( python -m pybind11 --cmakedir ) \ + -DMPI=${{ matrix.mpi }} - name: Build - run: cmake --build ${{github.workspace}}/build + run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.build_type }} - name: Test - working-directory: ${{github.workspace}}/build/tests + working-directory: ${{ github.workspace }}/build/tests run: ctest -C ${{ matrix.build_type }} --rerun-failed --output-on-failure diff --git a/CMakeLists.txt b/CMakeLists.txt index 50c768a..0735cb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,15 +31,15 @@ add_compile_options(-O3 -Wall -Wpedantic -Wfatal-errors) # Use MPI option(MPI "Build with MPI" OFF) -# Find MPI package -find_package(MPI) - # If MPI exists, compile the code using MPI -if (MPI AND MPI_FOUND) +if (MPI) + find_package(MPI REQUIRED) message(STATUS "MPI Enabled") add_compile_definitions(USE_MPI) include_directories(${MPI_CXX_HEADER_DIR}) link_libraries(MPI::MPI_CXX) +else() + message(STATUS "MPI Disabled") endif () # Find pthreads diff --git a/setup.py b/setup.py index 37fe58c..054409f 100644 --- a/setup.py +++ b/setup.py @@ -76,6 +76,11 @@ def build_extension(self, ext): if USE_MPI: cmake_args.append('-DMPI=ON') + # If provided, override MPIEXEC_EXECUTABLE + if 'MPIEXEC_EXECUTABLE' in os.environ: + cmake_args.append( + f'-DMPIEXEC_EXECUTABLE={os.environ["MPIEXEC_EXECUTABLE"]}') + build_args = ['--config', cfg] if not os.path.exists(self.build_temp):