You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by mb...@apache.org on 2016/01/27 22:54:33 UTC
[1/3] incubator-systemml git commit: [SYSTEMML-488] Performance
wdivmm sparse w/ 4 operands (co-alignment)
Repository: incubator-systemml
Updated Branches:
refs/heads/master 9121e1cef -> 74a7f2861
[SYSTEMML-488] Performance wdivmm sparse w/ 4 operands (co-alignment)
The common case regarding the new wdivmm four operand patterns are
sparse-sparse-dense-dense, where the factors are dense and the remaining
matrices are sparse. Furthermore, the two sparse inputs are often
co-aligned. This patch exploits this characteristics for efficient
co-scans of the two sparse inputs by checking for co-alignment per row.
The performance improvement is due to changed asymptotic behavior by
avoiding binary searches over the second sparse input.
Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/62697512
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/62697512
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/62697512
Branch: refs/heads/master
Commit: 62697512e89ea5b534b883c99739d0e5129ca681
Parents: 9121e1c
Author: Matthias Boehm <mb...@us.ibm.com>
Authored: Tue Jan 26 12:34:06 2016 -0800
Committer: Matthias Boehm <mb...@us.ibm.com>
Committed: Wed Jan 27 13:53:34 2016 -0800
----------------------------------------------------------------------
.../sysml/runtime/matrix/data/LibMatrixMult.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/62697512/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
index 78ce8f0..5e7b2e4 100644
--- a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
+++ b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
@@ -2641,12 +2641,20 @@ public class LibMatrixMult
ret.appendValue( i, wix[k], wval[k] * dotProduct(u, v, uix, wix[k]*cd, cd));
}
else if( four ) { //left/right
- //TODO perf: check for aligment and avoid binary search on X
int k = (cl==0) ? wpos : w.posFIndexGTE(i,cl);
k = (k>=0) ? k : wpos+wlen;
- for( ; k<wpos+wlen && wix[k]<cu; k++ ) {
- double xij = x.get(i, wix[k]);
- wdivmm(wval[k], xij, u, v, c, uix, wix[k]*cd, left, cd);
+ //checking alignment per row is ok because early abort if false,
+ //row nnz likely fit in L1/L2 cache, and asymptotically better if aligned
+ if( w.isAligned(i, x) ) {
+ //O(n) where n is nnz in w/x
+ double[] xvals = x.values(i);
+ for( ; k<wpos+wlen && wix[k]<cu; k++ )
+ wdivmm(wval[k], xvals[k], u, v, c, uix, wix[k]*cd, left, cd);
+ }
+ else {
+ //O(n log m) where n/m are nnz in w/x
+ for( ; k<wpos+wlen && wix[k]<cu; k++ )
+ wdivmm(wval[k], x.get(i, wix[k]), u, v, c, uix, wix[k]*cd, left, cd);
}
}
else { //left/right minus default
[2/3] incubator-systemml git commit: Fix spark matrix-scalar builtin
instructions log/log_nz (opcode checks)
Posted by mb...@apache.org.
Fix spark matrix-scalar builtin instructions log/log_nz (opcode checks)
Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/ad3fa90e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/ad3fa90e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/ad3fa90e
Branch: refs/heads/master
Commit: ad3fa90e925f58c961e67016516f0ad41800d5aa
Parents: 6269751
Author: Matthias Boehm <mb...@us.ibm.com>
Authored: Tue Jan 26 18:08:49 2016 -0800
Committer: Matthias Boehm <mb...@us.ibm.com>
Committed: Wed Jan 27 13:53:41 2016 -0800
----------------------------------------------------------------------
.../instructions/spark/MatrixScalarBuiltinSPInstruction.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/ad3fa90e/src/main/java/org/apache/sysml/runtime/instructions/spark/MatrixScalarBuiltinSPInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/spark/MatrixScalarBuiltinSPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/spark/MatrixScalarBuiltinSPInstruction.java
index a16a779..195e96c 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/spark/MatrixScalarBuiltinSPInstruction.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/spark/MatrixScalarBuiltinSPInstruction.java
@@ -39,8 +39,8 @@ public class MatrixScalarBuiltinSPInstruction extends BuiltinBinarySPInstruction
{
//sanity check opcode
String opcode = getOpcode();
- if ( !(opcode.equalsIgnoreCase("max") || opcode.equalsIgnoreCase("min"))
- ||opcode.equalsIgnoreCase("log") || opcode.equalsIgnoreCase("log_nz") )
+ if (!(opcode.equalsIgnoreCase("max") || opcode.equalsIgnoreCase("min")
+ ||opcode.equalsIgnoreCase("log") || opcode.equalsIgnoreCase("log_nz")) )
{
throw new DMLRuntimeException("Unknown opcode in instruction: " + opcode);
}
[3/3] incubator-systemml git commit: Performance wsloss sparse post
w/ 4 operands (co-alignment)
Posted by mb...@apache.org.
Performance wsloss sparse post w/ 4 operands (co-alignment)
Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/74a7f286
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/74a7f286
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/74a7f286
Branch: refs/heads/master
Commit: 74a7f2861fefc1047cc74dd8125486dffbc70ad4
Parents: ad3fa90
Author: Matthias Boehm <mb...@us.ibm.com>
Authored: Wed Jan 27 13:53:14 2016 -0800
Committer: Matthias Boehm <mb...@us.ibm.com>
Committed: Wed Jan 27 13:53:49 2016 -0800
----------------------------------------------------------------------
.../sysml/runtime/matrix/data/LibMatrixMult.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/74a7f286/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
index 5e7b2e4..056e58a 100644
--- a/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
+++ b/src/main/java/org/apache/sysml/runtime/matrix/data/LibMatrixMult.java
@@ -2205,10 +2205,21 @@ public class LibMatrixMult
int wlen = w.size(i);
int[] wix = w.indexes(i);
double[] wval = w.values(i);
- for( int k=wpos; k<wpos+wlen; k++ ) {
- double xi = mX.quickGetValue(i, wix[k]);
- double uvij = dotProduct(u, v, uix, wix[k]*cd, cd);
- wsloss += wval[k]*(xi-uvij)*(xi-uvij);
+ if( w.isAligned(i, x) ) {
+ //O(n) where n is nnz in w/x
+ double[] xval = x.values(i);
+ for( int k=wpos; k<wpos+wlen; k++ ) {
+ double uvij = dotProduct(u, v, uix, wix[k]*cd, cd);
+ wsloss += wval[k]*(xval[k]-uvij)*(xval[k]-uvij);
+ }
+ }
+ else {
+ //O(n log m) where n/m is nnz in w/x
+ for( int k=wpos; k<wpos+wlen; k++ ) {
+ double xi = mX.quickGetValue(i, wix[k]);
+ double uvij = dotProduct(u, v, uix, wix[k]*cd, cd);
+ wsloss += wval[k]*(xi-uvij)*(xi-uvij);
+ }
}
}
}