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:35 UTC

[3/3] incubator-systemml git commit: Performance wsloss sparse post w/ 4 operands (co-alignment)

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);
+						}	
 					}
 				}	
 		}