Repository: systemml Updated Branches: refs/heads/master 7027a532d -> c3af9adff
[MINOR] Performance ternary axpy operations w/ empty inputs This patch makes a minor performance improvement to the ternary axpy operations +* and -*. So far, we used a generic and slow fallback whenever one of the inputs was empty. Instead we now simply use a shallow copy (i.e., meta data operation) whenever possible. This helps improve the runtime of paramserv's update function. Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/c3af9adf Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/c3af9adf Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/c3af9adf Branch: refs/heads/master Commit: c3af9adffb492ebf7ca817abf40c4117b3dc2df6 Parents: 7027a53 Author: Matthias Boehm <[email protected]> Authored: Fri Jun 22 12:32:40 2018 -0700 Committer: Matthias Boehm <[email protected]> Committed: Fri Jun 22 12:32:40 2018 -0700 ---------------------------------------------------------------------- .../sysml/runtime/matrix/data/LibMatrixBincell.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/c3af9adf/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixBincell.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixBincell.java b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixBincell.java index 48fce40..d81bf07 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixBincell.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixBincell.java @@ -195,6 +195,9 @@ public class LibMatrixBincell private static void safeBinary(MatrixBlock m1, MatrixBlock m2, MatrixBlock ret, BinaryOperator op) { boolean skipEmpty = (op.fn instanceof Multiply || isSparseSafeDivide(op, m2) ); + boolean copyLeftRightEmpty = (op.fn instanceof Plus || op.fn instanceof Minus + || op.fn instanceof PlusMultiply || op.fn instanceof MinusMultiply); + boolean copyRightLeftEmpty = (op.fn instanceof Plus || op.fn instanceof PlusMultiply); //skip empty blocks (since sparse-safe) if( m1.isEmptyBlock(false) && m2.isEmptyBlock(false) @@ -225,7 +228,15 @@ public class LibMatrixBincell } else //MATRIX - MATRIX { - if(m1.sparse && m2.sparse) { + if( copyLeftRightEmpty && m2.isEmpty() ) { + //ret remains unchanged so a shallow copy is sufficient + ret.copyShallow(m1); + } + else if( copyRightLeftEmpty && m1.isEmpty() ) { + //ret remains unchanged so a shallow copy is sufficient + ret.copyShallow(m2); + } + else if(m1.sparse && m2.sparse) { safeBinaryMMSparseSparse(m1, m2, ret, op); } else if( !ret.sparse && (m1.sparse || m2.sparse) &&
