Skip to content

Commit

Permalink
Merge pull request #951 from rust-ndarray/disconnect-blas-dependency
Browse files Browse the repository at this point in the history
Drop direct blas-src dependency, update docs for blas integration
  • Loading branch information
bluss committed Mar 25, 2021
2 parents fdbc884 + 5b96f1d commit 175b8f8
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 28 deletions.
8 changes: 2 additions & 6 deletions Cargo.toml
Expand Up @@ -18,8 +18,6 @@ description = "An n-dimensional array for general elements and for numerics. Lig
keywords = ["array", "data-structure", "multidimensional", "matrix", "blas"]
categories = ["data-structures", "science"]

build = "build.rs"

exclude = ["docgen/images/*"]

[lib]
Expand All @@ -39,7 +37,6 @@ approx = { version = "0.4", optional = true , default-features = false }

# Use via the `blas` crate feature!
cblas-sys = { version = "0.1.4", optional = true, default-features = false }
blas-src = { version = "0.7.0", optional = true, default-features = false }
libc = { version = "0.2.82", optional = true }

matrixmultiply = { version = "0.3.0", default-features = false}
Expand All @@ -58,14 +55,13 @@ default = ["std"]

# Enable blas usage
# See README for more instructions
blas = ["cblas-sys", "blas-src", "libc"]
blas = ["cblas-sys", "libc"]

# Old name for the serde feature
serde-1 = ["serde"]

# These features are used for testing
test-blas-openblas-sys = ["blas"]
test = ["test-blas-openblas-sys"]
test = []

# This feature is used for docs
docs = ["approx", "serde", "rayon"]
Expand Down
29 changes: 21 additions & 8 deletions README.rst
Expand Up @@ -96,21 +96,34 @@ How to use with cargo
::

[dependencies]
ndarray = "0.14.0"
ndarray = "0.15.0"

How to enable blas integration. Depend on ``blas-src`` directly to pick a blas
provider. Depend on the same ``blas-src`` version as ``ndarray`` does, for the
selection to work. An example configuration using system openblas is shown
below. Note that only end-user projects (not libraries) should select
provider::
How to enable blas integration
-----------------------------

Blas integration is an optional add-on.

Depend and link to ``blas-src`` directly to pick a blas provider. Ndarray
presently requires a blas provider that provides the ``cblas-sys`` interface. If
further feature selection is needed then you might need to depend directly on
the backend crate's source too (for example ``openblas-src``, to select
``cblas``). The backend version **must** be the one that ``blas-src`` also
depends on.

An example configuration using system openblas is shown below. Note that only
end-user projects (not libraries) should select provider::

[dependencies]
ndarray = { version = "0.14.0", features = ["blas"] }
ndarray = { version = "0.15.0", features = ["blas"] }
blas-src = { version = "0.7.0", default-features = false, features = ["openblas"] }
openblas-src = { version = "0.9", default-features = false, features = ["cblas", "system"] }

For official releases of ``ndarray``, the versions are:
When this is done, your program must also link to ``blas_src`` by using it or
explicitly including it in your code::

extern crate blas_src;

For official releases of ``ndarray``, versions that have been verified to work are:

=========== ============ ================
``ndarray`` ``blas-src`` ``openblas-src``
Expand Down
10 changes: 0 additions & 10 deletions build.rs

This file was deleted.

1 change: 1 addition & 0 deletions scripts/all-tests.sh
Expand Up @@ -18,4 +18,5 @@ cargo test --manifest-path=xtest-serialization/Cargo.toml --verbose
cargo test --manifest-path=xtest-blas/Cargo.toml --verbose
cargo test --examples
CARGO_TARGET_DIR=target/ cargo test --manifest-path=xtest-numeric/Cargo.toml --verbose
CARGO_TARGET_DIR=target/ cargo test --manifest-path=xtest-numeric/Cargo.toml --verbose --features test_blas
([ "$CHANNEL" != "nightly" ] || cargo bench --no-run --verbose --features "$FEATURES")
2 changes: 0 additions & 2 deletions src/lib.rs
Expand Up @@ -124,8 +124,6 @@ extern crate std;
#[cfg(not(feature = "std"))]
extern crate core as std;

#[cfg(feature = "blas")]
extern crate blas_src;
#[cfg(feature = "blas")]
extern crate cblas_sys;

Expand Down
1 change: 0 additions & 1 deletion xtest-blas/src/lib.rs
@@ -1 +0,0 @@

1 change: 1 addition & 0 deletions xtest-blas/tests/oper.rs
Expand Up @@ -2,6 +2,7 @@ extern crate approx;
extern crate defmac;
extern crate ndarray;
extern crate num_traits;
extern crate blas_src;

use ndarray::linalg::general_mat_mul;
use ndarray::linalg::general_mat_vec_mul;
Expand Down
5 changes: 4 additions & 1 deletion xtest-numeric/Cargo.toml
Expand Up @@ -10,6 +10,9 @@ ndarray = { path = "..", features = ["approx"] }
ndarray-rand = { path = "../ndarray-rand/" }
rand_distr = "0.4"

blas-src = { optional = true, version = "0.7.0", default-features = false, features = ["openblas"] }
openblas-src = { optional = true, version = "0.9", default-features = false, features = ["cblas", "system"] }

[dependencies.rand]
version = "0.8.0"
features = ["small_rng"]
Expand All @@ -18,7 +21,7 @@ features = ["small_rng"]
test = false

[features]
test_blas = ["ndarray/blas", "ndarray/test-blas-openblas-sys"]
test_blas = ["ndarray/blas", "blas-src", "openblas-src"]

[profile.dev]
opt-level = 2
Expand Down
3 changes: 3 additions & 0 deletions xtest-numeric/src/lib.rs
@@ -0,0 +1,3 @@
#[cfg(feature = "test_blas")]
extern crate blas_src;

2 changes: 2 additions & 0 deletions xtest-numeric/tests/accuracy.rs
Expand Up @@ -4,6 +4,8 @@ extern crate ndarray;
extern crate ndarray_rand;
extern crate rand;

extern crate numeric_tests;

use ndarray_rand::{RandomExt, F32};
use rand::{Rng, SeedableRng};
use rand::rngs::SmallRng;
Expand Down

0 comments on commit 175b8f8

Please sign in to comment.