[SYSTEMML-552] Performance sparse scalar ops X!=0 (plain memcopy/memset) The performance improvement on a 100kx100x, sp=0.01 usecase was roughly 15-20%. Other shapes and characteristics showed similar improvements, where the benefit increases slightly with the number of non-zeros per row.
Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/0089c3d7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/0089c3d7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/0089c3d7 Branch: refs/heads/master Commit: 0089c3d793f9facf6e96e353beb04fd2e7dee700 Parents: 79ae541 Author: Matthias Boehm <[email protected]> Authored: Sun Mar 6 17:02:07 2016 -0800 Committer: Matthias Boehm <[email protected]> Committed: Mon Mar 7 12:23:22 2016 -0800 ---------------------------------------------------------------------- .../apache/sysml/runtime/matrix/data/LibMatrixBincell.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/0089c3d7/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 593e201..5a0ccdb 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 @@ -958,14 +958,9 @@ public class LibMatrixBincell SparseRow crow = new SparseRow(alen); crow.setSize(alen); - //memcopy/memset of indexes and values - //note: currently we do a safe copy of values because in special cases there - //might exist zeros in a sparserow and we need to ensure result correctness + //memcopy/memset of indexes/values (sparseblock guarantees absence of 0s) System.arraycopy(aix, apos, crow.indexes(), 0, alen); - //Arrays.fill(crow.getValueContainer(), 0, alen, 1); - double[] cvals = crow.values(); - for(int j=0; j<alen; j++) - cvals[j] = (avals[apos+j] != 0) ? 1 : 0; + Arrays.fill(crow.values(), 0, alen, 1); c.set(r, crow, false); ret.nonZeros+=alen; }
