diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06e11241c..16228b6bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,6 +42,27 @@ jobs: components: rustfmt - run: cargo fmt --all --check + nostd-build: + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + strategy: + matrix: + include: + - rust: stable + experimental: false + target: thumbv6m-none-eabi + + name: nostd-build/${{ matrix.target }}/${{ matrix.rust }} + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ matrix.rust }} + targets: ${{ matrix.target }} + - name: Tests + run: | + cargo rustc "--target=${{ matrix.target }}" --no-default-features --features portable-atomic-critical-section + tests: runs-on: ubuntu-latest strategy: diff --git a/Cargo.toml b/Cargo.toml index adae2de29..5921ebe05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ matrixmultiply = { version = "0.3.2", default-features = false, features=["cgemm serde = { version = "1.0", optional = true, default-features = false, features = ["alloc"] } rawpointer = { version = "0.2" } + [dev-dependencies] defmac = "0.2" quickcheck = { version = "1.0", default-features = false } @@ -70,8 +71,14 @@ docs = ["approx", "serde", "rayon"] std = ["num-traits/std", "matrixmultiply/std"] rayon = ["dep:rayon", "std"] +portable-atomic-critical-section = ["portable-atomic/critical-section"] + matrixmultiply-threading = ["matrixmultiply/threading"] +[target.'cfg(not(target_has_atomic = "ptr"))'.dependencies] +portable-atomic = { version = "1.6.0" } +portable-atomic-util = { version = "0.2.0", features = [ "alloc" ] } + [profile.bench] debug = true [profile.dev.package.numeric-tests] diff --git a/README.rst b/README.rst index 90ed47932..3fb692b68 100644 --- a/README.rst +++ b/README.rst @@ -97,6 +97,10 @@ your `Cargo.toml`. - Enable the ``threading`` feature in the matrixmultiply package +- ``portable-atomic-critical-section`` + + - Whether ``portable-atomic`` should use ``critical-section`` + How to use with cargo --------------------- diff --git a/src/data_traits.rs b/src/data_traits.rs index 960c561da..5ed856f4d 100644 --- a/src/data_traits.rs +++ b/src/data_traits.rs @@ -11,7 +11,12 @@ #[allow(unused_imports)] use rawpointer::PointerExt; +#[cfg(target_has_atomic = "ptr")] use alloc::sync::Arc; + +#[cfg(not(target_has_atomic = "ptr"))] +use portable_atomic_util::Arc; + #[cfg(not(feature = "std"))] use alloc::vec::Vec; use std::mem::MaybeUninit; diff --git a/src/impl_arc_array.rs b/src/impl_arc_array.rs index 0225c71ac..619ae2506 100644 --- a/src/impl_arc_array.rs +++ b/src/impl_arc_array.rs @@ -7,8 +7,13 @@ // except according to those terms. use crate::imp_prelude::*; + +#[cfg(target_has_atomic = "ptr")] use alloc::sync::Arc; +#[cfg(not(target_has_atomic = "ptr"))] +use portable_atomic_util::Arc; + /// Methods specific to `ArcArray`. /// /// ***See also all methods for [`ArrayBase`]*** diff --git a/src/lib.rs b/src/lib.rs index d6d6efcc2..a13224695 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,7 +123,12 @@ extern crate cblas_sys; #[cfg(feature = "docs")] pub mod doc; +#[cfg(target_has_atomic = "ptr")] use alloc::sync::Arc; + +#[cfg(not(target_has_atomic = "ptr"))] +use portable_atomic_util::Arc; + use std::marker::PhantomData; pub use crate::dimension::dim::*;