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 2017/05/27 21:33:23 UTC

[1/2] incubator-systemml git commit: [MINOR] Cleanup parser data structures (unused kind/default fields)

Repository: incubator-systemml
Updated Branches:
  refs/heads/master ac04b5708 -> 14fd9da1b


[MINOR] Cleanup parser data structures (unused kind/default fields)

Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/214b1772
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/214b1772
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/214b1772

Branch: refs/heads/master
Commit: 214b17725e2394187ed873aa25a544247f8cfb8a
Parents: ac04b57
Author: Matthias Boehm <mb...@gmail.com>
Authored: Fri May 26 21:57:54 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Fri May 26 21:57:54 2017 -0700

----------------------------------------------------------------------
 .../apache/sysml/parser/BinaryExpression.java   |  6 --
 .../apache/sysml/parser/BooleanExpression.java  |  2 -
 .../apache/sysml/parser/BooleanIdentifier.java  | 11 +--
 .../sysml/parser/BuiltinFunctionExpression.java |  5 +-
 .../org/apache/sysml/parser/DMLTranslator.java  | 80 +++++++++-----------
 .../org/apache/sysml/parser/DataExpression.java | 56 ++++++--------
 .../org/apache/sysml/parser/DataIdentifier.java | 29 +------
 .../apache/sysml/parser/DoubleIdentifier.java   | 18 ++---
 .../org/apache/sysml/parser/Expression.java     | 24 ++----
 .../sysml/parser/ExternalFunctionStatement.java |  1 -
 .../sysml/parser/FunctionCallIdentifier.java    |  9 +--
 .../apache/sysml/parser/FunctionStatement.java  |  1 -
 .../org/apache/sysml/parser/Identifier.java     |  1 -
 .../apache/sysml/parser/IndexedIdentifier.java  |  4 +-
 .../org/apache/sysml/parser/IntIdentifier.java  | 18 ++---
 .../ParameterizedBuiltinFunctionExpression.java | 10 +--
 .../sysml/parser/RelationalExpression.java      |  3 -
 .../org/apache/sysml/parser/StatementBlock.java | 26 ++-----
 .../apache/sysml/parser/StringIdentifier.java   | 10 +--
 .../cp/FunctionCallCPInstruction.java           | 51 ++++++-------
 20 files changed, 128 insertions(+), 237 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/BinaryExpression.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/BinaryExpression.java b/src/main/java/org/apache/sysml/parser/BinaryExpression.java
index baebcd0..121e488 100644
--- a/src/main/java/org/apache/sysml/parser/BinaryExpression.java
+++ b/src/main/java/org/apache/sysml/parser/BinaryExpression.java
@@ -24,15 +24,11 @@ import java.util.HashMap;
 
 public class BinaryExpression extends Expression 
 {
-	
 	private Expression _left;
 	private Expression _right;
 	private BinaryOp _opcode;
-
 	
 	public Expression rewriteExpression(String prefix) throws LanguageException{
-		
-		
 		BinaryExpression newExpr = new BinaryExpression(this._opcode,
 				this.getFilename(), this.getBeginLine(), this.getBeginColumn(), this.getEndLine(), this.getEndColumn());
 		newExpr.setLeft(_left.rewriteExpression(prefix));
@@ -41,7 +37,6 @@ public class BinaryExpression extends Expression
 	}
 	
 	public BinaryExpression(BinaryOp bop) {
-		_kind = Kind.BinaryOp;
 		_opcode = bop;
 		
 		setFilename("MAIN SCRIPT");
@@ -52,7 +47,6 @@ public class BinaryExpression extends Expression
 	}
 	
 	public BinaryExpression(BinaryOp bop, String filename, int beginLine, int beginColumn, int endLine, int endColumn) {
-		_kind = Kind.BinaryOp;
 		_opcode = bop;
 		
 		setFilename(filename);

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/BooleanExpression.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/BooleanExpression.java b/src/main/java/org/apache/sysml/parser/BooleanExpression.java
index 8dd84e5..2996da5 100644
--- a/src/main/java/org/apache/sysml/parser/BooleanExpression.java
+++ b/src/main/java/org/apache/sysml/parser/BooleanExpression.java
@@ -30,7 +30,6 @@ public class BooleanExpression extends Expression
 	private BooleanOp _opcode;
 	
 	public BooleanExpression(BooleanOp bop){
-		_kind = Kind.BooleanOp;
 		_opcode = bop;
 		
 		setFilename("MAIN SCRIPT");
@@ -41,7 +40,6 @@ public class BooleanExpression extends Expression
 	}
 	
 	public BooleanExpression(BooleanOp bop, String filename, int beginLine, int beginColumn, int endLine, int endColumn){
-		_kind = Kind.BooleanOp;
 		_opcode = bop;
 		
 		setFilename(filename);

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/BooleanIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/BooleanIdentifier.java b/src/main/java/org/apache/sysml/parser/BooleanIdentifier.java
index 2bb441e..501926c 100644
--- a/src/main/java/org/apache/sysml/parser/BooleanIdentifier.java
+++ b/src/main/java/org/apache/sysml/parser/BooleanIdentifier.java
@@ -23,18 +23,15 @@ package org.apache.sysml.parser;
 
 public class BooleanIdentifier extends ConstIdentifier 
 {
-	
 	private boolean _val;
 	
-	
 	public BooleanIdentifier(boolean val, String filename, int blp, int bcp, int elp, int ecp){
 		super();
 		 _val = val;
-		_kind = Kind.Data;
-		this.setDimensions(0,0);
-        this.computeDataType();
-        this.setValueType(ValueType.BOOLEAN);
-        this.setAllPositions(filename, blp, bcp, elp, ecp);
+		setDimensions(0,0);
+        computeDataType();
+        setValueType(ValueType.BOOLEAN);
+        setAllPositions(filename, blp, bcp, elp, ecp);
 	}
 	
 	public Expression rewriteExpression(String prefix) throws LanguageException{

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java b/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
index 5efa3e9..e3b3e79 100644
--- a/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
+++ b/src/main/java/org/apache/sysml/parser/BuiltinFunctionExpression.java
@@ -28,14 +28,12 @@ import org.apache.sysml.runtime.util.ConvolutionUtils;
 
 public class BuiltinFunctionExpression extends DataIdentifier 
 {
-	
 	protected Expression[] 	  _args = null;
 	private BuiltinFunctionOp _opcode;
 
 	public BuiltinFunctionExpression(BuiltinFunctionOp bifop, ArrayList<ParameterExpression> args, String fname, int blp, int bcp, int elp, int ecp) {
-		_kind = Kind.BuiltinFunctionOp;
 		_opcode = bifop;
-		this.setAllPositions(fname, blp, bcp, elp, ecp);
+		setAllPositions(fname, blp, bcp, elp, ecp);
 		args = expandConvolutionArguments(args);
 		_args = new Expression[args.size()];
 		for(int i=0; i < args.size(); i++) {
@@ -44,7 +42,6 @@ public class BuiltinFunctionExpression extends DataIdentifier
 	}
 
 	public BuiltinFunctionExpression(BuiltinFunctionOp bifop, Expression[] args, String fname, int blp, int bcp, int elp, int ecp) {
-		_kind = Kind.BuiltinFunctionOp;
 		_opcode = bifop;
 		_args = new Expression[args.length];
 		for(int i=0; i < args.length; i++) {

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/DMLTranslator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/DMLTranslator.java b/src/main/java/org/apache/sysml/parser/DMLTranslator.java
index 0ff6c60..a40c736 100644
--- a/src/main/java/org/apache/sysml/parser/DMLTranslator.java
+++ b/src/main/java/org/apache/sysml/parser/DMLTranslator.java
@@ -1403,72 +1403,64 @@ public class DMLTranslator
 	 * @throws ParseException if ParseException occurs
 	 */
 	private Hop processExpression(Expression source, DataIdentifier target, HashMap<String, Hop> hops) throws ParseException {
-		if (source.getKind() == Expression.Kind.BinaryOp) {
-			return processBinaryExpression((BinaryExpression) source, target, hops);
-		} else if (source.getKind() == Expression.Kind.RelationalOp) {
-			return processRelationalExpression((RelationalExpression) source, target, hops);
-		} else if (source.getKind() == Expression.Kind.BooleanOp) {
-			return processBooleanExpression((BooleanExpression) source, target, hops);
-		} else if (source.getKind() == Expression.Kind.Data) {
-			if (source instanceof IndexedIdentifier){
-				IndexedIdentifier sourceIndexed = (IndexedIdentifier) source;
-				return processIndexingExpression(sourceIndexed,target,hops);
-			} else if (source instanceof IntIdentifier) {
+		try {	
+			if( source instanceof BinaryExpression )
+				return processBinaryExpression((BinaryExpression) source, target, hops);
+			else if( source instanceof RelationalExpression )
+				return processRelationalExpression((RelationalExpression) source, target, hops);
+			else if( source instanceof BooleanExpression )
+				return processBooleanExpression((BooleanExpression) source, target, hops);
+			else if( source instanceof BuiltinFunctionExpression )
+				return processBuiltinFunctionExpression((BuiltinFunctionExpression) source, target, hops);
+			else if( source instanceof ParameterizedBuiltinFunctionExpression )
+				return processParameterizedBuiltinFunctionExpression((ParameterizedBuiltinFunctionExpression)source, target, hops);
+			else if( source instanceof DataExpression ) {
+				Hop ae = (Hop)processDataExpression((DataExpression)source, target, hops);
+				if (ae instanceof DataOp){
+					String formatName = ((DataExpression)source).getVarParam(DataExpression.FORMAT_TYPE).toString();
+					((DataOp)ae).setInputFormatType(Expression.convertFormatType(formatName));
+				}
+				return ae;
+			}
+			else if (source instanceof IndexedIdentifier)
+				return processIndexingExpression((IndexedIdentifier) source,target,hops);
+			else if (source instanceof IntIdentifier) {
 				IntIdentifier sourceInt = (IntIdentifier) source;
 				LiteralOp litop = new LiteralOp(sourceInt.getValue());
 				litop.setAllPositions(sourceInt.getBeginLine(), sourceInt.getBeginColumn(), sourceInt.getEndLine(), sourceInt.getEndColumn());
 				setIdentifierParams(litop, sourceInt);
 				return litop;
-			} else if (source instanceof DoubleIdentifier) {
+			} 
+			else if (source instanceof DoubleIdentifier) {
 				DoubleIdentifier sourceDouble = (DoubleIdentifier) source;
 				LiteralOp litop = new LiteralOp(sourceDouble.getValue());
 				litop.setAllPositions(sourceDouble.getBeginLine(), sourceDouble.getBeginColumn(), sourceDouble.getEndLine(), sourceDouble.getEndColumn());
 				setIdentifierParams(litop, sourceDouble);
 				return litop;
-			} else if (source instanceof DataIdentifier) {
-				DataIdentifier sourceId = (DataIdentifier) source;
-				return hops.get(sourceId.getName());
-			} else if (source instanceof BooleanIdentifier) {
+			}
+			else if (source instanceof BooleanIdentifier) {
 				BooleanIdentifier sourceBoolean = (BooleanIdentifier) source;
 				LiteralOp litop = new LiteralOp(sourceBoolean.getValue());
 				litop.setAllPositions(sourceBoolean.getBeginLine(), sourceBoolean.getBeginColumn(), sourceBoolean.getEndLine(), sourceBoolean.getEndColumn());
 				setIdentifierParams(litop, sourceBoolean);
 				return litop;
-			} else if (source instanceof StringIdentifier) {
+			} 
+			else if (source instanceof StringIdentifier) {
 				StringIdentifier sourceString = (StringIdentifier) source;
 				LiteralOp litop = new LiteralOp(sourceString.getValue());
 				litop.setAllPositions(sourceString.getBeginLine(), sourceString.getBeginColumn(), sourceString.getEndLine(), sourceString.getEndColumn());
 				setIdentifierParams(litop, sourceString);
 				return litop;
-			}
-		} else if (source.getKind() == Expression.Kind.BuiltinFunctionOp) {
-			try {
-				return processBuiltinFunctionExpression((BuiltinFunctionExpression) source, target, hops);
-			} catch (HopsException e) {
-				throw new ParseException(e.getMessage());
-			}
-		} else if (source.getKind() == Expression.Kind.ParameterizedBuiltinFunctionOp ) {
-			try {
-				return processParameterizedBuiltinFunctionExpression((ParameterizedBuiltinFunctionExpression)source, target, hops);
-			} catch ( HopsException e ) {
-				throw new ParseException(e.getMessage());
-			}
-		} else if (source.getKind() == Expression.Kind.DataOp ) {
-			try {	
-				Hop ae = (Hop)processDataExpression((DataExpression)source, target, hops);
-				
-				if (ae instanceof DataOp){
-					String formatName = ((DataExpression)source).getVarParam(DataExpression.FORMAT_TYPE).toString();
-					((DataOp)ae).setInputFormatType(Expression.convertFormatType(formatName));
-				}
-				//hops.put(target.getName(), ae);
-				return ae;
-			} catch ( Exception e ) {
-				throw new ParseException(e.getMessage());
-			}
+			} 
+			else if (source instanceof DataIdentifier)
+				return hops.get(((DataIdentifier) source).getName());
+		} 
+		catch ( Exception e ) {
+			throw new ParseException(e.getMessage());
 		}
+		
 		return null;
-	} // end method processExpression
+	}
 
 	private DataIdentifier createTarget(Expression source) {
 		Identifier id = source.getOutput();

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/DataExpression.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/DataExpression.java b/src/main/java/org/apache/sysml/parser/DataExpression.java
index bb10af4..51a51c9 100644
--- a/src/main/java/org/apache/sysml/parser/DataExpression.java
+++ b/src/main/java/org/apache/sysml/parser/DataExpression.java
@@ -380,11 +380,9 @@ public class DataExpression extends DataIdentifier
 	
 	public DataExpression(DataOp op, HashMap<String,Expression> varParams, 
 			String filename, int blp, int bcp, int elp, int ecp) {
-		
-		_kind = Kind.DataOp;
 		_opcode = op;
 		_varParams = varParams;
-		this.setAllPositions(filename, blp, bcp, elp, ecp);
+		setAllPositions(filename, blp, bcp, elp, ecp);
 	}
 
 	public Expression rewriteExpression(String prefix) throws LanguageException {
@@ -515,26 +513,23 @@ public class DataExpression extends DataIdentifier
 		if (fileNameExpr instanceof ConstIdentifier){
 			return fileNameExpr.toString();
 		}
-		else if (fileNameExpr instanceof BinaryExpression){
+		else if (fileNameExpr instanceof BinaryExpression) {
 			BinaryExpression expr = (BinaryExpression)fileNameExpr;
-							
-			if (expr.getKind()== Expression.Kind.BinaryOp){
-				Expression.BinaryOp op = expr.getOpCode();
-				switch (op){
-				case PLUS:
-						filename = "";
-						filename = fileNameCat(expr, currConstVars, filename, conditional);
-						// Since we have computed the value of filename, we update
-						// varParams with a const string value
-						StringIdentifier fileString = new StringIdentifier(filename, 
-								this.getFilename(), this.getBeginLine(), this.getBeginColumn(), 
-								this.getEndLine(), this.getEndColumn());
-						removeVarParam(IO_FILENAME);
-						addVarParam(IO_FILENAME, fileString);
-					break;
-				default:
-					raiseValidateError("for read method, parameter " + IO_FILENAME + " can only be const string concatenations. ", conditional);
-				}
+			Expression.BinaryOp op = expr.getOpCode();
+			switch (op){
+			case PLUS:
+					filename = "";
+					filename = fileNameCat(expr, currConstVars, filename, conditional);
+					// Since we have computed the value of filename, we update
+					// varParams with a const string value
+					StringIdentifier fileString = new StringIdentifier(filename, 
+							this.getFilename(), this.getBeginLine(), this.getBeginColumn(), 
+							this.getEndLine(), this.getEndColumn());
+					removeVarParam(IO_FILENAME);
+					addVarParam(IO_FILENAME, fileString);
+				break;
+			default:
+				raiseValidateError("for read method, parameter " + IO_FILENAME + " can only be const string concatenations. ", conditional);
 			}
 		}
 		else {
@@ -1728,17 +1723,14 @@ public class DataExpression extends DataIdentifier
 	{
 		// Processing the left node first
 		if (expr.getLeft() instanceof BinaryExpression 
-				&& ((BinaryExpression)expr.getLeft()).getKind()== BinaryExpression.Kind.BinaryOp
-				&& ((BinaryExpression)expr.getLeft()).getOpCode() == BinaryOp.PLUS){
+			&& ((BinaryExpression)expr.getLeft()).getOpCode() == BinaryOp.PLUS){
 			filename = fileNameCat((BinaryExpression)expr.getLeft(), currConstVars, filename, conditional)+ filename;
 		}
 		else if (expr.getLeft() instanceof ConstIdentifier){
 			filename = ((ConstIdentifier)expr.getLeft()).toString()+ filename;
 		}
 		else if (expr.getLeft() instanceof DataIdentifier 
-				&& ((DataIdentifier)expr.getLeft()).getDataType() == Expression.DataType.SCALAR
-				&& ((DataIdentifier)expr.getLeft()).getKind() == Expression.Kind.Data){ 
-				//&& ((DataIdentifier)expr.getLeft()).getValueType() == Expression.ValueType.STRING){
+			&& ((DataIdentifier)expr.getLeft()).getDataType() == Expression.DataType.SCALAR){ 
 			String name = ((DataIdentifier)expr.getLeft()).getName();
 			filename = ((StringIdentifier)currConstVars.get(name)).getValue() + filename;
 		}
@@ -1746,9 +1738,8 @@ public class DataExpression extends DataIdentifier
 			raiseValidateError("Parameter " + IO_FILENAME + " only supports a const string or const string concatenations.", conditional);
 		}
 		// Now process the right node
-		if (expr.getRight()instanceof BinaryExpression 
-				&& ((BinaryExpression)expr.getRight()).getKind()== BinaryExpression.Kind.BinaryOp
-				&& ((BinaryExpression)expr.getRight()).getOpCode() == BinaryOp.PLUS){
+		if (expr.getRight() instanceof BinaryExpression 
+			&& ((BinaryExpression)expr.getRight()).getOpCode() == BinaryOp.PLUS){
 			filename = filename + fileNameCat((BinaryExpression)expr.getRight(), currConstVars, filename, conditional);
 		}
 		// DRB: CHANGE
@@ -1756,9 +1747,8 @@ public class DataExpression extends DataIdentifier
 			filename = filename + ((ConstIdentifier)expr.getRight()).toString();
 		}
 		else if (expr.getRight() instanceof DataIdentifier 
-				&& ((DataIdentifier)expr.getRight()).getDataType() == Expression.DataType.SCALAR
-				&& ((DataIdentifier)expr.getRight()).getKind() == Expression.Kind.Data 
-				&& ((DataIdentifier)expr.getRight()).getValueType() == Expression.ValueType.STRING){
+			&& ((DataIdentifier)expr.getRight()).getDataType() == Expression.DataType.SCALAR
+			&& ((DataIdentifier)expr.getRight()).getValueType() == Expression.ValueType.STRING){
 			String name = ((DataIdentifier)expr.getRight()).getName();
 			filename =  filename + ((StringIdentifier)currConstVars.get(name)).getValue();
 		}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/DataIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/DataIdentifier.java b/src/main/java/org/apache/sysml/parser/DataIdentifier.java
index 158829a..1cd00d1 100644
--- a/src/main/java/org/apache/sysml/parser/DataIdentifier.java
+++ b/src/main/java/org/apache/sysml/parser/DataIdentifier.java
@@ -22,17 +22,13 @@ package org.apache.sysml.parser;
 
 public class DataIdentifier extends Identifier 
 {
-	
-	protected String 	_name;
-	protected String 	_valueTypeString;	
-	protected String 	_defaultValue;
+	protected String _name;
+	protected String _valueTypeString;	
 	
 	public DataIdentifier(DataIdentifier passed){
 		setProperties(passed);
-		_kind = Kind.Data;
 		_name = passed.getName();
 		_valueTypeString = passed.getValueType().toString();	
-		_defaultValue = passed.getDefaultValue();
 		
 		// set location information
 		setFilename(passed.getFilename());
@@ -44,7 +40,7 @@ public class DataIdentifier extends Identifier
 	
 	public Expression rewriteExpression(String prefix) throws LanguageException{
 		DataIdentifier newId = new DataIdentifier(this);
-		String newIdName = prefix + this._name;
+		String newIdName = prefix + _name;
 		newId.setName(newIdName);
 				
 		return newId;
@@ -53,23 +49,10 @@ public class DataIdentifier extends Identifier
 	public DataIdentifier(String name){
 		super();
 		_name = name;
-		_kind = Kind.Data;
-		_defaultValue = null;
-
 	}
 	
-	/*
-	public DataIdentifier(String name, int line, int col){
-		super();
-		_name = name;
-		_kind = Kind.Data;
-		_defaultValue = null;	
-	}
-	*/
 	public DataIdentifier(){
 		_name = null;
-		_kind = null;
-		_defaultValue = null;
 	}
 
 	public String getName(){
@@ -78,12 +61,6 @@ public class DataIdentifier extends Identifier
 	public void setName(String name){
 		_name = name;
 	}
-	public String getDefaultValue(){
-		return _defaultValue;
-	}
-	public void setDefaultValue(String val){
-		_defaultValue = val;
-	}
 	
 	@Override
 	public String toString() {

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/DoubleIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/DoubleIdentifier.java b/src/main/java/org/apache/sysml/parser/DoubleIdentifier.java
index 31ce3c3..febdbb4 100644
--- a/src/main/java/org/apache/sysml/parser/DoubleIdentifier.java
+++ b/src/main/java/org/apache/sysml/parser/DoubleIdentifier.java
@@ -32,21 +32,19 @@ public class DoubleIdentifier extends ConstIdentifier
 	public DoubleIdentifier(double val, String filename, int blp, int bcp, int elp, int ecp){
 		super();
 		 _val = val;
-		_kind = Kind.Data;
-		this.setDimensions(0,0);
-        this.computeDataType();
-        this.setValueType(ValueType.DOUBLE);
-        this.setAllPositions(filename, blp, bcp, elp, ecp);
+		setDimensions(0,0);
+        computeDataType();
+        setValueType(ValueType.DOUBLE);
+        setAllPositions(filename, blp, bcp, elp, ecp);
 	}
 	
 	public DoubleIdentifier(DoubleIdentifier d, String filename, int blp, int bcp, int elp, int ecp){
 		super();
 		 _val = d.getValue();
-		_kind = Kind.Data;
-		this.setDimensions(0,0);
-        this.computeDataType();
-        this.setValueType(ValueType.DOUBLE);
-        this.setAllPositions(filename, blp, bcp, elp, ecp);
+		setDimensions(0,0);
+        computeDataType();
+        setValueType(ValueType.DOUBLE);
+        setAllPositions(filename, blp, bcp, elp, ecp);
 	}
 	
 	public Expression rewriteExpression(String prefix) throws LanguageException{

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/Expression.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/Expression.java b/src/main/java/org/apache/sysml/parser/Expression.java
index 1bb7b35..01a0a77 100644
--- a/src/main/java/org/apache/sysml/parser/Expression.java
+++ b/src/main/java/org/apache/sysml/parser/Expression.java
@@ -26,19 +26,12 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.sysml.hops.Hop.FileFormatTypes;
+import org.apache.sysml.runtime.controlprogram.parfor.util.IDSequence;
 
 
 public abstract class Expression 
 {
 	/**
-	 * The kind of expression. Can be an operator (unary operator, binary operator, boolean operator, built-in function operator,
-	 * parameterized built-in function operator, data operator, relational operator, external built-in function operator, function call operator), data, or literal.
-	 */
-	public enum Kind {
-		BinaryOp, BooleanOp, BuiltinFunctionOp, ParameterizedBuiltinFunctionOp, DataOp, Data, RelationalOp, FunctionCallOp
-	};
-
-	/**
 	 * Binary operators.
 	 */
 	public enum BinaryOp {
@@ -194,19 +187,16 @@ public abstract class Expression
 	};
 	
 	protected static final Log LOG = LogFactory.getLog(Expression.class.getName());
-
-	public abstract Expression rewriteExpression(String prefix) throws LanguageException;
-		
 	
-	protected Kind _kind;
+	private static final IDSequence _tempId = new IDSequence();
 	protected Identifier[] _outputs;
 
-	private static int _tempId;
-
 	public Expression() {
 		_outputs = null;
 	}
 
+	public abstract Expression rewriteExpression(String prefix) throws LanguageException;
+	
 	public void setOutput(Identifier output) {
 		if ( _outputs == null) {
 			_outputs = new Identifier[1];
@@ -214,10 +204,6 @@ public abstract class Expression
 		_outputs[0] = output;
 	}
 
-	public Kind getKind() {
-		return _kind;
-	}
-
 	/**
 	 * Obtain identifier.
 	 * 
@@ -363,7 +349,7 @@ public abstract class Expression
 	 * @return Temporary name of expression.
 	 */
 	public static String getTempName() {
-		return "parsertemp" + _tempId++;
+		return "parsertemp" + _tempId.getNextID();
 	}
 
 	public abstract VariableSet variablesRead();

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/ExternalFunctionStatement.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/ExternalFunctionStatement.java b/src/main/java/org/apache/sysml/parser/ExternalFunctionStatement.java
index a9f76e4..14cca05 100644
--- a/src/main/java/org/apache/sysml/parser/ExternalFunctionStatement.java
+++ b/src/main/java/org/apache/sysml/parser/ExternalFunctionStatement.java
@@ -113,7 +113,6 @@ public class ExternalFunctionStatement extends FunctionStatement
 		for (int i=0; i<_inputParams.size(); i++){
 			DataIdentifier curr = _inputParams.get(i);
 			sb.append(curr.getName());
-			if (curr.getDefaultValue() != null) sb.append(" = " + curr.getDefaultValue());
 			if (i < _inputParams.size()-1) sb.append(", ");
 		}
 		sb.append(") return (");

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/FunctionCallIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/FunctionCallIdentifier.java b/src/main/java/org/apache/sysml/parser/FunctionCallIdentifier.java
index 297c8ba..8f48789 100644
--- a/src/main/java/org/apache/sysml/parser/FunctionCallIdentifier.java
+++ b/src/main/java/org/apache/sysml/parser/FunctionCallIdentifier.java
@@ -68,25 +68,18 @@ public class FunctionCallIdentifier extends DataIdentifier
 			
 		fci._name = this._name;
 		fci._namespace = this._namespace;
-		fci._opcode = this._opcode;
-		fci._kind = Kind.FunctionCallOp;	 
+		fci._opcode = this._opcode;	 
 		
 		return fci;
 	}
 	
-	
-	
 	public FunctionCallIdentifier(){}
 	
 	public FunctionCallIdentifier(ArrayList<ParameterExpression> paramExpressions) {
-		
 		_paramExprs = paramExpressions;
 		_opcode = null;
-		_kind = Kind.FunctionCallOp;	 
 	}
 	
-	
-	
 	public FunctCallOp getOpCode() {
 		return _opcode;
 	}

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/FunctionStatement.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/FunctionStatement.java b/src/main/java/org/apache/sysml/parser/FunctionStatement.java
index ea2ed5c..07a2284 100644
--- a/src/main/java/org/apache/sysml/parser/FunctionStatement.java
+++ b/src/main/java/org/apache/sysml/parser/FunctionStatement.java
@@ -93,7 +93,6 @@ public class FunctionStatement extends Statement
 		for (int i=0; i<_inputParams.size(); i++){
 			DataIdentifier curr = _inputParams.get(i);
 			sb.append(curr.getName());
-			if (curr.getDefaultValue() != null) sb.append(" = " + curr.getDefaultValue());
 			if (i < _inputParams.size()-1) sb.append(", ");
 		}
 		sb.append(") return (");

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/Identifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/Identifier.java b/src/main/java/org/apache/sysml/parser/Identifier.java
index 8789875..4d62f1a 100644
--- a/src/main/java/org/apache/sysml/parser/Identifier.java
+++ b/src/main/java/org/apache/sysml/parser/Identifier.java
@@ -25,7 +25,6 @@ import org.apache.sysml.parser.LanguageException.LanguageErrorCodes;
 
 public abstract class Identifier extends Expression
 {
-	
 	protected DataType _dataType;
 	protected ValueType _valueType;
 	protected long _dim1;

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/IndexedIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/IndexedIdentifier.java b/src/main/java/org/apache/sysml/parser/IndexedIdentifier.java
index 637e445..0fda2f9 100644
--- a/src/main/java/org/apache/sysml/parser/IndexedIdentifier.java
+++ b/src/main/java/org/apache/sysml/parser/IndexedIdentifier.java
@@ -569,11 +569,9 @@ public class IndexedIdentifier extends DataIdentifier
 		newIndexedIdentifier.setOriginalDimensions(this._origDim1, this._origDim2);
 		
 		// set remaining properties (specific to DataIdentifier)
-		newIndexedIdentifier._kind = Kind.Data;
 		newIndexedIdentifier._name = prefix + this._name;
 		newIndexedIdentifier._valueTypeString = this.getValueType().toString();	
-		newIndexedIdentifier._defaultValue = this._defaultValue;
-	
+		
 		// creates rewritten expression (deep copy)
 		newIndexedIdentifier._rowLowerBound = (_rowLowerBound == null) ? null : _rowLowerBound.rewriteExpression(prefix);
 		newIndexedIdentifier._rowUpperBound = (_rowUpperBound == null) ? null : _rowUpperBound.rewriteExpression(prefix);

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/IntIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/IntIdentifier.java b/src/main/java/org/apache/sysml/parser/IntIdentifier.java
index 070da79..60463e6 100644
--- a/src/main/java/org/apache/sysml/parser/IntIdentifier.java
+++ b/src/main/java/org/apache/sysml/parser/IntIdentifier.java
@@ -33,21 +33,19 @@ public class IntIdentifier extends ConstIdentifier
 	public IntIdentifier(long val, String filename, int blp, int bcp, int elp, int ecp){
 		super();
 		 _val = val;
-		_kind = Kind.Data;
-		this.setDimensions(0,0);
-        this.computeDataType();
-        this.setValueType(ValueType.INT);
-        this.setAllPositions(filename, blp, bcp, elp, ecp);
+		setDimensions(0,0);
+        computeDataType();
+        setValueType(ValueType.INT);
+        setAllPositions(filename, blp, bcp, elp, ecp);
 	}
 	
 	public IntIdentifier(IntIdentifier i, String filename, int blp, int bcp, int elp, int ecp){
 		super();
 		 _val = i.getValue();
-		_kind = Kind.Data;
-		this.setDimensions(0,0);
-        this.computeDataType();
-        this.setValueType(ValueType.INT);
-        this.setAllPositions(filename, blp, bcp, elp, ecp);
+		setDimensions(0,0);
+        computeDataType();
+        setValueType(ValueType.INT);
+        setAllPositions(filename, blp, bcp, elp, ecp);
 	}
 	
 	// Used only by the parser for unary operation

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/ParameterizedBuiltinFunctionExpression.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/ParameterizedBuiltinFunctionExpression.java b/src/main/java/org/apache/sysml/parser/ParameterizedBuiltinFunctionExpression.java
index c135b74..aa888d3 100644
--- a/src/main/java/org/apache/sysml/parser/ParameterizedBuiltinFunctionExpression.java
+++ b/src/main/java/org/apache/sysml/parser/ParameterizedBuiltinFunctionExpression.java
@@ -107,9 +107,8 @@ public class ParameterizedBuiltinFunctionExpression extends DataIdentifier
 		pbHopMap.put(Expression.ParameterizedBuiltinFunctionOp.TOSTRING, ParamBuiltinOp.TOSTRING);
 	}
 	
-	public static ParameterizedBuiltinFunctionExpression getParamBuiltinFunctionExpression(String functionName, ArrayList<ParameterExpression> paramExprsPassed,
-			String fileName, int blp, int bcp, int elp, int ecp){
-	
+	public static ParameterizedBuiltinFunctionExpression getParamBuiltinFunctionExpression(String functionName, 
+			ArrayList<ParameterExpression> paramExprsPassed, String fileName, int blp, int bcp, int elp, int ecp){
 		if (functionName == null || paramExprsPassed == null)
 			return null;
 		
@@ -125,15 +124,14 @@ public class ParameterizedBuiltinFunctionExpression extends DataIdentifier
 		ParameterizedBuiltinFunctionExpression retVal = new ParameterizedBuiltinFunctionExpression(pbifop,varParams,
 				fileName, blp, bcp, elp, ecp);
 		return retVal;
-	} // end method getBuiltinFunctionExpression
+	}
 	
 			
 	public ParameterizedBuiltinFunctionExpression(ParameterizedBuiltinFunctionOp op, HashMap<String,Expression> varParams,
 			String filename, int blp, int bcp, int elp, int ecp) {
-		_kind = Kind.ParameterizedBuiltinFunctionOp;
 		_opcode = op;
 		_varParams = varParams;
-		this.setAllPositions(filename, blp, bcp, elp, ecp);
+		setAllPositions(filename, blp, bcp, elp, ecp);
 	}
 
 	public Expression rewriteExpression(String prefix) throws LanguageException {

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/RelationalExpression.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/RelationalExpression.java b/src/main/java/org/apache/sysml/parser/RelationalExpression.java
index c622e37..48666d0 100644
--- a/src/main/java/org/apache/sysml/parser/RelationalExpression.java
+++ b/src/main/java/org/apache/sysml/parser/RelationalExpression.java
@@ -25,13 +25,11 @@ import org.apache.sysml.parser.LanguageException.LanguageErrorCodes;
 
 public class RelationalExpression extends Expression
 {
-		
 	private Expression _left;
 	private Expression _right;
 	private RelationalOp _opcode;
 	
 	public RelationalExpression(RelationalOp bop) {
-		_kind = Kind.RelationalOp;
 		_opcode = bop;
 		
 		setFilename("MAIN SCRIPT");
@@ -42,7 +40,6 @@ public class RelationalExpression extends Expression
 	}
 	
 	public RelationalExpression(RelationalOp bop, String filename, int beginLine, int beginColumn, int endLine, int endColumn) {
-		_kind = Kind.RelationalOp;
 		_opcode = bop;
 		
 		setFilename(filename);

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/StatementBlock.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/StatementBlock.java b/src/main/java/org/apache/sysml/parser/StatementBlock.java
index 7329ced..3947372 100644
--- a/src/main/java/org/apache/sysml/parser/StatementBlock.java
+++ b/src/main/java/org/apache/sysml/parser/StatementBlock.java
@@ -419,8 +419,12 @@ public class StatementBlock extends LiveVariableAnalysis
 				}
 				StatementBlock sblock = fstmt.getBody().get(0);
 				
-				for (int i =0; i < fstmt.getInputParams().size(); i++){
-					
+				if( fcall.getParamExprs().size() < fstmt.getInputParams().size() ) {
+					sourceExpr.raiseValidateError("Wrong number of function parameters: "+
+						fcall.getParamExprs().size() + ", but " + fstmt.getInputParams().size()+" expected.");
+				}
+				
+				for (int i =0; i < fstmt.getInputParams().size(); i++) {
 					DataIdentifier currFormalParam = fstmt.getInputParams().get(i);
 					
 					// create new assignment statement
@@ -428,23 +432,7 @@ public class StatementBlock extends LiveVariableAnalysis
 					DataIdentifier newTarget = new DataIdentifier(currFormalParam);
 					newTarget.setName(newFormalParameterName);
 					
-					Expression currCallParam = null;
-					if (fcall.getParamExprs().size() > i){
-						// function call has value for parameter
-						currCallParam = fcall.getParamExprs().get(i).getExpr();
-					}
-					else {
-						// use default value for parameter
-						if (fstmt.getInputParams().get(i).getDefaultValue() == null){
-							currFormalParam.raiseValidateError("default parameter for " + currFormalParam + " is undefined", false);
-						}
-						currCallParam = new DataIdentifier(fstmt.getInputParams().get(i).getDefaultValue());
-						currCallParam.setAllPositions( 	fstmt.getInputParams().get(i).getFilename(),
-														fstmt.getInputParams().get(i).getBeginLine(), 
-														fstmt.getInputParams().get(i).getBeginColumn(),
-														fstmt.getInputParams().get(i).getEndLine(),
-														fstmt.getInputParams().get(i).getEndColumn());
-					}
+					Expression currCallParam = fcall.getParamExprs().get(i).getExpr();
 					
 					//auto casting of inputs on inlining (if required)
 					ValueType targetVT = newTarget.getValueType();

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/parser/StringIdentifier.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/parser/StringIdentifier.java b/src/main/java/org/apache/sysml/parser/StringIdentifier.java
index dc91a60..6b8ba1e 100644
--- a/src/main/java/org/apache/sysml/parser/StringIdentifier.java
+++ b/src/main/java/org/apache/sysml/parser/StringIdentifier.java
@@ -33,12 +33,10 @@ public class StringIdentifier extends ConstIdentifier
 	public StringIdentifier(String val, String filename, int blp, int bcp, int elp, int ecp){
 		super();
 		 _val = val;
-		_kind = Kind.Data;
-		this.setDimensions(0,0);
-        this.computeDataType();
-        this.setValueType(ValueType.STRING);
-        this.setAllPositions(filename, blp, bcp, elp, ecp);
-		
+		setDimensions(0,0);
+        computeDataType();
+        setValueType(ValueType.STRING);
+        setAllPositions(filename, blp, bcp, elp, ecp);
 	}
 
 	public String getValue(){

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/214b1772/src/main/java/org/apache/sysml/runtime/instructions/cp/FunctionCallCPInstruction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/instructions/cp/FunctionCallCPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/cp/FunctionCallCPInstruction.java
index 0958aeb..9cc6bb2 100644
--- a/src/main/java/org/apache/sysml/runtime/instructions/cp/FunctionCallCPInstruction.java
+++ b/src/main/java/org/apache/sysml/runtime/instructions/cp/FunctionCallCPInstruction.java
@@ -30,7 +30,6 @@ import org.apache.sysml.lops.Lop;
 import org.apache.sysml.parser.DMLProgram;
 import org.apache.sysml.parser.DataIdentifier;
 import org.apache.sysml.parser.Expression.DataType;
-import org.apache.sysml.parser.Expression.ValueType;
 import org.apache.sysml.runtime.DMLRuntimeException;
 import org.apache.sysml.runtime.DMLScriptException;
 import org.apache.sysml.runtime.controlprogram.FunctionProgramBlock;
@@ -123,6 +122,12 @@ public class FunctionCallCPInstruction extends CPInstruction
 		// get the function program block (stored in the Program object)
 		FunctionProgramBlock fpb = ec.getProgram().getFunctionProgramBlock(_namespace, _functionName);
 		
+		// sanity check number of function paramters
+		if( _boundInputParamNames.size() < fpb.getInputParams().size() ) {
+			throw new DMLRuntimeException("Number of bound input parameters does not match the function signature "
+				+ "("+_boundInputParamNames.size()+", but "+fpb.getInputParams().size()+" expected)");
+		}
+		
 		// create bindings to formal parameters for given function call
 		// These are the bindings passed to the FunctionProgramBlock for function execution 
 		LocalVariableMap functionVariables = new LocalVariableMap();		
@@ -131,35 +136,25 @@ public class FunctionCallCPInstruction extends CPInstruction
 			DataIdentifier currFormalParam = fpb.getInputParams().get(i);
 			String currFormalParamName = currFormalParam.getName();
 			Data currFormalParamValue = null; 
-			ValueType valType = fpb.getInputParams().get(i).getValueType();
 				
-			// CASE (a): default values, if call w/ less params than signature (scalars only)
-			if( i > _boundInputParamNames.size() )
-			{	
-				String defaultVal = fpb.getInputParams().get(i).getDefaultValue();
-				currFormalParamValue = ec.getScalarInput(defaultVal, valType, false);
+			CPOperand operand = _boundInputParamOperands.get(i);
+			String varname = operand.getName();
+			//error handling non-existing variables
+			if( !operand.isLiteral() && !ec.containsVariable(varname) ) {
+				throw new DMLRuntimeException("Input variable '"+varname+"' not existing on call of " + 
+						DMLProgram.constructFunctionKey(_namespace, _functionName) + " (line "+getLineNum()+").");
 			}
-			// CASE (b) literals or symbol table entries
-			else {
-				CPOperand operand = _boundInputParamOperands.get(i);
-				String varname = operand.getName();
-				//error handling non-existing variables
-				if( !operand.isLiteral() && !ec.containsVariable(varname) ) {
-					throw new DMLRuntimeException("Input variable '"+varname+"' not existing on call of " + 
-							DMLProgram.constructFunctionKey(_namespace, _functionName) + " (line "+getLineNum()+").");
-				}
-				//get input matrix/frame/scalar
-				currFormalParamValue = (operand.getDataType()!=DataType.SCALAR) ? ec.getVariable(varname) : 
-					ec.getScalarInput(varname, operand.getValueType(), operand.isLiteral());
-				
-				//graceful value type conversion for scalar inputs with wrong type
-				if( currFormalParamValue.getDataType() == DataType.SCALAR
-					&& currFormalParamValue.getValueType() != operand.getValueType() )
-				{
-					ScalarObject so = (ScalarObject) currFormalParamValue;
-					currFormalParamValue = ScalarObjectFactory
-						.createScalarObject(operand.getValueType(), so);
-				}
+			//get input matrix/frame/scalar
+			currFormalParamValue = (operand.getDataType()!=DataType.SCALAR) ? ec.getVariable(varname) : 
+				ec.getScalarInput(varname, operand.getValueType(), operand.isLiteral());
+			
+			//graceful value type conversion for scalar inputs with wrong type
+			if( currFormalParamValue.getDataType() == DataType.SCALAR
+				&& currFormalParamValue.getValueType() != operand.getValueType() )
+			{
+				ScalarObject so = (ScalarObject) currFormalParamValue;
+				currFormalParamValue = ScalarObjectFactory
+					.createScalarObject(operand.getValueType(), so);
 			}
 			
 			functionVariables.put(currFormalParamName, currFormalParamValue);						



[2/2] incubator-systemml git commit: [SYSTEMML-1592] Codegen cell/multiagg templates w/ sparse side inputs

Posted by mb...@apache.org.
[SYSTEMML-1592] Codegen cell/multiagg templates w/ sparse side inputs 

This patch extends the code generator cell and multi-aggregate templates
by abstract side inputs which allows us to directly pass sparse inputs
without the need to (necessarily) convert these inputs into dense
format, which incurs overhead for sequential allocation and conversion.

Note that we still use dense inputs for row and outer product templates
because these templates requires direct access to rows/columns of dense
arrays. The internal primitives for generated indexing operations are
accordingly generalized via type-dependent access functionality.


Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/14fd9da1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/14fd9da1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/14fd9da1

Branch: refs/heads/master
Commit: 14fd9da1bd040c5a41ee099d3ab155e469225405
Parents: 214b177
Author: Matthias Boehm <mb...@gmail.com>
Authored: Sat May 27 00:40:59 2017 -0700
Committer: Matthias Boehm <mb...@gmail.com>
Committed: Sat May 27 00:40:59 2017 -0700

----------------------------------------------------------------------
 .../sysml/hops/codegen/cplan/CNodeCell.java     |  3 +-
 .../sysml/hops/codegen/cplan/CNodeMultiAgg.java |  5 +-
 .../sysml/hops/codegen/cplan/CNodeTernary.java  |  4 +-
 .../sysml/hops/codegen/cplan/CNodeUnary.java    |  4 +-
 .../sysml/runtime/codegen/SpoofCellwise.java    | 44 +++++++--------
 .../runtime/codegen/SpoofMultiAggregate.java    | 12 ++---
 .../sysml/runtime/codegen/SpoofOperator.java    | 57 ++++++++++++++++++--
 .../runtime/codegen/SpoofOuterProduct.java      | 16 +++---
 .../sysml/runtime/codegen/SpoofRowwise.java     |  4 +-
 9 files changed, 99 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeCell.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeCell.java b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeCell.java
index 1bbbd67..4d1c767 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeCell.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeCell.java
@@ -34,13 +34,14 @@ public class CNodeCell extends CNodeTpl
 			+ "import org.apache.sysml.runtime.codegen.SpoofCellwise;\n"
 			+ "import org.apache.sysml.runtime.codegen.SpoofCellwise.AggOp;\n"
 			+ "import org.apache.sysml.runtime.codegen.SpoofCellwise.CellType;\n"
+			+ "import org.apache.sysml.runtime.codegen.SpoofOperator.SideInput;\n"
 			+ "import org.apache.commons.math3.util.FastMath;\n"
 			+ "\n"
 			+ "public final class %TMP% extends SpoofCellwise {\n" 
 			+ "  public %TMP%() {\n"
 			+ "    super(CellType.%TYPE%, %AGG_OP%, %SPARSE_SAFE%);\n"
 			+ "  }\n"
-			+ "  protected double genexec( double a, double[][] b, double[] scalars, int m, int n, int rowIndex, int colIndex) { \n"
+			+ "  protected double genexec(double a, SideInput[] b, double[] scalars, int m, int n, int rowIndex, int colIndex) { \n"
 			+ "%BODY_dense%"
 			+ "    return %OUT%;\n"
 			+ "  }\n"

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeMultiAgg.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeMultiAgg.java b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeMultiAgg.java
index aa84a00..5cfa7c4 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeMultiAgg.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeMultiAgg.java
@@ -32,16 +32,17 @@ public class CNodeMultiAgg extends CNodeTpl
 	private static final String TEMPLATE = 
 			  "package codegen;\n"
 			+ "import org.apache.sysml.runtime.codegen.LibSpoofPrimitives;\n"
-			+ "import org.apache.sysml.runtime.codegen.SpoofMultiAggregate;\n"
 			+ "import org.apache.sysml.runtime.codegen.SpoofCellwise;\n"
 			+ "import org.apache.sysml.runtime.codegen.SpoofCellwise.AggOp;\n"
+			+ "import org.apache.sysml.runtime.codegen.SpoofMultiAggregate;\n"
+			+ "import org.apache.sysml.runtime.codegen.SpoofOperator.SideInput;\n"
 			+ "import org.apache.commons.math3.util.FastMath;\n"
 			+ "\n"
 			+ "public final class %TMP% extends SpoofMultiAggregate { \n"
 			+ "  public %TMP%() {\n"
 			+ "    super(%AGG_OP%);\n"
 			+ "  }\n"
-			+ "  protected void genexec( double a, double[][] b, double[] scalars, double[] c, "
+			+ "  protected void genexec(double a, SideInput[] b, double[] scalars, double[] c, "
 					+ "int m, int n, int rowIndex, int colIndex) { \n"
 			+ "%BODY_dense%"
 			+ "  }\n"

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeTernary.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeTernary.java b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeTernary.java
index 2a868f8..0aee40a 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeTernary.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeTernary.java
@@ -55,8 +55,8 @@ public class CNodeTernary extends CNode
 					
 				case LOOKUP_RC1:
 					return sparse ?
-							"    double %TMP% = getValue(%IN1v%, rowIndex*%IN2%+%IN3%-1);\n" :	
-							"    double %TMP% = getValue(%IN1%, rowIndex*%IN2%+%IN3%-1);\n";	
+							"    double %TMP% = getValue(%IN1v%, %IN2%, rowIndex, %IN3%-1);\n" :	
+							"    double %TMP% = getValue(%IN1%, %IN2%, rowIndex, %IN3%-1);\n";	
 					
 				default: 
 					throw new RuntimeException("Invalid ternary type: "+this.toString());

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java
index 7808421..b9c7cbe 100644
--- a/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java
+++ b/src/main/java/org/apache/sysml/hops/codegen/cplan/CNodeUnary.java
@@ -74,9 +74,9 @@ public class CNodeUnary extends CNode
 			    case LOOKUP_R:
 			    	return "    double %TMP% = getValue(%IN1%, rowIndex);\n";
 			    case LOOKUP_C:
-			    	return "    double %TMP% = getValue(%IN1%, colIndex);\n";
+			    	return "    double %TMP% = getValue(%IN1%, n, 0, colIndex);\n";
 			    case LOOKUP_RC:
-			    	return "    double %TMP% = getValue(%IN1%, rowIndex*n+colIndex);\n";	
+			    	return "    double %TMP% = getValue(%IN1%, n, rowIndex, colIndex);\n";	
 				case LOOKUP0:
 					return "    double %TMP% = %IN1%[0];\n" ;
 				case POW2:

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
index fe23a04..eb45cc4 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofCellwise.java
@@ -113,7 +113,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		}
 		
 		//input preparation
-		double[][] b = prepInputMatrices(inputs);
+		SideInput[] b = prepInputMatricesAbstract(inputs);
 		double[] scalars = prepInputScalars(scalarObjects);
 		final int m = inputs.get(0).getNumRows();
 		final int n = inputs.get(0).getNumColumns();
@@ -189,7 +189,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		}
 		
 		//input preparation
-		double[][] b = prepInputMatrices(inputs);
+		SideInput[] b = prepInputMatricesAbstract(inputs);
 		double[] scalars = prepInputScalars(scalarObjects);
 		final int m = inputs.get(0).getNumRows();
 		final int n = inputs.get(0).getNumColumns();
@@ -239,7 +239,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		out.examSparsity();
 	}
 	
-	private long executeDense(double[] a, double[][] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeDense(double[] a, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		double[] c = out.getDenseBlock();
@@ -256,7 +256,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return -1;
 	}
 	
-	private double executeDenseAndAgg(double[] a, double[][] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) throws DMLRuntimeException 
+	private double executeDenseAndAgg(double[] a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) throws DMLRuntimeException 
 	{
 		//numerically stable aggregation for sum/sum_sq
 		if( _aggOp == AggOp.SUM || _aggOp == AggOp.SUM_SQ )
@@ -265,7 +265,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 			return executeDenseAggMxx(a, b, scalars, m, n, sparseSafe, rl, ru);
 	}
 	
-	private long executeSparse(SparseBlock sblock, double[][] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeSparse(SparseBlock sblock, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		if( sparseSafe && sblock == null )
@@ -287,7 +287,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return -1;
 	}
 	
-	private double executeSparseAndAgg(SparseBlock sblock, double[][] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private double executeSparseAndAgg(SparseBlock sblock, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		if( sparseSafe && sblock == null )
@@ -299,7 +299,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 			return executeSparseAggMxx(sblock, b, scalars, m, n, sparseSafe, rl, ru);
 	}
 	
-	private long executeSparseNoAggSparse(SparseBlock sblock, double[][] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeSparseNoAggSparse(SparseBlock sblock, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		//note: sequential scan algorithm for both sparse-safe and -unsafe 
@@ -335,7 +335,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return lnnz;
 	}
 	
-	private long executeSparseNoAggDense(SparseBlock sblock, double[][] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeSparseNoAggDense(SparseBlock sblock, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		//note: sequential scan algorithm for both sparse-safe and -unsafe 
@@ -368,7 +368,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return lnnz;
 	}
 	
-	private long executeSparseRowAggSum(SparseBlock sblock, double[][] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeSparseRowAggSum(SparseBlock sblock, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		KahanFunction kplus = (KahanFunction) getAggFunction();
@@ -406,7 +406,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return lnnz;
 	}
 	
-	private long executeSparseRowAggMxx(SparseBlock sblock, double[][] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeSparseRowAggMxx(SparseBlock sblock, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		double initialVal = (_aggOp==AggOp.MIN) ? Double.MAX_VALUE : -Double.MAX_VALUE;
@@ -444,7 +444,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return lnnz;
 	}
 	
-	private double executeSparseAggSum(SparseBlock sblock, double[][] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private double executeSparseAggSum(SparseBlock sblock, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		KahanFunction kplus = (KahanFunction) getAggFunction();
@@ -478,7 +478,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return kbuff._sum;
 	}
 	
-	private double executeSparseAggMxx(SparseBlock sblock, double[][] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private double executeSparseAggMxx(SparseBlock sblock, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		double ret = (_aggOp==AggOp.MIN) ? Double.MAX_VALUE : -Double.MAX_VALUE;
@@ -513,7 +513,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return ret;
 	}
 	
-	private long executeDenseNoAgg(double[] a, double[][] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeDenseNoAgg(double[] a, SideInput[] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		long lnnz = 0;
@@ -528,7 +528,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return lnnz;
 	}
 	
-	private long executeDenseRowAggSum(double[] a, double[][] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeDenseRowAggSum(double[] a, SideInput[] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		KahanFunction kplus = (KahanFunction) getAggFunction();
@@ -546,7 +546,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return lnnz;
 	}
 	
-	private long executeDenseRowAggMxx(double[] a, double[][] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private long executeDenseRowAggMxx(double[] a, SideInput[] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		double initialVal = (_aggOp==AggOp.MIN) ? Double.MAX_VALUE : -Double.MAX_VALUE;
@@ -574,7 +574,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return lnnz;
 	}
 	
-	private double executeDenseAggSum(double[] a, double[][] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private double executeDenseAggSum(double[] a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		KahanFunction kplus = (KahanFunction) getAggFunction();
@@ -589,7 +589,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		return kbuff._sum;
 	}
 	
-	private double executeDenseAggMxx(double[] a, double[][] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
+	private double executeDenseAggMxx(double[] a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		//safe aggregation for min/max w/ handling of zero entries
@@ -607,12 +607,12 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 	}
 	
 	
-	protected abstract double genexec( double a, double[][] b, double[] scalars, int m, int n, int rowIndex, int colIndex);
+	protected abstract double genexec( double a, SideInput[] b, double[] scalars, int m, int n, int rowIndex, int colIndex);
 	
 	private class ParAggTask implements Callable<Double> 
 	{
 		private final MatrixBlock _a;
-		private final double[][] _b;
+		private final SideInput[] _b;
 		private final double[] _scalars;
 		private final int _rlen;
 		private final int _clen;
@@ -620,7 +620,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		private final int _rl;
 		private final int _ru;
 
-		protected ParAggTask( MatrixBlock a, double[][] b, double[] scalars, 
+		protected ParAggTask( MatrixBlock a, SideInput[] b, double[] scalars, 
 				int rlen, int clen, boolean sparseSafe, int rl, int ru ) {
 			_a = a;
 			_b = b;
@@ -643,7 +643,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 	private class ParExecTask implements Callable<Long> 
 	{
 		private final MatrixBlock _a;
-		private final double[][] _b;
+		private final SideInput[] _b;
 		private final double[] _scalars;
 		private final MatrixBlock _c;
 		private final int _rlen;
@@ -652,7 +652,7 @@ public abstract class SpoofCellwise extends SpoofOperator implements Serializabl
 		private final int _rl;
 		private final int _ru;
 
-		protected ParExecTask( MatrixBlock a, double[][] b, double[] scalars, MatrixBlock c, 
+		protected ParExecTask( MatrixBlock a, SideInput[] b, double[] scalars, MatrixBlock c, 
 				int rlen, int clen, boolean sparseSafe, int rl, int ru ) {
 			_a = a;
 			_b = b;

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java
index fd72631..faecd8c 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofMultiAggregate.java
@@ -88,7 +88,7 @@ public abstract class SpoofMultiAggregate extends SpoofOperator implements Seria
 		setInitialOutputValues(c);
 		
 		//input preparation
-		double[][] b = prepInputMatrices(inputs);
+		SideInput[] b = prepInputMatricesAbstract(inputs);
 		double[] scalars = prepInputScalars(scalarObjects);
 		final int m = inputs.get(0).getNumRows();
 		final int n = inputs.get(0).getNumColumns();
@@ -129,7 +129,7 @@ public abstract class SpoofMultiAggregate extends SpoofOperator implements Seria
 		out.examSparsity();	
 	}
 	
-	private void executeDense(double[] a, double[][] b, double[] scalars, double[] c, int m, int n, int rl, int ru) throws DMLRuntimeException 
+	private void executeDense(double[] a, SideInput[] b, double[] scalars, double[] c, int m, int n, int rl, int ru) throws DMLRuntimeException 
 	{
 		//core dense aggregation operation
 		for( int i=rl, ix=rl*n; i<ru; i++ ) { 
@@ -140,7 +140,7 @@ public abstract class SpoofMultiAggregate extends SpoofOperator implements Seria
 		}
 	}
 	
-	private void executeSparse(SparseBlock sblock, double[][] b, double[] scalars, double[] c, int m, int n, int rl, int ru) 
+	private void executeSparse(SparseBlock sblock, SideInput[] b, double[] scalars, double[] c, int m, int n, int rl, int ru) 
 		throws DMLRuntimeException 
 	{
 		//core dense aggregation operation
@@ -152,7 +152,7 @@ public abstract class SpoofMultiAggregate extends SpoofOperator implements Seria
 	}
 
 	
-	protected abstract void genexec( double a, double[][] b, double[] scalars, double[] c, int m, int n, int rowIndex, int colIndex);
+	protected abstract void genexec( double a, SideInput[] b, double[] scalars, double[] c, int m, int n, int rowIndex, int colIndex);
 	
 	
 	private void setInitialOutputValues(double[] c) {
@@ -229,14 +229,14 @@ public abstract class SpoofMultiAggregate extends SpoofOperator implements Seria
 	private class ParAggTask implements Callable<double[]> 
 	{
 		private final MatrixBlock _a;
-		private final double[][] _b;
+		private final SideInput[] _b;
 		private final double[] _scalars;
 		private final int _rlen;
 		private final int _clen;
 		private final int _rl;
 		private final int _ru;
 
-		protected ParAggTask( MatrixBlock a, double[][] b, double[] scalars, 
+		protected ParAggTask( MatrixBlock a, SideInput[] b, double[] scalars, 
 				int rlen, int clen, int rl, int ru ) {
 			_a = a;
 			_b = b;

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java
index ced10f9..9499319 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java
@@ -57,15 +57,15 @@ public abstract class SpoofOperator implements Serializable
 		return execute(inputs, scalars);
 	}
 	
-	protected double[][] prepInputMatrices(ArrayList<MatrixBlock> inputs) {
-		return prepInputMatrices(inputs, 1, inputs.size()-1);
+	protected double[][] prepInputMatricesDense(ArrayList<MatrixBlock> inputs) {
+		return prepInputMatricesDense(inputs, 1, inputs.size()-1);
 	}
 	
-	protected double[][] prepInputMatrices(ArrayList<MatrixBlock> inputs, int offset) {
-		return prepInputMatrices(inputs, offset, inputs.size()-offset);
+	protected double[][] prepInputMatricesDense(ArrayList<MatrixBlock> inputs, int offset) {
+		return prepInputMatricesDense(inputs, offset, inputs.size()-offset);
 	}
 	
-	protected double[][] prepInputMatrices(ArrayList<MatrixBlock> inputs, int offset, int len) {
+	protected double[][] prepInputMatricesDense(ArrayList<MatrixBlock> inputs, int offset, int len) {
 		double[][] b = new double[len][]; 
 		for(int i=offset; i<offset+len; i++) {
 			//convert empty or sparse to dense temporary block (note: we don't do
@@ -85,6 +85,26 @@ public abstract class SpoofOperator implements Serializable
 		return b;
 	}
 	
+	protected SideInput[] prepInputMatricesAbstract(ArrayList<MatrixBlock> inputs) {
+		return prepInputMatricesAbstract(inputs, 1, inputs.size()-1);
+	}
+	
+	protected SideInput[] prepInputMatricesAbstract(ArrayList<MatrixBlock> inputs, int offset) {
+		return prepInputMatricesAbstract(inputs, offset, inputs.size()-offset);
+	}
+	
+	protected SideInput[] prepInputMatricesAbstract(ArrayList<MatrixBlock> inputs, int offset, int len) {
+		SideInput[] b = new SideInput[len]; 
+		for(int i=offset; i<offset+len; i++) {
+			if( inputs.get(i).isInSparseFormat() && inputs.get(i).isAllocated() )
+				b[i-offset] = new SideInput(null, inputs.get(i));
+			else
+				b[i-offset] = new SideInput(inputs.get(i).getDenseBlock(), null);
+		}
+		
+		return b;
+	}
+	
 	protected double[] prepInputScalars(ArrayList<ScalarObject> scalarObjects) {
 		double[] scalars = new double[scalarObjects.size()]; 
 		for(int i=0; i < scalarObjects.size(); i++)
@@ -94,7 +114,34 @@ public abstract class SpoofOperator implements Serializable
 	
 	//abstraction for safely accessing sideways matrices without the need 
 	//to allocate empty matrices as dense, see prepInputMatrices
+	
 	protected static double getValue(double[] data, int index) {
 		return (data!=null) ? data[index] : 0;
 	}
+	
+	protected static double getValue(double[] data, int n, int rowIndex, int colIndex) {
+		return (data!=null) ? data[rowIndex*n+colIndex] : 0;
+	}
+	
+	protected static double getValue(SideInput data, int rowIndex) {
+		//note: wrapper sideinput guaranteed to exist
+		return (data.dBlock!=null) ? data.dBlock[rowIndex] : 
+			(data.mBlock!=null) ? data.mBlock.quickGetValue(rowIndex, 0) : 0;
+	}
+	
+	protected static double getValue(SideInput data, int n, int rowIndex, int colIndex) {
+		//note: wrapper sideinput guaranteed to exist
+		return (data.dBlock!=null) ? data.dBlock[rowIndex*n+colIndex] : 
+			(data.mBlock!=null) ? data.mBlock.quickGetValue(rowIndex, colIndex) : 0;
+	}
+	
+	public static class SideInput {
+		private final double[] dBlock;
+		private final MatrixBlock mBlock;
+	
+		public SideInput(double[] ddata, MatrixBlock mdata) {
+			dBlock = ddata;
+			mBlock = mdata;
+		}
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java
index 15da6b9..64470ea 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOuterProduct.java
@@ -74,8 +74,8 @@ public abstract class SpoofOuterProduct extends SpoofOperator
 			throw new RuntimeException("Invalid input arguments.");
 		
 		//input preparation
-		double[][] ab = prepInputMatrices(inputs, 1, 2);
-		double[][] b = prepInputMatrices(inputs, 3);
+		double[][] ab = prepInputMatricesDense(inputs, 1, 2);
+		double[][] b = prepInputMatricesDense(inputs, 3);
 		double[] scalars = prepInputScalars(scalarObjects);
 		
 		//core sequential execute
@@ -103,8 +103,8 @@ public abstract class SpoofOuterProduct extends SpoofOperator
 			throw new RuntimeException("Invalid input arguments.");
 		
 		//input preparation
-		double[][] ab = prepInputMatrices(inputs, 1, 2);
-		double[][] b = prepInputMatrices(inputs, 3);
+		double[][] ab = prepInputMatricesDense(inputs, 1, 2);
+		double[][] b = prepInputMatricesDense(inputs, 3);
 		double[] scalars = prepInputScalars(scalarObjects);
 		
 		//core sequential execute
@@ -167,8 +167,8 @@ public abstract class SpoofOuterProduct extends SpoofOperator
 		}			
 		
 		//input preparation
-		double[][] ab = prepInputMatrices(inputs, 1, 2);
-		double[][] b = prepInputMatrices(inputs, 3);
+		double[][] ab = prepInputMatricesDense(inputs, 1, 2);
+		double[][] b = prepInputMatricesDense(inputs, 3);
 		double[] scalars = prepInputScalars(scalarObjects);
 				
 		//core sequential execute
@@ -238,8 +238,8 @@ public abstract class SpoofOuterProduct extends SpoofOperator
 		}	
 		
 		//input preparation
-		double[][] ab = prepInputMatrices(inputs, 1, 2);
-		double[][] b = prepInputMatrices(inputs, 3);
+		double[][] ab = prepInputMatricesDense(inputs, 1, 2);
+		double[][] b = prepInputMatricesDense(inputs, 3);
 		double[] scalars = prepInputScalars(scalarObjects);
 		
 		//core sequential execute

http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/14fd9da1/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
index 8b9fb4d..e793345 100644
--- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
+++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofRowwise.java
@@ -93,7 +93,7 @@ public abstract class SpoofRowwise extends SpoofOperator
 		double[] c = out.getDenseBlock();
 		
 		//input preparation
-		double[][] b = prepInputMatrices(inputs);
+		double[][] b = prepInputMatricesDense(inputs);
 		double[] scalars = prepInputScalars(scalarObjects);
 		
 		//setup thread-local memory if necessary
@@ -133,7 +133,7 @@ public abstract class SpoofRowwise extends SpoofOperator
 		allocateOutputMatrix(m, n, out);
 		
 		//input preparation
-		double[][] b = prepInputMatrices(inputs);
+		double[][] b = prepInputMatricesDense(inputs);
 		double[] scalars = prepInputScalars(scalarObjects);
 		
 		//core parallel execute