bluss / matrixmultiply

General matrix multiplication of f32 and f64 matrices in Rust. Supports matrices with general strides.
https://docs.rs/matrixmultiply/
Apache License 2.0
209 stars 25 forks source link

error: array lengths can't depend on generic parameters #50

Closed jonathanstrong closed 4 years ago

jonathanstrong commented 4 years ago

ran into this error with nightly (via $ cargo check on master at 4ac62c28):

error: array lengths can't depend on generic parameters
   --> src/sgemm_kernel.rs:223:40
    |
223 |     let mut ab = [_mm256_setzero_ps(); MR];
    |                                        ^^
$ rustc --version
rustc 1.42.0-nightly (a9dd56ff9 2019-12-30)

haven't been able to make much headway in understanding what changed in rustc, but it seems likely this is a compiler bug.

It looks like substituting a const fn implemented on the struct does work (current implementation seems to rely on trait associated constants).

update: for a quick workaround, roll-back to nightly-2019-12-25 (ho ho ho!)

azriel91 commented 4 years ago

Related issue: https://github.com/rust-lang/rust/issues/67743

norru commented 4 years ago

Reproduced in:

Works in:

bluss commented 4 years ago

Thanks! As you know, this code compiles since Rust 1.28, so it's unfortunate that it is broken on nightly.

mvlabat commented 4 years ago

I was able to compile it on rustc 1.42.0-nightly (6d3f4e0aa 2020-01-25), Windows 10

bluss commented 4 years ago

The issue has been fixed in Rust and is fixed in Rust 1.42. It will continue to be an issue (unless further changes are done in matrixmultiply) with older versions, but it is probably too late to matter now.