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

Update the build system and fix CI #68

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0c53f3f
Force to build on Ubuntu 18.04
Mar 6, 2023
7a7814b
Upgrade to Ubuntu 22.04
Mar 20, 2023
4f0edf1
Fix CUDA installation
Mar 20, 2023
605eb7b
Fix CUDA version
Mar 20, 2023
ee5ed8a
Clean up
Mar 20, 2023
8563675
Fix CUDA version again
Mar 20, 2023
115be3a
Include factory.i for SWIG
Mar 20, 2023
e3d5c68
Update Linux versions
Mar 20, 2023
5034873
Set Linux versions
Mar 20, 2023
5b26bc3
Fix versions
Mar 20, 2023
8236103
Fix versions again
Mar 21, 2023
74e2efa
Clean up CI
Mar 21, 2023
a3a103b
Add pocl
Mar 21, 2023
e0c2433
Clean up
Mar 21, 2023
1c980c1
Clean up compilation flags
Mar 21, 2023
52d4121
Simplify testing
Mar 21, 2023
848a1b6
Use standard FindOpenCL
Mar 21, 2023
71348ed
Clean up
Mar 21, 2023
36d8f4f
Clean up
Mar 22, 2023
6dd58ab
Add older versions
Mar 24, 2023
db3354a
Use pip instead of setup.py
Mar 27, 2023
acaa8fa
Clean up MacOS dependecies
Mar 27, 2023
de0a552
Fix Python version on MacOS
Mar 27, 2023
1df18b1
Test MacOS 11
Mar 29, 2023
fb19c01
Remove pocl for MacOS
Apr 24, 2023
67f6b42
Skip OpenCL tests on MacOS
Apr 24, 2023
82f2b36
Set project name
Apr 25, 2023
6a06e8d
Report OpenCL and CUDA detected
Apr 25, 2023
4006440
Test with the OpenMM dev builds
May 5, 2023
574f1a8
Fix typo
May 5, 2023
93cd99e
Fix Action syntax
May 5, 2023
8238958
Fix channel addition
May 5, 2023
031cb15
Fix the new line
May 5, 2023
c1d5aa0
Show the environment file
May 8, 2023
e83e5e3
Fix typo
May 8, 2023
248713e
Fix the new line
May 8, 2023
8665ad0
Fix spaces
May 8, 2023
4814d70
Fix Python
May 8, 2023
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
187 changes: 89 additions & 98 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ on:
branches:
- "master"
schedule:
# Nightly tests run on master by default:
# Scheduled workflows run on the latest commit on the default or base branch.
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
- cron: "0 0 * * *"
# Run every Sunday at midnight
- cron: '0 0 * * 0'

defaults:
run:
shell: bash -l {0}

jobs:
unix:
Expand All @@ -22,136 +23,126 @@ jobs:
fail-fast: false
matrix:
include:
- name: Linux CPU CUDA 11.0 Python 3.6
python-version: "3.6"
os: ubuntu-latest
gcc-version: "9"
cuda-version: "11.0"
cdt-name: cos7 # CentOS sysroot: cuda 10.x needs cos6, 11+ needs cos7
CMAKE_FLAGS: |
-DPLUMED_BUILD_CUDA_LIB=ON \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-DEXTRA_COMPILE_FLAGS="-L/usr/local/cuda/lib64/stubs -Wl,-rpath,/usr/local/cuda/lib64/stubs -Wl,-rpath-link,/usr/local/cuda/lib64/stubs"

- name: MacOS Intel CPU OpenCL Python 3.9
# Bleeding edge
- name: Linux (CUDA 11.8, OpenMM dev, PLUMED 2.7, Python 3.*)
os: ubuntu-22.04
extra-channel: "conda-forge/label/openmm_dev"
cuda-version: "11.8.0"
gcc-version: "11.3"
nvcc-version: "11.8"
openmm-version: "*"
plumed-version: "2.7"
python-version: "3.*"

# Latest supported versions
- name: Linux (CUDA 11.8, OpenMM 8.0, PLUMED 2.7, Python 3.10)
os: ubuntu-22.04
extra-channel: ""
cuda-version: "11.8.0"
gcc-version: "11.3"
nvcc-version: "11.8"
openmm-version: "8.0"
plumed-version: "2.7"
python-version: "3.10"

# Oldest supported versions
- name: Linux (CUDA 11.2, OpenMM 7.7, PLUMED 2.7, Python 3.9)
os: ubuntu-22.04
extra-channel: ""
cuda-version: "11.2.2"
gcc-version: "10.4"
nvcc-version: "11.2"
openmm-version: "7.7"
plumed-version: "2.7"
python-version: "3.9"
os: macos-latest
cuda-version: ""
CMAKE_FLAGS: ""

- name: MacOS (OpenMM 8.0, PLUMED 2.7, Python 3.10)
os: macos-11
python-version: "3.10"

steps:
- uses: actions/checkout@v2
- name: Check out
uses: actions/checkout@v2

- name: Install CUDA Toolkit (if needed)
if: startsWith(matrix.os, 'ubuntu')
uses: Jimver/cuda-toolkit@v0.2.10
with:
cuda: ${{ matrix.cuda-version }}
linux-local-args: '["--toolkit", "--override"]' # Need to install CUDA 10.2

- name: Install MacOS SDK (if needed)
if: startsWith(matrix.os, 'macos')
run: source devtools/scripts/install_macos_sdk.sh

- name: "Patch conda env (if needed)"
- name: Prepare dependencies (if needed)
if: startsWith(matrix.os, 'ubuntu')
run: |
sed -i -e "s/@CDT_NAME@/${{ matrix.cdt-name }}/g" \
-e "s/@GCC_VERSION@/${{ matrix.gcc-version }}.*/g" \
-e "s/@CUDATOOLKIT_VERSION@/${{ matrix.cuda-version }}.*/g" \
sed -i -e "/cudatoolkit/c\ - cudatoolkit ${{ matrix.cuda-version }}" \
-e "/gxx_linux-64/c\ - gxx_linux-64 ${{ matrix.gcc-version }}" \
-e "/nvcc_linux-64/c\ - nvcc_linux-64 ${{ matrix.nvcc-version }}" \
-e "/openmm/c\ - openmm ${{ matrix.openmm-version }}" \
-e "/plumed/c\ - plumed ${{ matrix.plumed-version }}" \
-e "/python/c\ - python ${{ matrix.python-version }}" \
devtools/conda-envs/build-${{ matrix.os }}.yml

- uses: conda-incubator/setup-miniconda@v2
name: "Prepare base dependencies"
- name: Add an extra channel (if needed)
if: startsWith(matrix.os, 'ubuntu') && matrix.extra-channel != ''
run: |
sed -i -e "/^channels:$/a \ \ - ${{ matrix.extra-channel }}" \
devtools/conda-envs/build-${{ matrix.os }}.yml

- name: Show the environment file
run: cat devtools/conda-envs/build-${{ matrix.os }}.yml

- name: Install dependencies
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
activate-environment: build
environment-file: devtools/conda-envs/build-${{ matrix.os }}.yml
auto-activate-base: false
channels: conda-forge

- name: "Install CUDA on Ubuntu (if needed)"
if: matrix.cuda-version != ''
env:
CUDA_VERSION: ${{ matrix.cuda-version }}
run: source devtools/scripts/install_cuda.sh

- name: "Set SDK on MacOS (if needed)"
if: startsWith(matrix.os, 'macos')
run: source devtools/scripts/install_macos_sdk.sh

- name: "Conda info"
shell: bash -l {0}
- name: Conda info
run: |
conda info -a
conda list

- name: Patch Plumed's Lepton location
shell: bash -l {0}
- name: Patch Plumed's Lepton
run: |
test -d ${CONDA_PREFIX}/include/plumed/lepton && mv ${CONDA_PREFIX}/include/plumed/lepton ${CONDA_PREFIX}/include/plumed/lepton.bak

- name: "Configure build with CMake"
shell: bash -l {0}
- name: Configure, compile, and install
run: |
mkdir build
cd build

SHLIB_EXT=".so"
if [[ ${{ matrix.os }} == macos-* ]]; then
SHLIB_EXT=".dylib"
fi
mkdir build && cd build

cmake .. \
-DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX} \
-DCMAKE_PREFIX_PATH=${CONDA_PREFIX} \
-DCMAKE_BUILD_TYPE=Release \
-DOPENMM_DIR=${CONDA_PREFIX} \
-DPLUMED_INCLUDE_DIR=${CONDA_PREFIX}/include/plumed \
-DPLUMED_LIBRARY_DIR=${CONDA_PREFIX}/lib \
-DPLUMED_BUILD_OPENCL_LIB=ON \
-DOPENCL_INCLUDE_DIR=${CONDA_PREFIX}/include \
-DOPENCL_LIBRARY=${CONDA_PREFIX}/lib/libOpenCL${SHLIB_EXT} \
${{ matrix.CMAKE_FLAGS }}

- name: "Build"
shell: bash -l {0}
run: |
cd build
make -j2 install
make -j2 PythonInstall
make install
make PythonInstall

- name: "Plugin information"
shell: bash -l {0}
- name: Plugin information
run: |
python -c "import simtk.openmm as mm; print('---Loaded---', *mm.pluginLoadedLibNames, '---Failed---', *mm.Platform.getPluginLoadFailures(), sep='\n')"

- name: "Test C++"
shell: bash -l {0}
- name: Run C++ tests on Linux
if: startsWith(matrix.os, 'ubuntu')
run: |
cd build
ctest -V -E TestCuda

- name: Run C++ tests on MacOS
if: startsWith(matrix.os, 'macos')
run: |
set +e
cd build
if [[ ${{ matrix.os }} == ubuntu-* ]]; then
test_files=$(find . -name "Test*" -executable -type f)
else
test_files=$(find . -name "Test*" -perm +0111 -type f)
fi
summary=""
exitcode=0
for f in $test_files; do
fn=$(basename $f)
echo "::group::$fn"
summary+="\n${fn}: "
if [[ $fn == *Cuda* ]]; then
echo "Skipping $fn..."
summary+="Skipped"
echo "::endgroup::"
continue
fi
echo "Running $fn..."
./${f}
thisexitcode=$?
if [[ $thisexitcode == 0 ]]; then summary+="OK"; else summary+="FAILED"; fi
((exitcode+=$thisexitcode))
echo "::endgroup::"
done
echo "-------"
echo "Summary"
echo "-------"
echo -e "${summary}"
exit $exitcode

- name: "Test Python"
shell: bash -l {0}
ctest -V -E TestCuda -E TestOpenCL

- name: Test Python
run: |
cd python/tests
pytest -v Test*
21 changes: 11 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
# OpenMM Plumed Plugin
#----------------------------------------------------

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.20 FATAL_ERROR)

# Set the library name
SET(PLUMED_LIBRARY_NAME OpenMMPlumed)
SET(SHARED_PLUMED_TARGET ${PLUMED_LIBRARY_NAME})
PROJECT(${PLUMED_LIBRARY_NAME} LANGUAGES CXX)

# We need to know where OpenMM is installed so we can access the headers and libraries.
SET(OPENMM_DIR "/usr/local/openmm" CACHE PATH "Where OpenMM is installed")
Expand Down Expand Up @@ -37,10 +42,6 @@ ENDIF(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
SET(PLUMED_PLUGIN_SOURCE_SUBDIRS openmmapi serialization)

# Set the library name
SET(PLUMED_LIBRARY_NAME OpenMMPlumed)
SET(SHARED_PLUMED_TARGET ${PLUMED_LIBRARY_NAME})

# These are all the places to search for header files which are to be part of the API.
SET(API_INCLUDE_DIRS "openmmapi/include" "openmmapi/include/internal")

Expand Down Expand Up @@ -90,17 +91,17 @@ ADD_SUBDIRECTORY(serialization/tests)
ADD_SUBDIRECTORY(platforms/reference)

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
FIND_PACKAGE(OpenCL QUIET)
IF(OPENCL_FOUND)
FIND_PACKAGE(OpenCL)
IF(OpenCL_FOUND)
SET(PLUMED_BUILD_OPENCL_LIB ON CACHE BOOL "Build implementation for OpenCL")
ELSE(OPENCL_FOUND)
ELSE(OpenCL_FOUND)
SET(PLUMED_BUILD_OPENCL_LIB OFF CACHE BOOL "Build implementation for OpenCL")
ENDIF(OPENCL_FOUND)
ENDIF(OpenCL_FOUND)
IF(PLUMED_BUILD_OPENCL_LIB)
ADD_SUBDIRECTORY(platforms/opencl)
ENDIF(PLUMED_BUILD_OPENCL_LIB)

FIND_PACKAGE(CUDA QUIET)
FIND_PACKAGE(CUDA)
IF(CUDA_FOUND)
SET(PLUMED_BUILD_CUDA_LIB ON CACHE BOOL "Build implementation for CUDA")
ELSE(CUDA_FOUND)
Expand Down
95 changes: 0 additions & 95 deletions FindOpenCL.cmake

This file was deleted.

16 changes: 16 additions & 0 deletions devtools/conda-envs/build-macos-11.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: build
channels:
- conda-forge
dependencies:
# build
- cmake >=3.20
- compilers
- make
- pip
- swig
# host
- openmm 8.0
- plumed 2.7
- python 3.10
# test
- pytest
Loading