Skip to content

Windows CI #3

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

Merged
merged 16 commits into from
May 16, 2025
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
70 changes: 69 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: "Plugin information"
shell: bash -l {0}
run: |
python -c "import simtk.openmm as mm; print('---Loaded---', *mm.pluginLoadedLibNames, '---Failed---', *mm.Platform.getPluginLoadFailures(), sep='\n')"
python -c "import openmm as mm; print('---Loaded---', *mm.pluginLoadedLibNames, '---Failed---', *mm.Platform.getPluginLoadFailures(), sep='\n')"

- name: "Test C++"
shell: bash -l {0}
Expand Down Expand Up @@ -121,3 +121,71 @@ jobs:
run: |
cd python/tests
pytest -v Test*


windows:
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
- name: Windows Python 3.12
python-version: "3.12"
os: windows-latest

steps:
- uses: actions/checkout@v2

- uses: conda-incubator/setup-miniconda@v3
name: "Prepare base dependencies"
with:
python-version: ${{ matrix.python-version }}
activate-environment: build
environment-file: devtools/conda-envs/build-${{ matrix.os }}.yml
auto-activate-base: false
miniforge-variant: Miniforge3
use-mamba: true

- name: "Conda info"
shell: cmd /C call {0}
run: |
conda info -a
conda list

- name: "Configure build with CMake"
shell: cmd /C call {0}
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
mkdir build
cd build
cmake .. -G "NMake Makefiles JOM" ^
-DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%/Library ^
-DCMAKE_BUILD_TYPE=Release ^
-DOPENMM_DIR=%CONDA_PREFIX%/Library ^
-DONNX_LIBRARY_PATH="C:\Users\runneradmin\miniconda3\envs\build\Library\lib\onnxruntime_conda.lib"

- name: "Build"
shell: cmd /C call {0}
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
cd build
jom -j 4 install
jom -j 4 PythonInstall

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

# - name: "Test C++"
# shell: cmd /C call {0}
# run: |
# cd build
# ctest --output-on-failure
#
# - name: "Test Python"
# shell: cmd /C call {0}
# run: |
# cd python/tests
# pytest -v TestOnnxForce.py
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ADD_LIBRARY(${SHARED_ONNX_TARGET} SHARED ${SOURCE_FILES} ${SOURCE_INCLUDE_FILES}
SET_TARGET_PROPERTIES(${SHARED_ONNX_TARGET}
PROPERTIES COMPILE_FLAGS "-DONNX_BUILDING_SHARED_LIBRARY ${EXTRA_COMPILE_FLAGS}"
LINK_FLAGS "${EXTRA_COMPILE_FLAGS}")
TARGET_LINK_LIBRARIES(${SHARED_ONNX_TARGET} OpenMM onnxruntime)
TARGET_LINK_LIBRARIES(${SHARED_ONNX_TARGET} OpenMM "${ONNX_LIBRARY_PATH}")
INSTALL_TARGETS(/lib RUNTIME_DIRECTORY /lib ${SHARED_ONNX_TARGET})

# install headers
Expand Down
17 changes: 17 additions & 0 deletions devtools/conda-envs/build-windows-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: build
channels:
- conda-forge
dependencies:
# build
- jom
- cmake
- ccache
- m2-coreutils
# host
- python
- swig
- openmm
- onnxruntime
- onnxruntime-cpp
# test
- pytest
25 changes: 11 additions & 14 deletions openmmapi/src/OnnxForceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,15 @@ void OnnxForceImpl::initialize(ContextImpl& context) {
int numInputs = 1+owner.getNumGlobalParameters();
if (owner.usesPeriodicBoundaryConditions())
numInputs++;
inputTensors.resize(numInputs);
inputNames.resize(numInputs);
inputTensors[0] = Value::CreateTensor<float>(memoryInfo, positionVec.data(), positionVec.size(), positionsShape, 2);
inputNames[0] = "positions";
inputTensors.emplace_back(Value::CreateTensor<float>(memoryInfo, positionVec.data(), positionVec.size(), positionsShape, 2));
inputNames.push_back("positions");
if (owner.usesPeriodicBoundaryConditions()) {
inputTensors[1] = Value::CreateTensor<float>(memoryInfo, boxVectors, 9, boxShape, 2);
inputNames[1] = "box";
inputTensors.emplace_back(Value::CreateTensor<float>(memoryInfo, boxVectors, 9, boxShape, 2));
inputNames.push_back("box");
}
int paramStart = (owner.usesPeriodicBoundaryConditions() ? 2 : 1);
for (int i = 0; i < paramVec.size(); i++) {
inputTensors[i+paramStart] = Value::CreateTensor<float>(memoryInfo, &paramVec[i], 1, paramShape, 1);
inputNames[i+paramStart] = owner.getGlobalParameterName(i).c_str();
inputTensors.emplace_back(Value::CreateTensor<float>(memoryInfo, &paramVec[i], 1, paramShape, 1));
inputNames.push_back(owner.getGlobalParameterName(i).c_str());
}
}

Expand All @@ -134,19 +131,19 @@ double OnnxForceImpl::computeForce(ContextImpl& context, const vector<Vec3>& pos

int numParticles = context.getSystem().getNumParticles();
for (int i = 0; i < numParticles; i++) {
positionVec[3*i] = positions[i][0];
positionVec[3*i+1] = positions[i][1];
positionVec[3*i+2] = positions[i][2];
positionVec[3*i] = (float) positions[i][0];
positionVec[3*i+1] = (float) positions[i][1];
positionVec[3*i+2] = (float) positions[i][2];
}
if (owner.usesPeriodicBoundaryConditions()) {
Vec3 box[3];
context.getPeriodicBoxVectors(box[0], box[1], box[2]);
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
boxVectors[3*i+j] = box[i][j];
boxVectors[3*i+j] = (float) box[i][j];
}
for (int i = 0; i < owner.getNumGlobalParameters(); i++)
paramVec[i] = context.getParameter(owner.getGlobalParameterName(i));
paramVec[i] = (float) context.getParameter(owner.getGlobalParameterName(i));

// Perform the computation.

Expand Down
Loading