blas-lapack-rs / cblas Goto Github PK
View Code? Open in Web Editor NEWWrappers for CBLAS (C)
License: Other
Wrappers for CBLAS (C)
License: Other
Hello!!!
Why is imax implemented but imin is not?
This is probably an error with openblas/netlib rather than the rust cblas bindings, but since I discovered the error with the rust bindings, I thought I report it here.
I am getting the wrong results when calling ssyrk
or dsyrk
. See the simple example below:
// extern crate openblas_src; // Same results as with netlib
extern crate netlib_src;
fn main() {
let a_slice = vec![
1., 1.,
1., 1.,
1., 1.,
1., 1.
];
let mut c_slice = vec![
0., 0.,
0., 0.
];
unsafe {
cblas::ssyrk(
cblas::Layout::RowMajor, // change to cblas::Layout::ColumnMajor for correct result
cblas::Part::Upper,
cblas::Transpose::Ordinary,
2 as i32,
4 as i32,
1.0,
&a_slice,
4 as i32,
0.0,
&mut c_slice,
2 as i32,
);
}
println!("{:?}", c_slice);
}
This prints [2.0, 2.0, 0.0, 2.0]
, where I expected [4.0, 4.0, 0.0, 4.0]
.
When changing the code to cblas::Layout::ColumMajor
, it gives the correct result!
Any idea what's going on here?
When I tried to execute this simple program it segfaults in the MKL function, which does not happen when I do the same operation in C. So I'm confused, it also segfaults with dgemm.
extern crate cblas;
extern crate intel_mkl_src;
use cblas::*;
fn main() {
let (m, n, k) = (1024, 1024, 1024);
let a: Vec<f32> = (0..(m * k)).map(|i| i as f32).collect();
let b: Vec<f32> = (0..(k * n)).map(|i| i as f32).collect();
let mut c: Vec<f32> = (0..(m * n)).map(|_| 0.0).collect();
unsafe {
sgemm(
Layout::RowMajor,
Transpose::None,
Transpose::None,
m,
n,
k,
1.0,
&a,
k,
&b,
n,
0.0,
&mut c,
n,
)
}
}
My Cargo.toml file is containing only those dependencies which should work (both static and dynamic produces the segfault):
cblas = "0.4"
intel-mkl-src = {version = "0.8", features = ["mkl-dynamic-ilp64-seq"]}
Does anyone encounter this issue ?
I can't get cblas
and openblas_src
to compile; it used to just work, but I am now getting undefined reference to
cblas_dgemm'using the example in the
README`.
Here is the code:
extern crate cblas;
use cblas::*;
fn main() {
let (m, n, k) = (2, 4, 3);
let a = vec![
1.0, 4.0,
2.0, 5.0,
3.0, 6.0,
];
let b = vec![
1.0, 5.0, 9.0,
2.0, 6.0, 10.0,
3.0, 7.0, 11.0,
4.0, 8.0, 12.0,
];
let mut c = vec![
2.0, 7.0,
6.0, 2.0,
0.0, 7.0,
4.0, 2.0,
];
unsafe {
dgemm(Layout::ColumnMajor, Transpose::None, Transpose::None,
m, n, k, 1.0, &a, m, &b, k, 1.0, &mut c, m);
}
assert!(
c == vec![
40.0, 90.0,
50.0, 100.0,
50.0, 120.0,
60.0, 130.0,
]
)
}
with the following Cargo.toml
:
[package]
name = "cblasfail"
version = "0.1.0"
authors = ""
[dependencies]
cblas = "0.1.5"
openblas-src = "0.5.6"
This is the error message I receive when trying to build this:
error: linking with `cc` failed: exit code: 1
= note: /home/janis/projects/gram_schmidt/target/debug/deps/gram_schmidt-5869234c58a0a51a.gram_schmidt7.rcgu.o: In function `cblas::dnrm2':
/home/janis/.cargo/registry/src/github.com-1ecc6299db9ec823/cblas-0.1.5/src/lib.rs:204: undefined reference to `cblas_dnrm2'
collect2: error: ld returned 1 exit status
This is on rustc 1.23.0
. Not sure what other info might be required.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.