Skip to content
Merged
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
108 changes: 68 additions & 40 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,25 @@ jobs:
- name: "Ubuntu OpenMPI g++"
CC_COMPILER: gcc
CXX_COMPILER: g++
container: "ubuntu_openmpi"
container: "ubuntu_gcc_openmpi"
MPIEXEC_PREFLAGS: "--allow-run-as-root --oversubscribe"
USE_SANITIZER: ""
CMAKE_BUILD_TYPE: Release
DOCKER_OPTIONS: " "
DOCKER_OPTIONS: "--cap-add SYS_PTRACE"
CODE_COVERAGE: "OFF"

- name: "Ubuntu OpenMPI clang++"
CC_COMPILER: clang
CXX_COMPILER: clang++
container: "ubuntu_openmpi"
container: "ubuntu_clang_openmpi"
MPIEXEC_PREFLAGS: "--allow-run-as-root --oversubscribe"
USE_SANITIZER: ""
CMAKE_BUILD_TYPE: Release
DOCKER_OPTIONS: " "
DOCKER_OPTIONS: "--cap-add SYS_PTRACE"
CODE_COVERAGE: "OFF"

- name: "Ubuntu MPICH g++"
CC_COMPILER: gcc
CXX_COMPILER: g++
container: "ubuntu_mpich"
container: "ubuntu_gcc_mpich"
MPIEXEC_PREFLAGS: ""
CMAKE_BUILD_TYPE: Debug
DOCKER_OPTIONS: " "
Expand All @@ -58,35 +56,34 @@ jobs:
- name: "Ubuntu MPICH clang++"
CC_COMPILER: clang
CXX_COMPILER: clang++
container: "ubuntu_mpich"
container: "ubuntu_clang_mpich"
MPIEXEC_PREFLAGS: ""
CMAKE_BUILD_TYPE: Release
DOCKER_OPTIONS: " "
CODE_COVERAGE: "OFF"

# Hangs on github
# - name: "Debian OpenMPI g++"
# CC_COMPILER: gcc
# CXX_COMPILER: g++
# container: "debian_openmpi"
# MPIEXEC_PREFLAGS: "--allow-run-as-root --oversubscribe --mca btl_vader_single_copy_mechanism none"
# USE_SANITIZER: ""
# CMAKE_BUILD_TYPE: Debug
# DOCKER_OPTIONS: "--cap-add SYS_PTRACE"

# - name: "Debian OpenMPI clang++"
# CC_COMPILER: clang
# CXX_COMPILER: clang++
# container: "debian_openmpi"
# MPIEXEC_PREFLAGS: "--allow-run-as-root --oversubscribe --mca btl_vader_single_copy_mechanism none"
# USE_SANITIZER: ""
# CMAKE_BUILD_TYPE: Debug
# DOCKER_OPTIONS: "--cap-add SYS_PTRACE"
- name: "Debian OpenMPI g++"
CC_COMPILER: gcc
CXX_COMPILER: g++
container: "debian_gcc_openmpi"
MPIEXEC_PREFLAGS: "--allow-run-as-root --oversubscribe"
CMAKE_BUILD_TYPE: Release
DOCKER_OPTIONS: "--cap-add SYS_PTRACE"
CODE_COVERAGE: "OFF"

- name: "Debian OpenMPI clang++"
CC_COMPILER: clang
CXX_COMPILER: clang++
container: "debian_clang_openmpi"
MPIEXEC_PREFLAGS: "--allow-run-as-root --oversubscribe"
CMAKE_BUILD_TYPE: Release
DOCKER_OPTIONS: "--cap-add SYS_PTRACE"
CODE_COVERAGE: "OFF"

- name: "Debian MPICH g++"
CC_COMPILER: gcc
CXX_COMPILER: g++
container: "debian_mpich"
container: "debian_gcc_mpich"
MPIEXEC_PREFLAGS: ""
CMAKE_BUILD_TYPE: Release
DOCKER_OPTIONS: " "
Expand All @@ -95,7 +92,7 @@ jobs:
- name: "Debian MPICH clang++"
CC_COMPILER: clang
CXX_COMPILER: clang++
container: "debian_mpich"
container: "debian_clang_mpich"
MPIEXEC_PREFLAGS: ""
CMAKE_BUILD_TYPE: Release
DOCKER_OPTIONS: " "
Expand All @@ -115,46 +112,77 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- name: Checkout htool-python
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: "true"

- name: Activate virtualenv
run: |
. /usr/local/share/venv/bin/activate
echo PATH=$PATH >> $GITHUB_ENV

- name: Build package in release
if: matrix.CODE_COVERAGE == 'OFF'
run: |
pip3 install . --user
python3 -m pip install .[dev]

- name: Build package in debug for coverage
if: matrix.CODE_COVERAGE == 'ON'
run: |
mkdir build && cd build
pip3 install numpy scipy matplotlib
CC=${{ matrix.CC_COMPILER }} CXX=${{ matrix.CXX_COMPILER }} cmake -DUSE_SANITIZER=${{ matrix.USE_SANITIZER }} -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DCODE_COVERAGE=${{ matrix.CODE_COVERAGE }} ../
python3 -m pip install numpy matplotlib ruff pytest mpi4py scipy
CC=${{ matrix.CC_COMPILER }} CXX=${{ matrix.CXX_COMPILER }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DCODE_COVERAGE=${{ matrix.CODE_COVERAGE }} ../
make

- name: Run tests
run: |
export PYTHONPATH="$PWD/build"
mpirun -np 2 ${{ matrix.MPIEXEC_PREFLAGS }} pytest tests
mpirun -np 3 ${{ matrix.MPIEXEC_PREFLAGS }} pytest tests
mpirun -np 4 ${{ matrix.MPIEXEC_PREFLAGS }} pytest tests
mpirun -np 1 ${{ matrix.MPIEXEC_PREFLAGS }} python3 -m pytest tests --ignore=tests/test_hmatrix.py --ignore=tests/test_logger.py
mpirun -np 2 ${{ matrix.MPIEXEC_PREFLAGS }} python3 -m pytest tests --ignore=tests/test_hmatrix.py --ignore=tests/test_logger.py
mpirun -np 3 ${{ matrix.MPIEXEC_PREFLAGS }} python3 -m pytest tests --ignore=tests/test_hmatrix.py --ignore=tests/test_logger.py
mpirun -np 4 ${{ matrix.MPIEXEC_PREFLAGS }} python3 -m pytest tests --ignore=tests/test_hmatrix.py --ignore=tests/test_logger.py
python3 -m pytest tests/test_hmatrix.py
python3 -m pytest tests/test_logger.py

- name: Check format
if: matrix.CODE_COVERAGE == 'ON'
# https://github.com/actions/checkout/pull/762
run: |
git config --global --add safe.directory `pwd`
cd build
make format
make cmake-format
git diff --exit-code

- name: Check with ruff
run: |
ruff check example/ tests/

- name: Generate coverage reports
if: matrix.CODE_COVERAGE == 'ON'
run: |
lcov --capture --base-directory ./ --directory build/ --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/hpddm/*' '*/pybind11/*' '*/lib/htool/*' --output-file coverage.info
lcov --ignore-errors mismatch --capture --base-directory ./ --directory build/ --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/hpddm/*' '*/pybind11/*' '*/lib/htool/*' --output-file ../coverage.info

- name: Upload coverage to Codecov
- uses: actions/upload-artifact@v4
with:
path: coverage.info
if-no-files-found: error
if: matrix.CODE_COVERAGE == 'ON'
uses: codecov/codecov-action@v2

coverage:
runs-on: ubuntu-latest
if: ${{ success() }}
needs: [ linux ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
- name: Upload coverage report
uses: codecov/codecov-action@v4
with:
file: coverage.info
fail_ci_if_error: true
file: ./coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
37 changes: 36 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
build*
__pycache__

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "lib/pybind11"]
path = lib/pybind11
url = https://github.com/pybind/pybind11.git
[submodule "lib/htool_generate_data_test"]
path = lib/htool_generate_data_test
url = https://github.com/PierreMarchand20/htool_generate_data_test.git
87 changes: 59 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ else()
LANGUAGES CXX)
endif()

# To force c++11
# To force c++17
if(${CMAKE_VERSION} VERSION_LESS 3.1)
add_compile_options(-std=c++11)
add_compile_options(-std=c++17)
elseif(${CMAKE_VERSION} VERSION_LESS 3.6.3 AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
add_compile_options(-std=c++11)
add_compile_options(-std=c++17)
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

Expand All @@ -44,45 +44,76 @@ cmake_format(cmake_format ${PROJECT_SOURCE_DIR}/CMakeLists.txt)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")

# MPI
find_package(MPI REQUIRED)
message("-- MPI libraries found in " "${MPI_LIBRARIES}")
message("-- MPI include files found in " "${MPI_INCLUDE_PATH}")
separate_arguments(MPIEXEC_PREFLAGS) # to support multi flags

find_package(MPI)
if(MPI_FOUND)
message("-- MPI libraries found in " "${MPI_LIBRARIES}")
message("-- MPI include files found in " "${MPI_INCLUDE_PATH}")
separate_arguments(MPIEXEC_PREFLAGS) # to support multi flags
endif()
# OPENMP
find_package(OpenMP)

# BLAS
find_package(BLAS REQUIRED)
message("-- Found Blas implementation:" "${BLAS_LIBRARIES}")
message("-- Blas implementation:" "${BLAS_LIBRARIES}")

# LAPACK
find_package(LAPACK)
message("-- Found Lapack:" "${LAPACK_LIBRARIES}")
message("-- Lapack implementation:" "${LAPACK_LIBRARIES}")

# MPI4PY
find_package(MPI4PY REQUIRED)
message("-- Found MPI4PY:" "${MPI4PY_INCLUDE_DIR}")
find_package(
Python
COMPONENTS Interpreter Development
REQUIRED)
message("-- Python executable:" "${Python_EXECUTABLE}")

# MPI4PY
if(MPI_FOUND)
find_package(MPI4PY REQUIRED)
message("-- MPI4PY include dir:" "${MPI4PY_INCLUDE_DIR}")
endif()

add_subdirectory(lib/pybind11)

pybind11_add_module(Htool src/htool/main.cpp)
target_include_directories(
Htool
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/htool/include>
$<INSTALL_INTERFACE:lib/htool/include>
lib/htool/include
lib/hpddm/include
${MPI_INCLUDE_PATH}
${MKL_INC_DIR}
${MPI4PY_INCLUDE_DIR})
target_include_directories(Htool PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/lib/htool/include> $<INSTALL_INTERFACE:lib/htool/include> lib/htool/include lib/hpddm/include ${MKL_INC_DIR})
if(MPI_FOUND)
target_link_libraries(Htool PRIVATE MPI::MPI_CXX)
target_include_directories(Htool PRIVATE ${MPI_INCLUDE_PATH} ${MPI4PY_INCLUDE_DIR})
target_compile_definitions(Htool PRIVATE HAVE_MPI)
endif()
target_link_libraries(Htool PRIVATE ${MPI_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${ARPACK_LIBRARIES} ${OpenMP_CXX_LIBRARIES})

target_compile_definitions(Htool PRIVATE "-DPYTHON_INTERFACE" "-DWITH_HPDDM")

if(CODE_COVERAGE AND (CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"))
target_compile_options(Htool PRIVATE -fprofile-arcs -ftest-coverage)
target_link_libraries(Htool PRIVATE gcov)
if("${BLA_VENDOR}" STREQUAL "Intel10_32"
OR "${BLA_VENDOR}" STREQUAL "Intel10_64lp"
OR "${BLA_VENDOR}" STREQUAL "Intel10_64lp_seq"
OR "${BLA_VENDOR}" STREQUAL "Intel10_64ilp"
OR "${BLA_VENDOR}" STREQUAL "Intel10_64ilp_seq"
OR "${BLA_VENDOR}" STREQUAL "Intel10_64_dyn")
target_compile_definitions(Htool PRIVATE "-DHPDDM_MKL -DHTOOL_MKL")
endif()

# target_compile_features(Htool INTERFACE cxx_std_11)
target_compile_definitions(Htool PRIVATE "-DHTOOL_WITH_PYTHON_INTERFACE" "-DHTOOL_WITH_HPDDM")

if(CODE_COVERAGE)
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(STATUS "Code coverage enabled with GNU.")
target_compile_options(Htool PRIVATE -fprofile-arcs -ftest-coverage -fno-elide-constructors -fno-default-inline -O0)
target_link_options(
Htool
PRIVATE
-fprofile-arcs
-ftest-coverage
-fno-elide-constructors
-fno-default-inline
-O0)
target_link_libraries(Htool PRIVATE gcov)
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Code coverage enabled with LLVM.")
target_compile_options(Htool PRIVATE -fprofile-instr-generate -fcoverage-mapping -O0)
target_link_options(Htool PRIVATE -fprofile-instr-generate -fcoverage-mapping -O0)
else()
message(STATUS "Code coverage not available.")
endif()
endif()
Loading