Skip to content

Commit

Permalink
API: Drop direct blas-src dependency, update docs for blas integration
Browse files Browse the repository at this point in the history
We can in theory unchain ourselves from the blas-src version and let the
user be responsible for linking in blas in the final product.

Update xtest-blas to test this configuration.

Update instructions in readme for how to use it.
  • Loading branch information
bluss committed Mar 25, 2021
1 parent fdbc884 commit f98e5c0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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,7 +57,7 @@ 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"]
Expand Down
29 changes: 21 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
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
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

1 change: 1 addition & 0 deletions xtest-blas/tests/oper.rs
Original file line number Diff line number Diff line change
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

0 comments on commit f98e5c0

Please sign in to comment.