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

CI/CD: BLAS MSRV and Clippy #1458

Merged
merged 2 commits into from
Nov 30, 2024
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
14 changes: 14 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ jobs:
run: sudo apt-get install libopenblas-dev gfortran
- run: ./scripts/all-tests.sh "$FEATURES" ${{ matrix.rust }}

blas-msrv:
runs-on: ubuntu-latest
name: blas-msrv
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.67.0 # BLAS MSRV
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- name: Install openblas
run: sudo apt-get install libopenblas-dev gfortran
- run: ./scripts/blas-integ-tests.sh "$FEATURES" 1.67.0

miri:
runs-on: ubuntu-latest
name: miri
Expand Down
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ there is no tight coupling to the ``blas-src`` version, so version selection is
0.13 0.2.0 0.6.0
=========== ============ ================ ==============

------------
BLAS on MSRV
------------

Although ``ndarray`` currently maintains an MSRV of 1.64.0, this is separate from the MSRV (either stated or real) of the various BLAS providers.
As of the time of writing, ``openblas`` currently supports MSRV of 1.67.0.
So, while ``ndarray`` and ``openblas-src`` are compatible, they can only work together with toolchains 1.67.0 or above.

Recent Changes
--------------

Expand Down
1 change: 0 additions & 1 deletion crates/ndarray-gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
// except according to those terms.

/// Build ndarray arrays for test purposes

pub mod array_builder;
2 changes: 1 addition & 1 deletion examples/bounds_check_elim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn test1d_single_mut(a: &mut Array1<f64>, i: usize) -> f64
#[no_mangle]
pub fn test1d_len_of(a: &Array1<f64>) -> f64
{
let a = &*a;
let a = a;
let mut sum = 0.;
for i in 0..a.len_of(Axis(0)) {
sum += a[i];
Expand Down
2 changes: 1 addition & 1 deletion ndarray-rand/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn sampling_works(a: &Array2<f64>, strategy: SamplingStrategy, axis: Axis, n_sam
let samples = a.sample_axis(axis, n_samples, strategy);
samples
.axis_iter(axis)
.all(|lane| is_subset(&a, &lane, axis))
.all(|lane| is_subset(a, &lane, axis))
}

// Check if, when sliced along `axis`, there is at least one lane in `a` equal to `b`
Expand Down
5 changes: 3 additions & 2 deletions scripts/all-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ cargo test -v -p ndarray -p ndarray-rand --release --features "$FEATURES" $QC_FE
# BLAS tests
cargo test -p ndarray --lib -v --features blas
cargo test -p blas-mock-tests -v
cargo test -p blas-tests -v --features blas-tests/openblas-system
cargo test -p numeric-tests -v --features numeric-tests/test_blas
if [ "$CHANNEL" != "1.64.0" ]; then
./scripts/blas-integ-tests.sh "$FEATURES" $CHANNEL
fi

# Examples
cargo test --examples
Expand Down
11 changes: 11 additions & 0 deletions scripts/blas-integ-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -x
set -e

FEATURES=$1
CHANNEL=$2

# BLAS tests
cargo test -p blas-tests -v --features blas-tests/openblas-system
cargo test -p numeric-tests -v --features numeric-tests/test_blas
8 changes: 4 additions & 4 deletions src/argument_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub trait AssignElem<T>
}

/// Assignable element, simply `*self = input`.
impl<'a, T> AssignElem<T> for &'a mut T
impl<T> AssignElem<T> for &mut T
{
fn assign_elem(self, input: T)
{
Expand All @@ -20,7 +20,7 @@ impl<'a, T> AssignElem<T> for &'a mut T
}

/// Assignable element, simply `self.set(input)`.
impl<'a, T> AssignElem<T> for &'a Cell<T>
impl<T> AssignElem<T> for &Cell<T>
{
fn assign_elem(self, input: T)
{
Expand All @@ -29,7 +29,7 @@ impl<'a, T> AssignElem<T> for &'a Cell<T>
}

/// Assignable element, simply `self.set(input)`.
impl<'a, T> AssignElem<T> for &'a MathCell<T>
impl<T> AssignElem<T> for &MathCell<T>
{
fn assign_elem(self, input: T)
{
Expand All @@ -39,7 +39,7 @@ impl<'a, T> AssignElem<T> for &'a MathCell<T>

/// Assignable element, the item in the MaybeUninit is overwritten (prior value, if any, is not
/// read or dropped).
impl<'a, T> AssignElem<T> for &'a mut MaybeUninit<T>
impl<T> AssignElem<T> for &mut MaybeUninit<T>
{
fn assign_elem(self, input: T)
{
Expand Down
4 changes: 2 additions & 2 deletions src/array_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ where
// private iterator wrapper
struct Sequence<'a, A, D>(Iter<'a, A, D>);

impl<'a, A, D> Serialize for Sequence<'a, A, D>
impl<A, D> Serialize for Sequence<'_, A, D>
where
A: Serialize,
D: Dimension + Serialize,
Expand Down Expand Up @@ -162,7 +162,7 @@ impl<'de> Deserialize<'de> for ArrayField
{
struct ArrayFieldVisitor;

impl<'de> Visitor<'de> for ArrayFieldVisitor
impl Visitor<'_> for ArrayFieldVisitor
{
type Value = ArrayField;

Expand Down
4 changes: 2 additions & 2 deletions src/arraytraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ where
/// Return `true` if the array shapes and all elements of `self` and
/// `rhs` are equal. Return `false` otherwise.
#[allow(clippy::unconditional_recursion)] // false positive
impl<'a, A, B, S, S2, D> PartialEq<&'a ArrayBase<S2, D>> for ArrayBase<S, D>
impl<A, B, S, S2, D> PartialEq<&ArrayBase<S2, D>> for ArrayBase<S, D>
where
A: PartialEq<B>,
S: Data<Elem = A>,
Expand All @@ -144,7 +144,7 @@ where
/// Return `true` if the array shapes and all elements of `self` and
/// `rhs` are equal. Return `false` otherwise.
#[allow(clippy::unconditional_recursion)] // false positive
impl<'a, A, B, S, S2, D> PartialEq<ArrayBase<S2, D>> for &'a ArrayBase<S, D>
impl<A, B, S, S2, D> PartialEq<ArrayBase<S2, D>> for &ArrayBase<S, D>
where
A: PartialEq<B>,
S: Data<Elem = A>,
Expand Down
24 changes: 12 additions & 12 deletions src/data_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ where A: Clone
}
}

unsafe impl<'a, A> RawData for ViewRepr<&'a A>
unsafe impl<A> RawData for ViewRepr<&A>
{
type Elem = A;

Expand All @@ -420,7 +420,7 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a A>
private_impl! {}
}

unsafe impl<'a, A> Data for ViewRepr<&'a A>
unsafe impl<A> Data for ViewRepr<&A>
{
fn into_owned<D>(self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
where
Expand All @@ -437,15 +437,15 @@ unsafe impl<'a, A> Data for ViewRepr<&'a A>
}
}

unsafe impl<'a, A> RawDataClone for ViewRepr<&'a A>
unsafe impl<A> RawDataClone for ViewRepr<&A>
{
unsafe fn clone_with_ptr(&self, ptr: NonNull<Self::Elem>) -> (Self, NonNull<Self::Elem>)
{
(*self, ptr)
}
}

unsafe impl<'a, A> RawData for ViewRepr<&'a mut A>
unsafe impl<A> RawData for ViewRepr<&mut A>
{
type Elem = A;

Expand All @@ -458,7 +458,7 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a mut A>
private_impl! {}
}

unsafe impl<'a, A> RawDataMut for ViewRepr<&'a mut A>
unsafe impl<A> RawDataMut for ViewRepr<&mut A>
{
#[inline]
fn try_ensure_unique<D>(_: &mut ArrayBase<Self, D>)
Expand All @@ -475,7 +475,7 @@ unsafe impl<'a, A> RawDataMut for ViewRepr<&'a mut A>
}
}

unsafe impl<'a, A> Data for ViewRepr<&'a mut A>
unsafe impl<A> Data for ViewRepr<&mut A>
{
fn into_owned<D>(self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
where
Expand All @@ -492,7 +492,7 @@ unsafe impl<'a, A> Data for ViewRepr<&'a mut A>
}
}

unsafe impl<'a, A> DataMut for ViewRepr<&'a mut A> {}
unsafe impl<A> DataMut for ViewRepr<&mut A> {}

/// Array representation trait.
///
Expand Down Expand Up @@ -533,7 +533,7 @@ pub unsafe trait DataOwned: Data
pub unsafe trait DataShared: Clone + Data + RawDataClone {}

unsafe impl<A> DataShared for OwnedArcRepr<A> {}
unsafe impl<'a, A> DataShared for ViewRepr<&'a A> {}
unsafe impl<A> DataShared for ViewRepr<&A> {}

unsafe impl<A> DataOwned for OwnedRepr<A>
{
Expand Down Expand Up @@ -571,7 +571,7 @@ unsafe impl<A> DataOwned for OwnedArcRepr<A>
}
}

unsafe impl<'a, A> RawData for CowRepr<'a, A>
unsafe impl<A> RawData for CowRepr<'_, A>
{
type Elem = A;

Expand All @@ -587,7 +587,7 @@ unsafe impl<'a, A> RawData for CowRepr<'a, A>
private_impl! {}
}

unsafe impl<'a, A> RawDataMut for CowRepr<'a, A>
unsafe impl<A> RawDataMut for CowRepr<'_, A>
where A: Clone
{
#[inline]
Expand Down Expand Up @@ -615,7 +615,7 @@ where A: Clone
}
}

unsafe impl<'a, A> RawDataClone for CowRepr<'a, A>
unsafe impl<A> RawDataClone for CowRepr<'_, A>
where A: Clone
{
unsafe fn clone_with_ptr(&self, ptr: NonNull<Self::Elem>) -> (Self, NonNull<Self::Elem>)
Expand Down Expand Up @@ -681,7 +681,7 @@ unsafe impl<'a, A> Data for CowRepr<'a, A>
}
}

unsafe impl<'a, A> DataMut for CowRepr<'a, A> where A: Clone {}
unsafe impl<A> DataMut for CowRepr<'_, A> where A: Clone {}

unsafe impl<'a, A> DataOwned for CowRepr<'a, A>
{
Expand Down
4 changes: 2 additions & 2 deletions src/dimension/axes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct AxisDescription
copy_and_clone!(AxisDescription);
copy_and_clone!(['a, D] Axes<'a, D>);

impl<'a, D> Iterator for Axes<'a, D>
impl<D> Iterator for Axes<'_, D>
where D: Dimension
{
/// Description of the axis, its length and its stride.
Expand Down Expand Up @@ -99,7 +99,7 @@ where D: Dimension
}
}

impl<'a, D> DoubleEndedIterator for Axes<'a, D>
impl<D> DoubleEndedIterator for Axes<'_, D>
where D: Dimension
{
fn next_back(&mut self) -> Option<Self::Item>
Expand Down
6 changes: 3 additions & 3 deletions src/dimension/ndindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ unsafe impl<const N: usize> NdIndex<IxDyn> for [Ix; N]
}
}

impl<'a> IntoDimension for &'a [Ix]
impl IntoDimension for &[Ix]
{
type Dim = IxDyn;
fn into_dimension(self) -> Self::Dim
Expand All @@ -264,7 +264,7 @@ impl<'a> IntoDimension for &'a [Ix]
}
}

unsafe impl<'a> NdIndex<IxDyn> for &'a IxDyn
unsafe impl NdIndex<IxDyn> for &IxDyn
{
fn index_checked(&self, dim: &IxDyn, strides: &IxDyn) -> Option<isize>
{
Expand All @@ -276,7 +276,7 @@ unsafe impl<'a> NdIndex<IxDyn> for &'a IxDyn
}
}

unsafe impl<'a> NdIndex<IxDyn> for &'a [Ix]
unsafe impl NdIndex<IxDyn> for &[Ix]
{
fn index_checked(&self, dim: &IxDyn, strides: &IxDyn) -> Option<isize>
{
Expand Down
2 changes: 1 addition & 1 deletion src/impl_cow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::imp_prelude::*;
/// Methods specific to `CowArray`.
///
/// ***See also all methods for [`ArrayBase`]***
impl<'a, A, D> CowArray<'a, A, D>
impl<A, D> CowArray<'_, A, D>
where D: Dimension
{
/// Returns `true` iff the array is the view (borrowed) variant.
Expand Down
4 changes: 2 additions & 2 deletions src/impl_views/constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ where D: Dimension
}

/// Private array view methods
impl<'a, A, D> ArrayView<'a, A, D>
impl<A, D> ArrayView<'_, A, D>
where D: Dimension
{
/// Create a new `ArrayView`
Expand All @@ -254,7 +254,7 @@ where D: Dimension
}
}

impl<'a, A, D> ArrayViewMut<'a, A, D>
impl<A, D> ArrayViewMut<'_, A, D>
where D: Dimension
{
/// Create a new `ArrayView`
Expand Down
2 changes: 1 addition & 1 deletion src/impl_views/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub trait IndexLonger<I>
unsafe fn uget(self, index: I) -> Self::Output;
}

impl<'a, 'b, I, A, D> IndexLonger<I> for &'b ArrayView<'a, A, D>
impl<'a, I, A, D> IndexLonger<I> for &ArrayView<'a, A, D>
where
I: NdIndex<D>,
D: Dimension,
Expand Down
2 changes: 1 addition & 1 deletion src/impl_views/splitting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::slice::MultiSliceArg;
use num_complex::Complex;

/// Methods for read-only array views.
impl<'a, A, D> ArrayView<'a, A, D>
impl<A, D> ArrayView<'_, A, D>
where D: Dimension
{
/// Split the array view along `axis` and return one view strictly before the
Expand Down
Loading