Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 26 additions & 15 deletions .github/workflows/branching-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down