This is an automated email from the ASF dual-hosted git repository.
mboehm7 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/master by this push:
new 9e01614 [SYSTEMDS-3109] Performance sparse binary matrix-vector
operations
9e01614 is described below
commit 9e016141264b3a83eedaf2b03c3e6463f242f272
Author: Matthias Boehm <[email protected]>
AuthorDate: Sun Aug 29 21:14:36 2021 +0200
[SYSTEMDS-3109] Performance sparse binary matrix-vector operations
This patch makes several smaller improvements to sparse binary
matrix-vector operations, especially for sparse-safe operations like
multiply and division. This includes skipping zero values for division,
and pre-allocating sparse output rows. On a scenario of 100K x 100 and
50 operations, the dense X/rowVect required 11.3s while sparse (with
sparsity 0.1) required 33.6s. With skipping it went down to 11.9s and
with skipping and pre-allocation to 8.7s.
Thanks to Sebastian Baunsgaard for catching this performance issue.
---
.../java/org/apache/sysds/runtime/matrix/data/LibMatrixBincell.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git
a/src/main/java/org/apache/sysds/runtime/matrix/data/LibMatrixBincell.java
b/src/main/java/org/apache/sysds/runtime/matrix/data/LibMatrixBincell.java
index 2fde00d..6d53ff7 100644
--- a/src/main/java/org/apache/sysds/runtime/matrix/data/LibMatrixBincell.java
+++ b/src/main/java/org/apache/sysds/runtime/matrix/data/LibMatrixBincell.java
@@ -605,7 +605,7 @@ public class LibMatrixBincell {
private static void safeBinaryMVSparse(MatrixBlock m1, MatrixBlock m2,
MatrixBlock ret, BinaryOperator op) {
boolean isMultiply = (op.fn instanceof Multiply);
- boolean skipEmpty = (isMultiply);
+ boolean skipEmpty = (isMultiply || isSparseSafeDivide(op, m2));
int rlen = m1.rlen;
int clen = m1.clen;
@@ -661,7 +661,8 @@ public class LibMatrixBincell {
for( int i=0; i<rlen; i++ ) {
if( skipEmpty && (a==null || a.isEmpty(i)) )
continue; //skip empty rows
-
+ if( skipEmpty && ret.sparse )
+ ret.sparseBlock.allocate(i, a.size(i));
int lastIx = -1;
if( a!=null && !a.isEmpty(i) ) {
int apos = a.pos(i);