Skip to content

Commit

Permalink
fix: Fix SIMD imports to work with latest nightly.
Browse files Browse the repository at this point in the history
Add nightly builds to CI.
  • Loading branch information
jetuk committed Mar 12, 2024
1 parent fb89773 commit af1da2d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 33 deletions.
51 changes: 33 additions & 18 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,40 @@ env:

jobs:
build:
name: Build (stable)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir bin
curl -sSL $url | tar -xz --directory=bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Build
run: cargo build --verbose --no-default-features
- name: Run tests
run: cargo test --no-default-features
- name: Run mdbook tests
run: mdbook test ./pywr-book

build_nightly:
name: Build (nightly) w/ SIMD and OpenCL
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir bin
curl -sSL $url | tar -xz --directory=bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Build
run: cargo build --verbose --no-default-features
- name: Run tests
run: cargo test --no-default-features
- name: Run mdbook tests
run: mdbook test ./pywr-book
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@nightly
- run: cargo test --all-features
- name: Build
run: cargo +nightly build --verbose --no-default-features --features ipm-simd,ipm-ocl
- name: Run tests
run: cargo +nightly test --no-default-features --features ipm-simd,ipm-ocl
3 changes: 2 additions & 1 deletion ipm-simd/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use nalgebra_sparse::CsrMatrix;
use std::iter::Sum;
use std::ops::{Add, AddAssign, Div, Mul, Neg, Sub};
use std::simd::{LaneCount, Simd, SimdElement, SimdFloat, StdFloat, SupportedLaneCount};
use std::simd::prelude::SimdFloat;
use std::simd::{LaneCount, Simd, SimdElement, StdFloat, SupportedLaneCount};

pub struct Matrix<T, const N: usize>
where
Expand Down
5 changes: 2 additions & 3 deletions ipm-simd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ use std::fmt::Debug;
use std::iter::Sum;
use std::num::NonZeroUsize;
use std::ops::{Add, AddAssign, Div, Mul, Neg, Sub};
use std::simd::{
LaneCount, Mask, Simd, SimdElement, SimdFloat, SimdPartialEq, SimdPartialOrd, StdFloat, SupportedLaneCount,
};
use std::simd::prelude::{SimdFloat, SimdPartialEq, SimdPartialOrd};
use std::simd::{LaneCount, Mask, Simd, SimdElement, StdFloat, SupportedLaneCount};

struct PathData<T, const N: usize>
where
Expand Down
5 changes: 2 additions & 3 deletions ipm-simd/src/path_following_direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ use crate::Tolerances;
use ipm_common::SparseNormalCholeskyIndices;
use std::iter::Sum;
use std::ops::{Add, AddAssign, Div, Mul, Neg, Sub};
use std::simd::{
LaneCount, Mask, Simd, SimdElement, SimdFloat, SimdPartialEq, SimdPartialOrd, StdFloat, SupportedLaneCount,
};
use std::simd::prelude::{SimdFloat, SimdPartialEq, SimdPartialOrd};
use std::simd::{LaneCount, Mask, Simd, SimdElement, StdFloat, SupportedLaneCount};

pub struct ANormIndices {
indptr: Vec<usize>,
Expand Down
14 changes: 8 additions & 6 deletions pywr-core/benches/random_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use pywr_core::solvers::{HighsSolver, HighsSolverSettings};
#[cfg(feature = "ipm-simd")]
use pywr_core::solvers::{SimdIpmF64Solver, SimdIpmSolverSettings, SimdIpmSolverSettingsBuilder};
use pywr_core::test_utils::make_random_model;

use rand::SeedableRng;
use rand_chacha::ChaCha8Rng;
#[cfg(any(feature = "ipm-simd", feature = "ipm-ocl"))]
use std::num::NonZeroUsize;

fn random_benchmark(
c: &mut Criterion,
Expand Down Expand Up @@ -312,12 +313,13 @@ fn bench_threads(c: &mut Criterion) {
)
}

#[cfg(any(feature = "ipm-simd", feature = "ipm-ocl"))]
fn bench_ipm_convergence(c: &mut Criterion) {
const N_THREADS: usize = 0;

let solver_setups = Vec::new();
let mut solver_setups = Vec::new();

for _optimality in [1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8] {
for optimality in [1e-3, 1e-4, 1e-5, 1e-6, 1e-7, 1e-8] {
#[cfg(feature = "ipm-simd")]
solver_setups.push(SolverSetup {
setting: SolverSetting::IpmSimdF64x4(
Expand Down Expand Up @@ -353,15 +355,15 @@ fn bench_ipm_convergence(c: &mut Criterion) {
)
}

#[cfg(feature = "ipm-ocl")]
fn bench_ocl_chunks(c: &mut Criterion) {
const N_THREADS: usize = 0;

let solver_setups = Vec::new();
let mut solver_setups = Vec::new();

let num_chunks = vec![1, 2, 4, 8, 16];

for _num_chunks in num_chunks {
#[cfg(feature = "ipm-ocl")]
for num_chunks in num_chunks {
solver_setups.push(SolverSetup {
setting: SolverSetting::IpmOcl(
ClIpmSolverSettingsBuilder::default()
Expand Down
3 changes: 2 additions & 1 deletion pywr-core/src/solvers/ipm_simd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ pub use settings::{SimdIpmSolverSettings, SimdIpmSolverSettingsBuilder};
use std::collections::BTreeMap;
use std::num::NonZeroUsize;
use std::ops::Deref;
use std::simd::{LaneCount, Simd, SimdFloat, SupportedLaneCount};
use std::simd::prelude::SimdFloat;
use std::simd::{LaneCount, Simd, SupportedLaneCount};
use std::time::Instant;

const B_MAX: f64 = 999999.0;
Expand Down
2 changes: 1 addition & 1 deletion pywr-core/src/solvers/ipm_simd/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,6 @@ mod tests {
};
let settings_from_builder = SimdIpmSolverSettingsBuilder::<f64, 4>::default().parallel().build();

assert_eq!(settings_from_builder, settings_from_builder);
assert_eq!(settings_from_builder, settings);
}
}

0 comments on commit af1da2d

Please sign in to comment.