Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Element-wise matrix multiplication should be vectorized/parallelized #72

Open
japaric opened this issue May 11, 2015 · 6 comments
Open
Labels

Comments

@japaric
Copy link
Contributor

japaric commented May 11, 2015

There is no BLAS routine for this operation, and right now it's implemented as a single-threaded for loop.

At the very least the operation should be SIMD accelerated, and perhaps multi-threaded for "big" inputs.

@japaric japaric added the perf label May 11, 2015
@japaric
Copy link
Contributor Author

japaric commented May 11, 2015

yeppp has C routines for this operation.

@vks
Copy link

vks commented May 14, 2015

Doesn't a decent BLAS/LAPACK implementation use SIMD?

@vks
Copy link

vks commented May 14, 2015

Just looked it up: OpenBLAS and ATLAS support vectorization and multi-threading.

@japaric
Copy link
Contributor Author

japaric commented May 15, 2015

@vks By Mat *= Mat I meant element-wise matrix multiplication. Do BLAS libraries provide a routine for that?

@japaric japaric changed the title Mat *= Mat should be parallelized Element-wise matrix multiplication should be vectorized/parallelized May 15, 2015
@vks
Copy link

vks commented May 15, 2015

It seems like only MKL supports it. There are workarounds, see
http://stackoverflow.com/questions/7621520/element-wise-vector-vector-multiplication-in-blas
.

On Fri, May 15, 2015, 04:40 Jorge Aparicio notifications@github.com wrote:

@vks https://github.com/vks By Mat = Mat I meant *element-wise matrix
multiplication. Do BLAS libraries provide a routine for that?


Reply to this email directly or view it on GitHub
#72 (comment).

@japaric
Copy link
Contributor Author

japaric commented May 15, 2015

@vks The BLAS trick is interesting, it does more operations per element than the current implementation, but because the former is vectorized and multithreaded it will likely result in faster execution times for sufficiently large inputs. I think it would also be possible to use it to evaluate the expression alpha * A % B + beta * C (where % denotes element-wise multiplication).

re MKL, we could use it but put it behind an opt-in cargo feature, but I'll like to focus on using standard BLAS routines for the time being.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants