http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateBinaryGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateBinaryGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateBinaryGPUInstruction.java index 29a1ead..1d8f7fe 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateBinaryGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateBinaryGPUInstruction.java @@ -53,16 +53,11 @@ public class AggregateBinaryGPUInstruction extends GPUInstruction { _isRightTransposed = rightTranspose; } - public static AggregateBinaryGPUInstruction parseInstruction( String str ) - throws DMLRuntimeException - { + public static AggregateBinaryGPUInstruction parseInstruction( String str ) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); String opcode = parts[0]; - - if ( !opcode.equalsIgnoreCase("ba+*")) { + if ( !opcode.equalsIgnoreCase("ba+*")) throw new DMLRuntimeException("AggregateBinaryInstruction.parseInstruction():: Unknown opcode " + opcode); - } - InstructionUtils.checkNumFields( parts, 5 ); CPOperand in1 = new CPOperand(parts[1]); CPOperand in2 = new CPOperand(parts[2]); @@ -75,28 +70,18 @@ public class AggregateBinaryGPUInstruction extends GPUInstruction { } @Override - public void processInstruction(ExecutionContext ec) - throws DMLRuntimeException - { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); - AggregateBinaryOperator op = (AggregateBinaryOperator) _optr; - if( !(op.binaryFn instanceof Multiply && op.aggOp.increOp.fn instanceof Plus) ) { + if( !(op.binaryFn instanceof Multiply && op.aggOp.increOp.fn instanceof Plus) ) throw new DMLRuntimeException("Unsupported binary aggregate operation: ("+op.binaryFn+", "+op.aggOp+")."); - } - - //get inputs MatrixObject m1 = getMatrixInputForGPUInstruction(ec, _input1.getName()); MatrixObject m2 = getMatrixInputForGPUInstruction(ec, _input2.getName()); - - //compute matrix multiplication int rlen = (int) (_isLeftTransposed ? m1.getNumColumns() : m1.getNumRows()); int clen = (int) (_isRightTransposed ? m2.getNumRows() : m2.getNumColumns()); - ec.setMetaData(_output.getName(), rlen, clen); LibMatrixCuMatMult.matmult(ec, ec.getGPUContext(0), getExtendedOpcode(), m1, m2, _output.getName(), _isLeftTransposed, _isRightTransposed); - //release inputs/outputs ec.releaseMatrixInputForGPUInstruction(_input1.getName()); ec.releaseMatrixInputForGPUInstruction(_input2.getName()); @@ -104,13 +89,13 @@ public class AggregateBinaryGPUInstruction extends GPUInstruction { } @SuppressWarnings("unused") - private static MatrixBlock transpose(MatrixBlock m1) throws DMLRuntimeException { + private static MatrixBlock transpose(MatrixBlock m1) { ReorgOperator r_op = new ReorgOperator(SwapIndex.getSwapIndexFnObject(), 1); return (MatrixBlock) (m1.reorgOperations(r_op, new MatrixBlock(), 0, 0, 0)); } @SuppressWarnings("unused") - private static boolean isSparse(ExecutionContext ec, String var) throws DMLRuntimeException { + private static boolean isSparse(ExecutionContext ec, String var) { MatrixObject mo = ec.getMatrixObject(var); return LibMatrixCUDA.isInSparseFormat(ec.getGPUContext(0), mo); }
http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateUnaryGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateUnaryGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateUnaryGPUInstruction.java index 767f173..1d5802b 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateUnaryGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/AggregateUnaryGPUInstruction.java @@ -46,9 +46,7 @@ public class AggregateUnaryGPUInstruction extends GPUInstruction { _output = out; } - public static AggregateUnaryGPUInstruction parseInstruction(String str ) - throws DMLRuntimeException - { + public static AggregateUnaryGPUInstruction parseInstruction(String str ) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); String opcode = parts[0]; CPOperand in1 = new CPOperand(parts[1]); @@ -66,9 +64,7 @@ public class AggregateUnaryGPUInstruction extends GPUInstruction { } @Override - public void processInstruction(ExecutionContext ec) - throws DMLRuntimeException - { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); String opcode = getOpcode(); @@ -103,5 +99,4 @@ public class AggregateUnaryGPUInstruction extends GPUInstruction { ec.releaseMatrixOutputForGPUInstruction(_output.getName()); } } - } http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/ArithmeticBinaryGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ArithmeticBinaryGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ArithmeticBinaryGPUInstruction.java index e1f06ba..763439a 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ArithmeticBinaryGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ArithmeticBinaryGPUInstruction.java @@ -39,7 +39,7 @@ public abstract class ArithmeticBinaryGPUInstruction extends GPUInstruction { _output = out; } - public static ArithmeticBinaryGPUInstruction parseInstruction ( String str ) throws DMLRuntimeException { + public static ArithmeticBinaryGPUInstruction parseInstruction ( String str ) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); InstructionUtils.checkNumFields ( parts, 3 ); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinBinaryGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinBinaryGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinBinaryGPUInstruction.java index b145c09..be56bc6 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinBinaryGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinBinaryGPUInstruction.java @@ -44,7 +44,7 @@ public abstract class BuiltinBinaryGPUInstruction extends GPUInstruction { this.input2 = input2; } - public static BuiltinBinaryGPUInstruction parseInstruction(String str) throws DMLRuntimeException { + public static BuiltinBinaryGPUInstruction parseInstruction(String str) { CPOperand in1 = new CPOperand("", Expression.ValueType.UNKNOWN, Expression.DataType.UNKNOWN); CPOperand in2 = new CPOperand("", Expression.ValueType.UNKNOWN, Expression.DataType.UNKNOWN); CPOperand out = new CPOperand("", Expression.ValueType.UNKNOWN, Expression.DataType.UNKNOWN); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinUnaryGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinUnaryGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinUnaryGPUInstruction.java index 93a8f35..c4e9fad 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinUnaryGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/BuiltinUnaryGPUInstruction.java @@ -46,7 +46,6 @@ public abstract class BuiltinUnaryGPUInstruction extends GPUInstruction { } public static BuiltinUnaryGPUInstruction parseInstruction ( String str ) - throws DMLRuntimeException { CPOperand in = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN); CPOperand out = new CPOperand("", ValueType.UNKNOWN, DataType.UNKNOWN); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/ConvolutionGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ConvolutionGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ConvolutionGPUInstruction.java index 9e2d672..591fd54 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ConvolutionGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ConvolutionGPUInstruction.java @@ -44,7 +44,7 @@ public class ConvolutionGPUInstruction extends GPUInstruction { private ArrayList<CPOperand> _padding = new ArrayList<>(); private double _intermediateMemoryBudget = 0; - public ConvolutionGPUInstruction(CPOperand in1, CPOperand in2, CPOperand out, String opcode, String istr, double intermediateMemoryBudget) throws DMLRuntimeException { + public ConvolutionGPUInstruction(CPOperand in1, CPOperand in2, CPOperand out, String opcode, String istr, double intermediateMemoryBudget) { super(new ReorgOperator(SwapIndex.getSwapIndexFnObject()), opcode, istr); if (!(opcode.equals("bias_add") || opcode.equals("bias_multiply") || opcode.equals("relu_backward"))) { throw new DMLRuntimeException( @@ -58,7 +58,7 @@ public class ConvolutionGPUInstruction extends GPUInstruction { _intermediateMemoryBudget = intermediateMemoryBudget; } - public ConvolutionGPUInstruction(CPOperand in1, CPOperand in2, CPOperand in3, CPOperand out, String opcode, String istr, double intermediateMemoryBudget) throws DMLRuntimeException { + public ConvolutionGPUInstruction(CPOperand in1, CPOperand in2, CPOperand in3, CPOperand out, String opcode, String istr, double intermediateMemoryBudget) { super(new ReorgOperator(SwapIndex.getSwapIndexFnObject()), opcode, istr); if( !opcode.equals("channel_sums") ) { throw new DMLRuntimeException("Incorrect usage. Expected the opcode to be channel_sums, but found " + opcode); @@ -98,12 +98,9 @@ public class ConvolutionGPUInstruction extends GPUInstruction { _intermediateMemoryBudget = intermediateMemoryBudget; } - public static ConvolutionGPUInstruction parseInstruction(String str) - throws DMLRuntimeException - { + public static ConvolutionGPUInstruction parseInstruction(String str) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); String opcode = parts[0]; - if( ( opcode.equalsIgnoreCase("conv2d") || opcode.equalsIgnoreCase("conv2d_backward_filter") || opcode.equalsIgnoreCase("conv2d_backward_data")) ) { @@ -111,7 +108,6 @@ public class ConvolutionGPUInstruction extends GPUInstruction { CPOperand in1 = new CPOperand(parts[1]); CPOperand in2 = new CPOperand(parts[2]); CPOperand out = new CPOperand(parts[15]); - ArrayList<CPOperand> stride = new ArrayList<>(); ArrayList<CPOperand> padding = new ArrayList<>(); ArrayList<CPOperand> input_shape = new ArrayList<>(); @@ -237,7 +233,7 @@ public class ConvolutionGPUInstruction extends GPUInstruction { } } - public void processBiasInstruction(String instOpcode, ExecutionContext ec) throws DMLRuntimeException { + public void processBiasInstruction(String instOpcode, ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); MatrixObject input = getMatrixInputForGPUInstruction(ec, _input1.getName()); MatrixObject bias = getMatrixInputForGPUInstruction(ec, _input2.getName()); @@ -254,7 +250,7 @@ public class ConvolutionGPUInstruction extends GPUInstruction { } // (X > 0) * dout - public void processReLUBackwardInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processReLUBackwardInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); MatrixObject input = getMatrixInputForGPUInstruction(ec, _input1.getName()); MatrixObject dout = getMatrixInputForGPUInstruction(ec, _input2.getName()); @@ -268,7 +264,7 @@ public class ConvolutionGPUInstruction extends GPUInstruction { ec.releaseMatrixOutputForGPUInstruction(_output.getName()); } - public void processChannelSumsInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processChannelSumsInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); MatrixObject input = getMatrixInputForGPUInstruction(ec, _input1.getName()); int C = (int) ec.getScalarInput(_input2.getName(), _input2.getValueType(), _input2.isLiteral()).getLongValue(); @@ -286,9 +282,7 @@ public class ConvolutionGPUInstruction extends GPUInstruction { } @Override - public void processInstruction(ExecutionContext ec) - throws DMLRuntimeException - { + public void processInstruction(ExecutionContext ec) { if (instOpcode.equalsIgnoreCase("bias_add") || instOpcode.equalsIgnoreCase("bias_multiply")) { processBiasInstruction(instOpcode, ec); return; @@ -431,9 +425,7 @@ public class ConvolutionGPUInstruction extends GPUInstruction { } - private static int getScalarInput(ExecutionContext ec, ArrayList<CPOperand> aL, int index) - throws DMLRuntimeException - { + private static int getScalarInput(ExecutionContext ec, ArrayList<CPOperand> aL, int index) { return (int) ec.getScalarInput(aL.get(index).getName(), aL.get(index).getValueType(), aL.get(index).isLiteral()).getLongValue(); } http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/GPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/GPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/GPUInstruction.java index 63eb34a..722b564 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/GPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/GPUInstruction.java @@ -23,7 +23,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.sysml.api.DMLScript; import org.apache.sysml.lops.runtime.RunMRJobs; -import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.controlprogram.caching.MatrixObject; import org.apache.sysml.runtime.controlprogram.context.ExecutionContext; import org.apache.sysml.runtime.instructions.GPUInstructionParser; @@ -180,44 +179,34 @@ public abstract class GPUInstruction extends Instruction { } @Override - public Instruction preprocessInstruction(ExecutionContext ec) - throws DMLRuntimeException - { + public Instruction preprocessInstruction(ExecutionContext ec) { //default preprocess behavior (e.g., debug state) Instruction tmp = super.preprocessInstruction(ec); - //instruction patching if( tmp.requiresLabelUpdate() ) { //update labels only if required //note: no exchange of updated instruction as labels might change in the general case String updInst = RunMRJobs.updateLabels(tmp.toString(), ec.getVariables()); tmp = GPUInstructionParser.parseSingleInstruction(updInst); } - return tmp; } @Override - public abstract void processInstruction(ExecutionContext ec) - throws DMLRuntimeException; - + public abstract void processInstruction(ExecutionContext ec); + @Override - public void postprocessInstruction(ExecutionContext ec) - throws DMLRuntimeException - { + public void postprocessInstruction(ExecutionContext ec) { if(DMLScript.SYNCHRONIZE_GPU) { long t0 = DMLScript.FINEGRAINED_STATISTICS ? System.nanoTime() : 0; jcuda.runtime.JCuda.cudaDeviceSynchronize(); - if(DMLScript.FINEGRAINED_STATISTICS) { + if(DMLScript.FINEGRAINED_STATISTICS) GPUStatistics.maintainCPMiscTimes(getExtendedOpcode(), GPUInstruction.MISC_TIMER_CUDA_SYNC, System.nanoTime() - t0); - } } if(LOG.isDebugEnabled()) { - for(GPUContext gpuCtx : ec.getGPUContexts()) { + for(GPUContext gpuCtx : ec.getGPUContexts()) if(gpuCtx != null) gpuCtx.printMemoryInfo(getOpcode()); - } } - } /** @@ -226,9 +215,8 @@ public abstract class GPUInstruction extends Instruction { * @param ec active {@link ExecutionContext} * @param name name of input matrix (that the {@link ExecutionContext} is aware of) * @return the matrix object - * @throws DMLRuntimeException if an error occurs */ - protected MatrixObject getMatrixInputForGPUInstruction(ExecutionContext ec, String name) throws DMLRuntimeException { + protected MatrixObject getMatrixInputForGPUInstruction(ExecutionContext ec, String name) { return ec.getMatrixInputForGPUInstruction(name, getExtendedOpcode()); } @@ -240,9 +228,8 @@ public abstract class GPUInstruction extends Instruction { * @param numRows number of rows of matrix object * @param numCols number of columns of matrix object * @return the matrix object - * @throws DMLRuntimeException if an error occurs */ - protected MatrixObject getDenseMatrixOutputForGPUInstruction(ExecutionContext ec, String name, long numRows, long numCols) throws DMLRuntimeException { + protected MatrixObject getDenseMatrixOutputForGPUInstruction(ExecutionContext ec, String name, long numRows, long numCols) { long t0 = DMLScript.FINEGRAINED_STATISTICS ? System.nanoTime() : 0; Pair<MatrixObject, Boolean> mb = ec.getDenseMatrixOutputForGPUInstruction(name, numRows, numCols); if (DMLScript.FINEGRAINED_STATISTICS && mb.getValue()) GPUStatistics.maintainCPMiscTimes(getExtendedOpcode(), GPUInstruction.MISC_TIMER_ALLOCATE_DENSE_OUTPUT, System.nanoTime() - t0); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/MMTSJGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MMTSJGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MMTSJGPUInstruction.java index f795f54..310e358 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MMTSJGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MMTSJGPUInstruction.java @@ -19,13 +19,6 @@ package org.apache.sysml.runtime.instructions.gpu; -/* - * Parses and processes the MMTSJ GPU Instruction - * @function GPUInstruction(...) - * @function parseInstruction(...) - * @function processInstruction(...) - * @function getMMTSJType(...) - */ import org.apache.sysml.lops.MMTSJ.MMTSJType; import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.controlprogram.caching.MatrixObject; @@ -65,14 +58,7 @@ public class MMTSJGPUInstruction extends GPUInstruction { _output = out; } - /** - * parse MMTSJ GPU instruction - * @param str instruction string - * @return MMTSJGPUInstruction object - * @throws DMLRuntimeException if DMLRuntimeException occurs - */ public static MMTSJGPUInstruction parseInstruction ( String str ) - throws DMLRuntimeException { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); InstructionUtils.checkNumFields ( parts, 3 ); @@ -88,39 +74,21 @@ public class MMTSJGPUInstruction extends GPUInstruction { return new MMTSJGPUInstruction(new Operator(true), in1, titype, out, opcode, str); } - /** - * process MMTSJ GPU instruction - * @param ec execution context - * @throws DMLRuntimeException if DMLRuntimeException occurs - */ @Override - public void processInstruction(ExecutionContext ec) - throws DMLRuntimeException - { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); - - //get input MatrixObject mat = getMatrixInputForGPUInstruction(ec, _input.getName()); - boolean isLeftTransposed = ( _type == MMTSJType.LEFT); - int rlen = (int) (isLeftTransposed? mat.getNumColumns() : mat.getNumRows()); int clen = rlen; - //execute operations ec.setMetaData(_output.getName(), rlen, clen); LibMatrixCUDA.matmultTSMM(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName(), isLeftTransposed); - ec.releaseMatrixInputForGPUInstruction(_input.getName()); ec.releaseMatrixOutputForGPUInstruction(_output.getName()); } - /** - * returns left/right depending on the type of MMTSJ instruction - * @return MMTSJType object - */ - public MMTSJType getMMTSJType() - { + public MMTSJType getMMTSJType() { return _type; } } http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixAppendGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixAppendGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixAppendGPUInstruction.java index a183d29..a6e0b23 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixAppendGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixAppendGPUInstruction.java @@ -50,12 +50,9 @@ public class MatrixAppendGPUInstruction extends GPUInstruction { this.atype = type; } - public static MatrixAppendGPUInstruction parseInstruction ( String str ) - throws DMLRuntimeException - { + public static MatrixAppendGPUInstruction parseInstruction ( String str ) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); InstructionUtils.checkNumFields (parts, 5); - String opcode = parts[0]; CPOperand in1 = new CPOperand(parts[1]); CPOperand in2 = new CPOperand(parts[2]); @@ -63,36 +60,29 @@ public class MatrixAppendGPUInstruction extends GPUInstruction { CPOperand in3 = new CPOperand(parts[3]); CPOperand out = new CPOperand(parts[4]); boolean cbind = Boolean.parseBoolean(parts[5]); - AppendCPInstruction.AppendType type = (in1.getDataType()!= Expression.DataType.MATRIX && in1.getDataType()!= Expression.DataType.FRAME) ? AppendCPInstruction.AppendType.STRING : cbind ? AppendCPInstruction.AppendType.CBIND : AppendCPInstruction.AppendType.RBIND; - if (in1.getDataType()!= Expression.DataType.MATRIX || in2.getDataType()!= Expression.DataType.MATRIX){ throw new DMLRuntimeException("GPU : Error in internal state - Append was called on data other than matrices"); } - if(!opcode.equalsIgnoreCase("append")) throw new DMLRuntimeException("Unknown opcode while parsing a AppendCPInstruction: " + str); - Operator op = new ReorgOperator(OffsetColumnIndex.getOffsetColumnIndexFnObject(-1)); return new MatrixAppendGPUInstruction(op, in1, in2, out, type, opcode, str); } @Override - public void processInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); - String opcode = getOpcode(); MatrixObject mat1 = getMatrixInputForGPUInstruction(ec, input1.getName()); MatrixObject mat2 = getMatrixInputForGPUInstruction(ec, input2.getName()); - - if(atype == AppendCPInstruction.AppendType.CBIND) { + if(atype == AppendCPInstruction.AppendType.CBIND) LibMatrixCUDA.cbind(ec, ec.getGPUContext(0), getExtendedOpcode(), mat1, mat2, output.getName()); - } else if (atype == AppendCPInstruction.AppendType.RBIND ) { + else if (atype == AppendCPInstruction.AppendType.RBIND ) LibMatrixCUDA.rbind(ec, ec.getGPUContext(0), getExtendedOpcode(), mat1, mat2, output.getName()); - } else { + else throw new DMLRuntimeException("Unsupported GPU operator:" + opcode); - } ec.releaseMatrixInputForGPUInstruction(input1.getName()); ec.releaseMatrixInputForGPUInstruction(input2.getName()); ec.releaseMatrixOutputForGPUInstruction(output.getName()); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixBuiltinGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixBuiltinGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixBuiltinGPUInstruction.java index f54bc80..159608f 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixBuiltinGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixBuiltinGPUInstruction.java @@ -36,7 +36,7 @@ public class MatrixBuiltinGPUInstruction extends BuiltinUnaryGPUInstruction { } @Override - public void processInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); String opcode = getOpcode(); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixIndexingGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixIndexingGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixIndexingGPUInstruction.java index 9b29d4a..9ea91a5 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixIndexingGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixIndexingGPUInstruction.java @@ -63,7 +63,7 @@ public class MatrixIndexingGPUInstruction extends GPUInstruction { output = out; } - public static MatrixIndexingGPUInstruction parseInstruction ( String str ) throws DMLRuntimeException { + public static MatrixIndexingGPUInstruction parseInstruction ( String str ) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); String opcode = parts[0]; @@ -117,8 +117,7 @@ public class MatrixIndexingGPUInstruction extends GPUInstruction { } @Override - public void processInstruction(ExecutionContext ec) - throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); String opcode = getOpcode(); @@ -134,11 +133,11 @@ public class MatrixIndexingGPUInstruction extends GPUInstruction { } } - IndexRange getIndexRange(ExecutionContext ec) throws DMLRuntimeException { + IndexRange getIndexRange(ExecutionContext ec) { return new IndexRange( //rl, ru, cl, ru (int)(ec.getScalarInput(rowLower.getName(), rowLower.getValueType(), rowLower.isLiteral()).getLongValue()-1), (int)(ec.getScalarInput(rowUpper.getName(), rowUpper.getValueType(), rowUpper.isLiteral()).getLongValue()-1), (int)(ec.getScalarInput(colLower.getName(), colLower.getValueType(), colLower.isLiteral()).getLongValue()-1), - (int)(ec.getScalarInput(colUpper.getName(), colUpper.getValueType(), colUpper.isLiteral()).getLongValue()-1)); + (int)(ec.getScalarInput(colUpper.getName(), colUpper.getValueType(), colUpper.isLiteral()).getLongValue()-1)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixArithmeticGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixArithmeticGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixArithmeticGPUInstruction.java index d332bc8..9f4f2c5 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixArithmeticGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixArithmeticGPUInstruction.java @@ -19,7 +19,6 @@ package org.apache.sysml.runtime.instructions.gpu; -import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.controlprogram.caching.MatrixObject; import org.apache.sysml.runtime.controlprogram.context.ExecutionContext; import org.apache.sysml.runtime.instructions.cp.CPOperand; @@ -36,7 +35,7 @@ public class MatrixMatrixArithmeticGPUInstruction extends ArithmeticBinaryGPUIns } @Override - public void processInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); MatrixObject in1 = getMatrixInputForGPUInstruction(ec, _input1.getName()); @@ -45,8 +44,6 @@ public class MatrixMatrixArithmeticGPUInstruction extends ArithmeticBinaryGPUIns //TODO: make hop level changes for this boolean isLeftTransposed = false; boolean isRightTransposed = false; - // int rlen = isLeftTransposed ? (int) in1.getNumColumns() : (int) in1.getNumRows(); - // int clen = isLeftTransposed ? (int) in1.getNumRows() : (int) in1.getNumColumns(); long rlen1 = in1.getNumRows(); long clen1 = in1.getNumColumns(); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixAxpyGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixAxpyGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixAxpyGPUInstruction.java index 778c400..a4eea05 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixAxpyGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixAxpyGPUInstruction.java @@ -41,7 +41,7 @@ public class MatrixMatrixAxpyGPUInstruction extends ArithmeticBinaryGPUInstructi this.multiplier = multiplier; } - public static MatrixMatrixAxpyGPUInstruction parseInstruction ( String str ) throws DMLRuntimeException { + public static MatrixMatrixAxpyGPUInstruction parseInstruction ( String str ) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); InstructionUtils.checkNumFields ( parts, 4 ); @@ -77,7 +77,7 @@ public class MatrixMatrixAxpyGPUInstruction extends ArithmeticBinaryGPUInstructi @Override - public void processInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); MatrixObject in1 = getMatrixInputForGPUInstruction(ec, _input1.getName()); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixBuiltinGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixBuiltinGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixBuiltinGPUInstruction.java index 0ef7a44..b877d38 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixBuiltinGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixBuiltinGPUInstruction.java @@ -36,7 +36,7 @@ public class MatrixMatrixBuiltinGPUInstruction extends BuiltinBinaryGPUInstructi } @Override - public void processInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); String opcode = getOpcode(); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixRelationalBinaryGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixRelationalBinaryGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixRelationalBinaryGPUInstruction.java index 224e7b5..df64f78 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixRelationalBinaryGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/MatrixMatrixRelationalBinaryGPUInstruction.java @@ -19,7 +19,6 @@ package org.apache.sysml.runtime.instructions.gpu; -import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.controlprogram.caching.MatrixObject; import org.apache.sysml.runtime.controlprogram.context.ExecutionContext; import org.apache.sysml.runtime.instructions.cp.CPOperand; @@ -36,7 +35,7 @@ public class MatrixMatrixRelationalBinaryGPUInstruction extends RelationalBinary } @Override - public void processInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); MatrixObject in1 = getMatrixInputForGPUInstruction(ec, _input1.getName()); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/RelationalBinaryGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/RelationalBinaryGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/RelationalBinaryGPUInstruction.java index 505e6e4..a63954f 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/RelationalBinaryGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/RelationalBinaryGPUInstruction.java @@ -40,7 +40,7 @@ public abstract class RelationalBinaryGPUInstruction extends GPUInstruction { _output = out; } - public static RelationalBinaryGPUInstruction parseInstruction ( String str ) throws DMLRuntimeException { + public static RelationalBinaryGPUInstruction parseInstruction ( String str ) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); InstructionUtils.checkNumFields ( parts, 3 ); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/ReorgGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ReorgGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ReorgGPUInstruction.java index 2c32cd5..f191d2a 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ReorgGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ReorgGPUInstruction.java @@ -55,38 +55,27 @@ public class ReorgGPUInstruction extends GPUInstruction { _output = out; } - public static ReorgGPUInstruction parseInstruction ( String str ) - throws DMLRuntimeException - { + public static ReorgGPUInstruction parseInstruction ( String str ) { String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); - InstructionUtils.checkNumFields ( parts, 2 ); - + InstructionUtils.checkNumFields ( parts, 2 ); String opcode = parts[0]; CPOperand in = new CPOperand(parts[1]); - CPOperand out = new CPOperand(parts[2]); - - if ( !(opcode.equalsIgnoreCase("r'")) ) { + CPOperand out = new CPOperand(parts[2]); + if ( !(opcode.equalsIgnoreCase("r'")) ) throw new DMLRuntimeException("Unknown opcode while parsing a ReorgInstruction: " + str); - } else return new ReorgGPUInstruction(new ReorgOperator(SwapIndex.getSwapIndexFnObject()), in, out, opcode, str); } @Override - public void processInstruction(ExecutionContext ec) - throws DMLRuntimeException - { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); - //acquire input MatrixObject mat = getMatrixInputForGPUInstruction(ec, _input.getName()); - int rlen = (int) mat.getNumColumns(); int clen = (int) mat.getNumRows(); - //execute operation ec.setMetaData(_output.getName(), rlen, clen); LibMatrixCUDA.transpose(ec, ec.getGPUContext(0), getExtendedOpcode(), mat, _output.getName()); - //release inputs/outputs ec.releaseMatrixInputForGPUInstruction(_input.getName()); ec.releaseMatrixOutputForGPUInstruction(_output.getName()); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixArithmeticGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixArithmeticGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixArithmeticGPUInstruction.java index 4552c1f..2593837 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixArithmeticGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixArithmeticGPUInstruction.java @@ -20,7 +20,6 @@ package org.apache.sysml.runtime.instructions.gpu; import org.apache.sysml.parser.Expression.DataType; -import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.controlprogram.caching.MatrixObject; import org.apache.sysml.runtime.controlprogram.context.ExecutionContext; import org.apache.sysml.runtime.instructions.cp.CPOperand; @@ -38,9 +37,7 @@ public class ScalarMatrixArithmeticGPUInstruction extends ArithmeticBinaryGPUIns } @Override - public void processInstruction(ExecutionContext ec) - throws DMLRuntimeException - { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); CPOperand mat = ( _input1.getDataType() == DataType.MATRIX ) ? _input1 : _input2; http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixBuiltinGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixBuiltinGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixBuiltinGPUInstruction.java index f8e024f..93c012b 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixBuiltinGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixBuiltinGPUInstruction.java @@ -40,7 +40,7 @@ public class ScalarMatrixBuiltinGPUInstruction extends BuiltinBinaryGPUInstructi } @Override - public void processInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); String opcode = getOpcode(); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixRelationalBinaryGPUInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixRelationalBinaryGPUInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixRelationalBinaryGPUInstruction.java index 59e717f..bf5b017 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixRelationalBinaryGPUInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/ScalarMatrixRelationalBinaryGPUInstruction.java @@ -20,7 +20,6 @@ package org.apache.sysml.runtime.instructions.gpu; import org.apache.sysml.parser.Expression; -import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.controlprogram.caching.MatrixObject; import org.apache.sysml.runtime.controlprogram.context.ExecutionContext; import org.apache.sysml.runtime.instructions.cp.CPOperand; @@ -38,7 +37,7 @@ public class ScalarMatrixRelationalBinaryGPUInstruction extends RelationalBinary } @Override - public void processInstruction(ExecutionContext ec) throws DMLRuntimeException { + public void processInstruction(ExecutionContext ec) { GPUStatistics.incrementNoOfExecutedGPUInst(); CPOperand mat = ( _input1.getDataType() == Expression.DataType.MATRIX ) ? _input1 : _input2; http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/CSRPointer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/CSRPointer.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/CSRPointer.java index a50e56a..bdc5b21 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/CSRPointer.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/CSRPointer.java @@ -116,29 +116,17 @@ public class CSRPointer { return numElems * ((long) LibMatrixCUDA.sizeOfDataType); } - // private Pointer allocate(String instName, long size) throws DMLRuntimeException { - // return getGPUContext().allocate(instName, size); - // } - private static long getIntSizeOf(long numElems) { return numElems * ((long) Sizeof.INT); } - // private void cudaFreeHelper(Pointer toFree) throws DMLRuntimeException { - // getGPUContext().cudaFreeHelper(toFree); - // } - - public static int toIntExact(long l) throws DMLRuntimeException { + public static int toIntExact(long l) { if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw new DMLRuntimeException("Cannot be cast to int:" + l); } return (int) l; } - // private void cudaFreeHelper(String instName, Pointer toFree, boolean eager) throws DMLRuntimeException { - // getGPUContext().cudaFreeHelper(instName, toFree, eager); - // } - /** * @return Singleton default matrix descriptor object * (set with CUSPARSE_MATRIX_TYPE_GENERAL, CUSPARSE_INDEX_BASE_ZERO) @@ -188,9 +176,8 @@ public class CSRPointer { * @param rowPtr integer array of row pointers * @param colInd integer array of column indices * @param values double array of non zero values - * @throws DMLRuntimeException if error occurs */ - public static void copyToDevice(GPUContext gCtx, CSRPointer dest, int rows, long nnz, int[] rowPtr, int[] colInd, double[] values) throws DMLRuntimeException { + public static void copyToDevice(GPUContext gCtx, CSRPointer dest, int rows, long nnz, int[] rowPtr, int[] colInd, double[] values) { CSRPointer r = dest; long t0 = 0; if (DMLScript.STATISTICS) @@ -218,9 +205,8 @@ public class CSRPointer { * @param nnz [input] number of non-zeroes * @param rowPtr [output] pre-allocated integer array of row pointers of size (rows+1) * @param colInd [output] pre-allocated integer array of column indices of size nnz - * @throws DMLRuntimeException if error */ - public static void copyPtrToHost(CSRPointer src, int rows, long nnz, int[] rowPtr, int[] colInd) throws DMLRuntimeException { + public static void copyPtrToHost(CSRPointer src, int rows, long nnz, int[] rowPtr, int[] colInd) { CSRPointer r = src; cudaMemcpy(Pointer.to(rowPtr), r.rowPtr, getIntSizeOf(rows + 1), cudaMemcpyDeviceToHost); cudaMemcpy(Pointer.to(colInd), r.colInd, getIntSizeOf(nnz), cudaMemcpyDeviceToHost); @@ -237,13 +223,10 @@ public class CSRPointer { * @param m Rows in A * @param n Columns in Bs * @return CSR (compressed sparse row) pointer - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public static CSRPointer allocateForDgeam(GPUContext gCtx, cusparseHandle handle, CSRPointer A, CSRPointer B, int m, - int n) throws DMLRuntimeException { - if (A.nnz >= Integer.MAX_VALUE || B.nnz >= Integer.MAX_VALUE) { + public static CSRPointer allocateForDgeam(GPUContext gCtx, cusparseHandle handle, CSRPointer A, CSRPointer B, int m, int n) { + if (A.nnz >= Integer.MAX_VALUE || B.nnz >= Integer.MAX_VALUE) throw new DMLRuntimeException("Number of non zeroes is larger than supported by cuSparse"); - } CSRPointer C = new CSRPointer(gCtx); step1AllocateRowPointers(gCtx, handle, C, m); step2GatherNNZGeam(gCtx, handle, A, B, C, m, n); @@ -265,10 +248,9 @@ public class CSRPointer { * @param n Columns in B * @param k Columns in A / Rows in B * @return a {@link CSRPointer} instance that encapsulates the CSR matrix on GPU - * @throws DMLRuntimeException if DMLRuntimeException occurs */ public static CSRPointer allocateForMatrixMultiply(GPUContext gCtx, cusparseHandle handle, CSRPointer A, int transA, - CSRPointer B, int transB, int m, int n, int k) throws DMLRuntimeException { + CSRPointer B, int transB, int m, int n, int k) { // Following the code example at http://docs.nvidia.com/cuda/cusparse/#cusparse-lt-t-gt-csrgemm and at // https://github.com/jcuda/jcuda-matrix-utils/blob/master/JCudaMatrixUtils/src/test/java/org/jcuda/matrix/samples/JCusparseSampleDgemm.java CSRPointer C = new CSRPointer(gCtx); @@ -285,9 +267,8 @@ public class CSRPointer { * @param nnz2 number of non-zeroes * @param rows number of rows * @return a {@link CSRPointer} instance that encapsulates the CSR matrix on GPU - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public static CSRPointer allocateEmpty(GPUContext gCtx, long nnz2, long rows) throws DMLRuntimeException { + public static CSRPointer allocateEmpty(GPUContext gCtx, long nnz2, long rows) { LOG.trace("GPU : allocateEmpty from CSRPointer with nnz=" + nnz2 + " and rows=" + rows + ", GPUContext=" + gCtx); if(nnz2 < 0) throw new DMLRuntimeException("Incorrect usage of internal API, number of non zeroes is less than 0 when trying to allocate sparse data on GPU"); if(rows <= 0) throw new DMLRuntimeException("Incorrect usage of internal API, number of rows is less than or equal to 0 when trying to allocate sparse data on GPU"); @@ -312,10 +293,8 @@ public class CSRPointer { * @param handle a valid {@link cusparseHandle} * @param C Output matrix * @param rowsC number of rows in C - * @throws DMLRuntimeException ? */ - private static void step1AllocateRowPointers(GPUContext gCtx, cusparseHandle handle, CSRPointer C, int rowsC) - throws DMLRuntimeException { + private static void step1AllocateRowPointers(GPUContext gCtx, cusparseHandle handle, CSRPointer C, int rowsC) { LOG.trace("GPU : step1AllocateRowPointers" + ", GPUContext=" + gCtx); cusparseSetPointerMode(handle, cusparsePointerMode.CUSPARSE_POINTER_MODE_HOST); //cudaDeviceSynchronize; @@ -334,10 +313,8 @@ public class CSRPointer { * @param C Output Sparse Matrix C on GPU * @param m Rows in C * @param n Columns in C - * @throws DMLRuntimeException ? */ - private static void step2GatherNNZGeam(GPUContext gCtx, cusparseHandle handle, CSRPointer A, CSRPointer B, - CSRPointer C, int m, int n) throws DMLRuntimeException { + private static void step2GatherNNZGeam(GPUContext gCtx, cusparseHandle handle, CSRPointer A, CSRPointer B, CSRPointer C, int m, int n) { LOG.trace("GPU : step2GatherNNZGeam for DGEAM" + ", GPUContext=" + gCtx); int[] CnnzArray = { -1 }; cusparseXcsrgeamNnz(handle, m, n, A.descr, toIntExact(A.nnz), A.rowPtr, A.colInd, B.descr, toIntExact(B.nnz), @@ -367,10 +344,9 @@ public class CSRPointer { * @param m Number of rows of sparse matrix op ( A ) and C * @param n Number of columns of sparse matrix op ( B ) and C * @param k Number of columns/rows of sparse matrix op ( A ) / op ( B ) - * @throws DMLRuntimeException ? */ private static void step2GatherNNZGemm(GPUContext gCtx, cusparseHandle handle, CSRPointer A, int transA, - CSRPointer B, int transB, CSRPointer C, int m, int n, int k) throws DMLRuntimeException { + CSRPointer B, int transB, CSRPointer C, int m, int n, int k) { LOG.trace("GPU : step2GatherNNZGemm for DGEMM" + ", GPUContext=" + gCtx); int[] CnnzArray = { -1 }; if (A.nnz >= Integer.MAX_VALUE || B.nnz >= Integer.MAX_VALUE) { @@ -396,10 +372,8 @@ public class CSRPointer { * @param gCtx a valid {@link GPUContext} * @param handle a valid {@link cusparseHandle} * @param C Output sparse matrix on GPU - * @throws DMLRuntimeException ? */ - private static void step3AllocateValNInd(GPUContext gCtx, cusparseHandle handle, CSRPointer C) - throws DMLRuntimeException { + private static void step3AllocateValNInd(GPUContext gCtx, cusparseHandle handle, CSRPointer C) { LOG.trace("GPU : step3AllocateValNInd" + ", GPUContext=" + gCtx); // Increment cudaCount by one when all three arrays of CSR sparse array are allocated C.val = gCtx.allocate(null, getDataTypeSizeOf(C.nnz)); @@ -424,30 +398,25 @@ public class CSRPointer { // nnzC elements respectively, then finally calls function cusparse[S|D|C|Z]csrgeam() // to complete matrix C. - public CSRPointer clone(int rows) throws DMLRuntimeException { + public CSRPointer clone(int rows) { CSRPointer me = this; CSRPointer that = new CSRPointer(me.getGPUContext()); - that.allocateMatDescrPointer(); - that.nnz = me.nnz; that.val = allocate(that.nnz * LibMatrixCUDA.sizeOfDataType); - // TODO: Nakul ... can you please double-check whether the below was a bug or intentional ? that.rowPtr = allocate(rows * Sizeof.INT); that.colInd = allocate(that.nnz * Sizeof.INT); - cudaMemcpy(that.val, me.val, that.nnz * LibMatrixCUDA.sizeOfDataType, cudaMemcpyDeviceToDevice); cudaMemcpy(that.rowPtr, me.rowPtr, rows * Sizeof.INT, cudaMemcpyDeviceToDevice); cudaMemcpy(that.colInd, me.colInd, that.nnz * Sizeof.INT, cudaMemcpyDeviceToDevice); - return that; } - private Pointer allocate(long size) throws DMLRuntimeException { + private Pointer allocate(long size) { return getGPUContext().allocate(size); } - private void cudaFreeHelper(Pointer toFree, boolean eager) throws DMLRuntimeException { + private void cudaFreeHelper(Pointer toFree, boolean eager) { getGPUContext().cudaFreeHelper(toFree, eager); } @@ -490,10 +459,9 @@ public class CSRPointer { * @param cols number of columns in this CSR matrix * @param instName name of the invoking instruction to record{@link Statistics}. * @return A {@link Pointer} to the allocated dense matrix (in column-major format) - * @throws DMLRuntimeException if DMLRuntimeException occurs */ public Pointer toColumnMajorDenseMatrix(cusparseHandle cusparseHandle, cublasHandle cublasHandle, int rows, - int cols, String instName) throws DMLRuntimeException { + int cols, String instName) { long t0 = DMLScript.FINEGRAINED_STATISTICS && instName != null ? System.nanoTime() : 0; LOG.trace("GPU : sparse -> column major dense (inside CSRPointer) on " + this + ", GPUContext=" + getGPUContext()); @@ -514,9 +482,8 @@ public class CSRPointer { /** * Calls cudaFree lazily on the allocated {@link Pointer} instances * - * @throws DMLRuntimeException ? */ - public void deallocate() throws DMLRuntimeException { + public void deallocate() { deallocate(DMLScript.EAGER_CUDA_FREE); } @@ -524,9 +491,8 @@ public class CSRPointer { * Calls cudaFree lazily or eagerly on the allocated {@link Pointer} instances * * @param eager whether to do eager or lazy cudaFrees - * @throws DMLRuntimeException ? */ - public void deallocate(boolean eager) throws DMLRuntimeException { + public void deallocate(boolean eager) { if (nnz > 0) { cudaFreeHelper(val, eager); cudaFreeHelper(rowPtr, eager); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/ExecutionConfig.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/ExecutionConfig.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/ExecutionConfig.java index cae0660..872fef7 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/ExecutionConfig.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/ExecutionConfig.java @@ -66,9 +66,8 @@ public class ExecutionConfig { * * @param numCells number of cells * @return execution configuration - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public static ExecutionConfig getConfigForSimpleVectorOperations(int numCells) throws DMLRuntimeException { + public static ExecutionConfig getConfigForSimpleVectorOperations(int numCells) { if(numCells == 0) throw new DMLRuntimeException("Attempting to invoke a kernel with 0 threads"); int deviceNumber = 0; @@ -86,9 +85,8 @@ public class ExecutionConfig { * @param rlen number of rows * @param clen number of columns * @return execution configuration - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public static ExecutionConfig getConfigForSimpleMatrixOperations(int rlen, int clen) throws DMLRuntimeException { + public static ExecutionConfig getConfigForSimpleMatrixOperations(int rlen, int clen) { return getConfigForSimpleVectorOperations(rlen * clen); } @@ -109,9 +107,8 @@ public class ExecutionConfig { * * @param deviceNumber device number of the given device * @return The maximum block dimension, in x-direction - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - private static int getMaxBlockDim(int deviceNumber) throws DMLRuntimeException { + private static int getMaxBlockDim(int deviceNumber) { // return 32; // TODO: Use JCudaDriver.cuOccupancyMaxPotentialBlockSize to chose the block size that maximizes occupancy Integer ret = maxBlockDimForDevice.get(deviceNumber); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContext.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContext.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContext.java index 9f41e04..7f8f106 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContext.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContext.java @@ -90,7 +90,7 @@ public class GPUContext { return memoryManager; } - protected GPUContext(int deviceNum) throws DMLRuntimeException { + protected GPUContext(int deviceNum) { this.deviceNum = deviceNum; cudaSetDevice(deviceNum); @@ -123,15 +123,14 @@ public class GPUContext { * Print information of memory usage. * * @param opcode opcode of caller - * @throws DMLRuntimeException if error */ - public void printMemoryInfo(String opcode) throws DMLRuntimeException { + public void printMemoryInfo(String opcode) { if (LOG.isDebugEnabled()) { LOG.debug(opcode + ": " + memoryManager.toString()); } } - private void initializeCudaLibraryHandles() throws DMLRuntimeException { + private void initializeCudaLibraryHandles() { deleteCudaLibraryHandles(); if (cudnnHandle == null) { @@ -178,9 +177,8 @@ public class GPUContext { * If in a multi-threaded environment like parfor, this method must be called when in the * appropriate thread. * - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public void initializeThread() throws DMLRuntimeException { + public void initializeThread() { cudaSetDevice(deviceNum); initializeCudaLibraryHandles(); } @@ -190,9 +188,8 @@ public class GPUContext { * * @param size size of data (in bytes) to allocate * @return jcuda pointer - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public Pointer allocate(long size) throws DMLRuntimeException { + public Pointer allocate(long size) { return memoryManager.malloc(null, size); } @@ -202,9 +199,8 @@ public class GPUContext { * @param instructionName name of instruction for which to record per instruction performance statistics, null if don't want to record * @param size size of data (in bytes) to allocate * @return jcuda pointer - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public Pointer allocate(String instructionName, long size) throws DMLRuntimeException { + public Pointer allocate(String instructionName, long size) { return memoryManager.malloc(instructionName, size); } @@ -213,9 +209,8 @@ public class GPUContext { * Does lazy cudaFree calls. * * @param toFree {@link Pointer} instance to be freed - * @throws DMLRuntimeException if error */ - public void cudaFreeHelper(final Pointer toFree) throws DMLRuntimeException { + public void cudaFreeHelper(final Pointer toFree) { cudaFreeHelper(null, toFree, DMLScript.EAGER_CUDA_FREE); } @@ -224,9 +219,8 @@ public class GPUContext { * * @param toFree {@link Pointer} instance to be freed * @param eager true if to be done eagerly - * @throws DMLRuntimeException if error */ - public void cudaFreeHelper(final Pointer toFree, boolean eager) throws DMLRuntimeException { + public void cudaFreeHelper(final Pointer toFree, boolean eager) { cudaFreeHelper(null, toFree, eager); } @@ -235,9 +229,8 @@ public class GPUContext { * * @param instructionName name of the instruction for which to record per instruction free time, null if do not want to record * @param toFree {@link Pointer} instance to be freed - * @throws DMLRuntimeException if error */ - public void cudaFreeHelper(String instructionName, final Pointer toFree) throws DMLRuntimeException { + public void cudaFreeHelper(String instructionName, final Pointer toFree) { cudaFreeHelper(instructionName, toFree, DMLScript.EAGER_CUDA_FREE); } @@ -247,9 +240,8 @@ public class GPUContext { * @param instructionName name of the instruction for which to record per instruction free time, null if do not want to record * @param toFree {@link Pointer} instance to be freed * @param eager true if to be done eagerly - * @throws DMLRuntimeException if error */ - public void cudaFreeHelper(String instructionName, final Pointer toFree, boolean eager) throws DMLRuntimeException { + public void cudaFreeHelper(String instructionName, final Pointer toFree, boolean eager) { memoryManager.free(instructionName, toFree, eager); } @@ -265,10 +257,8 @@ public class GPUContext { /** * Makes sure that GPU that SystemML is trying to use has the minimum compute capability needed. - * - * @throws DMLRuntimeException if the compute capability is less than what is required */ - public void ensureComputeCapability() throws DMLRuntimeException { + public void ensureComputeCapability() { int[] devices = { -1 }; cudaGetDeviceCount(devices); if (devices[0] == -1) { @@ -308,9 +298,8 @@ public class GPUContext { * Gets the device properties for the active GPU (set with cudaSetDevice()). * * @return the device properties - * @throws DMLRuntimeException ? */ - public cudaDeviceProp getGPUProperties() throws DMLRuntimeException { + public cudaDeviceProp getGPUProperties() { return GPUContextPool.getGPUProperties(deviceNum); } @@ -318,9 +307,8 @@ public class GPUContext { * Gets the maximum number of threads per block for "active" GPU. * * @return the maximum number of threads per block - * @throws DMLRuntimeException ? */ - public int getMaxThreadsPerBlock() throws DMLRuntimeException { + public int getMaxThreadsPerBlock() { cudaDeviceProp deviceProps = getGPUProperties(); return deviceProps.maxThreadsPerBlock; } @@ -329,9 +317,8 @@ public class GPUContext { * Gets the maximum number of blocks supported by the active cuda device. * * @return the maximum number of blocks supported - * @throws DMLRuntimeException ? */ - public int getMaxBlocks() throws DMLRuntimeException { + public int getMaxBlocks() { cudaDeviceProp deviceProp = getGPUProperties(); return deviceProp.maxGridSize[0]; } @@ -340,9 +327,8 @@ public class GPUContext { * Gets the shared memory per block supported by the active cuda device. * * @return the shared memory per block - * @throws DMLRuntimeException ? */ - public long getMaxSharedMemory() throws DMLRuntimeException { + public long getMaxSharedMemory() { cudaDeviceProp deviceProp = getGPUProperties(); return deviceProp.sharedMemPerBlock; } @@ -351,9 +337,8 @@ public class GPUContext { * Gets the warp size supported by the active cuda device. * * @return the warp size - * @throws DMLRuntimeException ? */ - public int getWarpSize() throws DMLRuntimeException { + public int getWarpSize() { cudaDeviceProp deviceProp = getGPUProperties(); return deviceProp.warpSize; } @@ -406,9 +391,8 @@ public class GPUContext { /** * Destroys this GPUContext object. * - * @throws DMLRuntimeException if error */ - public void destroy() throws DMLRuntimeException { + public void destroy() { if (LOG.isTraceEnabled()) { LOG.trace("GPU : this context was destroyed, this = " + this.toString()); } @@ -445,14 +429,12 @@ public class GPUContext { * If memory is being used between MLContext invocations, they are pointed to by a {@link GPUObject} instance * which would be part of the {@link MatrixObject}. The cleanup of that {@link MatrixObject} instance will * cause the memory associated with that block on the GPU to be freed up. - * - * @throws DMLRuntimeException ? */ - public void clearMemory() throws DMLRuntimeException { + public void clearMemory() { memoryManager.clearMemory(); } - public void clearTemporaryMemory() throws DMLRuntimeException { + public void clearTemporaryMemory() { memoryManager.clearTemporaryMemory(); } @@ -460,5 +442,4 @@ public class GPUContext { public String toString() { return "GPUContext{" + "deviceNum=" + deviceNum + '}'; } - } http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContextPool.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContextPool.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContextPool.java index e030180..242127a 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContextPool.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUContextPool.java @@ -80,10 +80,8 @@ public class GPUContextPool { * Also sets behaviour for J{Cuda, Cudnn, Cublas, Cusparse} in case of error * Initializes the CUDA driver * All these need be done once, and not per GPU - * - * @throws DMLRuntimeException ? */ - public synchronized static void initializeGPU() throws DMLRuntimeException { + public synchronized static void initializeGPU() { initialized = true; GPUContext.LOG.info("Initializing CUDA"); long start = System.nanoTime(); @@ -207,9 +205,8 @@ public class GPUContextPool { * Reserves and gets an initialized list of GPUContexts * * @return null if no GPUContexts in pool, otherwise a valid list of GPUContext - * @throws DMLRuntimeException ? */ - public static synchronized List<GPUContext> reserveAllGPUContexts() throws DMLRuntimeException { + public static synchronized List<GPUContext> reserveAllGPUContexts() { if (reserved) throw new DMLRuntimeException("Trying to re-reserve GPUs"); if (!initialized) @@ -233,9 +230,8 @@ public class GPUContextPool { * * @param device the device number (on a machine with more than 1 GPU) * @return the device properties - * @throws DMLRuntimeException if there is problem initializing the GPUContexts */ - static cudaDeviceProp getGPUProperties(int device) throws DMLRuntimeException { + static cudaDeviceProp getGPUProperties(int device) { // do once - initialization of GPU if (!initialized) initializeGPU(); @@ -246,9 +242,8 @@ public class GPUContextPool { * Number of available devices on this machine * * @return number of available GPUs on this machine - * @throws DMLRuntimeException if error */ - public static int getDeviceCount() throws DMLRuntimeException { + public static int getDeviceCount() { if (!initialized) initializeGPU(); return deviceCount; @@ -256,10 +251,8 @@ public class GPUContextPool { /** * Unreserves all GPUContexts - * - * @throws DMLRuntimeException if error */ - public static synchronized void freeAllGPUContexts() throws DMLRuntimeException { + public static synchronized void freeAllGPUContexts() { if (!reserved) throw new DMLRuntimeException("Trying to free unreserved GPUs"); reserved = false; http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUMemoryManager.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUMemoryManager.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUMemoryManager.java index c0df38b..e2012a7 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUMemoryManager.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUMemoryManager.java @@ -153,9 +153,8 @@ public class GPUMemoryManager { * @param opcode instruction name * @param size size in bytes * @return allocated pointer - * @throws DMLRuntimeException if error */ - public Pointer malloc(String opcode, long size) throws DMLRuntimeException { + public Pointer malloc(String opcode, long size) { if(size < 0) { throw new DMLRuntimeException("Cannot allocate memory of size " + size); } @@ -296,9 +295,8 @@ public class GPUMemoryManager { * @param opcode instruction name * @param toFree pointer to free * @param eager whether to deallocate eagerly - * @throws DMLRuntimeException if error */ - public void free(String opcode, Pointer toFree, boolean eager) throws DMLRuntimeException { + public void free(String opcode, Pointer toFree, boolean eager) { Pointer dummy = new Pointer(); if (toFree == dummy) { // trying to free a null pointer return; @@ -325,10 +323,8 @@ public class GPUMemoryManager { /** * Clear the allocated GPU objects - * - * @throws DMLRuntimeException if error */ - public void clearMemory() throws DMLRuntimeException { + public void clearMemory() { // First deallocate all the GPU objects for(GPUObject gpuObj : allocatedGPUObjects) { if(gpuObj.isDirty()) { http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUObject.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUObject.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUObject.java index c0a50ec..613e16f 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUObject.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/GPUObject.java @@ -98,10 +98,6 @@ public class GPUObject { */ protected MatrixObject mat = null; - // private Pointer allocate(String instName, long size) throws DMLRuntimeException { - // return getGPUContext().allocate(instName, size); - // } - @Override public Object clone() { GPUObject me = this; @@ -135,19 +131,15 @@ public class GPUObject { return that; } - private Pointer allocate(long size) throws DMLRuntimeException { + private Pointer allocate(long size) { return getGPUContext().allocate(size); } - private void cudaFreeHelper(Pointer toFree) throws DMLRuntimeException { + private void cudaFreeHelper(Pointer toFree) { getGPUContext().cudaFreeHelper(toFree); } - // private void cudaFreeHelper(Pointer toFree, boolean eager) throws DMLRuntimeException { - // getGPUContext().cudaFreeHelper(toFree, eager); - // } - - private void cudaFreeHelper(String instName, Pointer toFree, boolean eager) throws DMLRuntimeException { + private void cudaFreeHelper(String instName, Pointer toFree, boolean eager) { getGPUContext().cudaFreeHelper(instName, toFree, eager); } @@ -164,11 +156,9 @@ public class GPUObject { * @param n columns in output matrix * @param lda rows in input matrix * @param ldc columns in output matrix - * @throws DMLRuntimeException if operation failed * @return transposed matrix */ - public static Pointer transpose(GPUContext gCtx, Pointer densePtr, int m, int n, int lda, int ldc) - throws DMLRuntimeException { + public static Pointer transpose(GPUContext gCtx, Pointer densePtr, int m, int n, int lda, int ldc) { if(LOG.isTraceEnabled()) { LOG.trace("GPU : transpose of block of size [" + m + "," + n + "]" + ", GPUContext=" + gCtx); } @@ -195,10 +185,9 @@ public class GPUObject { * @param rows number of rows * @param cols number of columns * @return CSR (compressed sparse row) pointer - * @throws DMLRuntimeException if DMLRuntimeException occurs */ public static CSRPointer columnMajorDenseToRowMajorSparse(GPUContext gCtx, cusparseHandle cusparseHandle, - Pointer densePtr, int rows, int cols) throws DMLRuntimeException { + Pointer densePtr, int rows, int cols) { cusparseMatDescr matDescr = CSRPointer.getDefaultCuSparseMatrixDescriptor(); Pointer nnzPerRowPtr = null; Pointer nnzTotalDevHostPtr = null; @@ -255,9 +244,8 @@ public class GPUObject { * Needed for operations like cusparseDcsrgemm(cusparseHandle, int, int, int, int, int, cusparseMatDescr, int, Pointer, Pointer, Pointer, cusparseMatDescr, int, Pointer, Pointer, Pointer, cusparseMatDescr, Pointer, Pointer, Pointer) * * @param sparseMatrixPtr CSR (compressed sparse row) pointer - * @throws DMLRuntimeException ? */ - public void setSparseMatrixCudaPointer(CSRPointer sparseMatrixPtr) throws DMLRuntimeException { + public void setSparseMatrixCudaPointer(CSRPointer sparseMatrixPtr) { if (this.jcudaSparseMatrixPtr != null) { throw new DMLRuntimeException("jcudaSparseMatrixPtr was already allocated for " + this + ", this will cause a memory leak on the GPU"); } @@ -273,9 +261,8 @@ public class GPUObject { * Convenience method to directly set the dense matrix pointer on GPU * * @param densePtr dense pointer - * @throws DMLRuntimeException ? */ - public void setDenseMatrixCudaPointer(Pointer densePtr) throws DMLRuntimeException { + public void setDenseMatrixCudaPointer(Pointer densePtr) { if (this.jcudaDenseMatrixPtr != null) { throw new DMLRuntimeException("jcudaDenseMatrixPtr was already allocated for " + this + ", this will cause a memory leak on the GPU"); } @@ -292,10 +279,8 @@ public class GPUObject { /** * Converts this GPUObject from dense to sparse format. - * - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public void denseToSparse() throws DMLRuntimeException { + public void denseToSparse() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : dense -> sparse on " + this + ", GPUContext=" + getGPUContext()); } @@ -324,10 +309,8 @@ public class GPUObject { /** * Convenience method. Converts Row Major Dense Matrix to Column Major Dense Matrix - * - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public void denseRowMajorToColumnMajor() throws DMLRuntimeException { + public void denseRowMajorToColumnMajor() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : dense Ptr row-major -> col-major on " + this + ", GPUContext=" + getGPUContext()); } @@ -347,10 +330,8 @@ public class GPUObject { /** * Convenience method. Converts Column Major Dense Matrix to Row Major Dense Matrix - * - * @throws DMLRuntimeException if error */ - public void denseColumnMajorToRowMajor() throws DMLRuntimeException { + public void denseColumnMajorToRowMajor() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : dense Ptr row-major -> col-major on " + this + ", GPUContext=" + getGPUContext()); } @@ -371,10 +352,8 @@ public class GPUObject { /** * Convert sparse to dense (Performs transpose, use sparseToColumnMajorDense if the kernel can deal with column major format) - * - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public void sparseToDense() throws DMLRuntimeException { + public void sparseToDense() { sparseToDense(null); } @@ -383,9 +362,8 @@ public class GPUObject { * Also records per instruction invokation of sparseToDense. * * @param instructionName Name of the instruction for which statistics are recorded in {@link GPUStatistics} - * @throws DMLRuntimeException ? */ - public void sparseToDense(String instructionName) throws DMLRuntimeException { + public void sparseToDense(String instructionName) { if(LOG.isTraceEnabled()) { LOG.trace("GPU : sparse -> dense on " + this + ", GPUContext=" + getGPUContext()); } @@ -409,10 +387,8 @@ public class GPUObject { /** * More efficient method to convert sparse to dense but returns dense in column major format - * - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public void sparseToColumnMajorDense() throws DMLRuntimeException { + public void sparseToColumnMajorDense() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : sparse -> col-major dense on " + this + ", GPUContext=" + getGPUContext()); } @@ -457,10 +433,8 @@ public class GPUObject { /** * Allocates a sparse and empty {@link GPUObject} * This is the result of operations that are both non zero matrices. - * - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public void allocateSparseAndEmpty() throws DMLRuntimeException { + public void allocateSparseAndEmpty() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : allocate sparse and empty block on " + this + ", GPUContext=" + getGPUContext()); } @@ -472,9 +446,8 @@ public class GPUObject { * and fills it up with a single value * * @param v value to fill up the dense matrix - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public void allocateAndFillDense(double v) throws DMLRuntimeException { + public void allocateAndFillDense(double v) { if(LOG.isTraceEnabled()) { LOG.trace("GPU : allocate and fill dense with value " + v + " on " + this + ", GPUContext=" + getGPUContext()); } @@ -496,9 +469,8 @@ public class GPUObject { * Being allocated is a prerequisite to being sparse and empty. * * @return true if sparse and empty - * @throws DMLRuntimeException if error */ - public boolean isSparseAndEmpty() throws DMLRuntimeException { + public boolean isSparseAndEmpty() { boolean isSparseAndAllocated = isAllocated() && LibMatrixCUDA.isInSparseFormat(getGPUContext(), mat); boolean isEmptyAndSparseAndAllocated = isSparseAndAllocated && getJcudaSparseMatrixPtr().nnz == 0; return isEmptyAndSparseAndAllocated; @@ -511,9 +483,8 @@ public class GPUObject { * @param instName instruction name * @param recomputeDenseNNZ recompute NNZ if dense * @return the number of nonzeroes - * @throws DMLRuntimeException if error */ - public long getNnz(String instName, boolean recomputeDenseNNZ) throws DMLRuntimeException { + public long getNnz(String instName, boolean recomputeDenseNNZ) { if(isAllocated()) { if(LibMatrixCUDA.isInSparseFormat(getGPUContext(), mat)) { return getJcudaSparseMatrixPtr().nnz; @@ -554,7 +525,7 @@ public class GPUObject { throw new DMLRuntimeException("Expected the GPU object to be allocated"); } - public boolean acquireDeviceRead(String opcode) throws DMLRuntimeException { + public boolean acquireDeviceRead(String opcode) { if(LOG.isTraceEnabled()) { LOG.trace("GPU : acquireDeviceRead on " + this); } @@ -573,7 +544,7 @@ public class GPUObject { return transferred; } - public boolean acquireDeviceModifyDense() throws DMLRuntimeException { + public boolean acquireDeviceModifyDense() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : acquireDeviceModifyDense on " + this + ", GPUContext=" + getGPUContext()); } @@ -593,7 +564,7 @@ public class GPUObject { return allocated; } - public boolean acquireDeviceModifySparse() throws DMLRuntimeException { + public boolean acquireDeviceModifySparse() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : acquireDeviceModifySparse on " + this + ", GPUContext=" + getGPUContext()); } @@ -619,7 +590,7 @@ public class GPUObject { * @param instName name of the instruction * @return true if a copy to host happened, false otherwise */ - public boolean acquireHostRead(String instName) throws DMLRuntimeException { + public boolean acquireHostRead(String instName) { boolean copied = false; if(LOG.isTraceEnabled()) { LOG.trace("GPU : acquireDeviceModifySparse on " + this + ", GPUContext=" + getGPUContext()); @@ -639,14 +610,14 @@ public class GPUObject { return writeLock || readLocks.longValue() > 0; } - public void addReadLock() throws DMLRuntimeException { + public void addReadLock() { if(writeLock) throw new DMLRuntimeException("Attempting to add a read lock when writeLock="+ writeLock); else readLocks.increment(); } - public void addWriteLock() throws DMLRuntimeException { + public void addWriteLock() { if(readLocks.longValue() > 0) throw new DMLRuntimeException("Attempting to add a write lock when readLocks="+ readLocks.longValue()); else if(writeLock) @@ -655,13 +626,13 @@ public class GPUObject { writeLock = true; } - public void releaseReadLock() throws DMLRuntimeException { + public void releaseReadLock() { readLocks.decrement(); if(readLocks.longValue() < 0) throw new DMLRuntimeException("Attempting to release a read lock when readLocks="+ readLocks.longValue()); } - public void releaseWriteLock() throws DMLRuntimeException { + public void releaseWriteLock() { if(writeLock) writeLock = false; else @@ -675,10 +646,8 @@ public class GPUObject { /** * Updates the locks depending on the eviction policy selected - * - * @throws DMLRuntimeException if there is no locked GPU Object or if could not obtain a {@link GPUContext} */ - private void updateReleaseLocks() throws DMLRuntimeException { + private void updateReleaseLocks() { DMLScript.EvictionPolicy evictionPolicy = DMLScript.GPU_EVICTION_POLICY; switch (evictionPolicy) { case LRU: @@ -699,10 +668,8 @@ public class GPUObject { /** * Releases input allocated on GPU - * - * @throws DMLRuntimeException if data is not allocated or if there is no locked GPU Object or if could not obtain a {@link GPUContext} */ - public void releaseInput() throws DMLRuntimeException { + public void releaseInput() { releaseReadLock(); updateReleaseLocks(); if (!isAllocated()) @@ -711,10 +678,8 @@ public class GPUObject { /** * releases output allocated on GPU - * - * @throws DMLRuntimeException if data is not allocated or if there is no locked GPU Object or if could not obtain a {@link GPUContext} */ - public void releaseOutput() throws DMLRuntimeException { + public void releaseOutput() { releaseWriteLock(); updateReleaseLocks(); // Currently, there is no convenient way to acquireDeviceModify independently of dense/sparse format. @@ -725,7 +690,7 @@ public class GPUObject { throw new DMLRuntimeException("Attempting to release an output before allocating it"); } - void allocateDenseMatrixOnDevice() throws DMLRuntimeException { + void allocateDenseMatrixOnDevice() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : allocateDenseMatrixOnDevice, on " + this + ", GPUContext=" + getGPUContext()); } @@ -742,7 +707,7 @@ public class GPUObject { setDenseMatrixCudaPointer(tmp); } - void allocateSparseMatrixOnDevice() throws DMLRuntimeException { + void allocateSparseMatrixOnDevice() { if(LOG.isTraceEnabled()) { LOG.trace("GPU : allocateSparseMatrixOnDevice, on " + this + ", GPUContext=" + getGPUContext()); } http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/JCudaKernels.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/JCudaKernels.java b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/JCudaKernels.java index 181b08d..743c7e6 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/JCudaKernels.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/gpu/context/JCudaKernels.java @@ -55,10 +55,8 @@ public class JCudaKernels { /** * Loads the kernels in the file ptxFileName. Though cubin files are also supported, we will stick with * ptx file as they are target-independent similar to Java's .class files. - * - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - JCudaKernels() throws DMLRuntimeException { + JCudaKernels() { module = new CUmodule(); // Load the kernels specified in the ptxFileName file checkResult(cuModuleLoadDataEx(module, initKernels(ptxFileName), 0, new int[0], Pointer.to(new int[0]))); @@ -71,9 +69,8 @@ public class JCudaKernels { * @param name name of the kernel * @param config execution configuration * @param arguments can be of type Pointer, long, double, float and int - * @throws DMLRuntimeException if DMLRuntimeException occurs */ - public void launchKernel(String name, ExecutionConfig config, Object... arguments) throws DMLRuntimeException { + public void launchKernel(String name, ExecutionConfig config, Object... arguments) { name = name + LibMatrixCUDA.customKernelSuffix; CUfunction function = kernels.get(name); @@ -115,7 +112,7 @@ public class JCudaKernels { JCuda.cudaDeviceSynchronize(); } - public static void checkResult(int cuResult) throws DMLRuntimeException { + public static void checkResult(int cuResult) { if (cuResult != CUresult.CUDA_SUCCESS) { throw new DMLRuntimeException(CUresult.stringFor(cuResult)); } @@ -126,9 +123,8 @@ public class JCudaKernels { * * @param ptxFileName * @return - * @throws DMLRuntimeException */ - private static Pointer initKernels(String ptxFileName) throws DMLRuntimeException { + private static Pointer initKernels(String ptxFileName) { InputStream in = null; ByteArrayOutputStream out = null; try { http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateBinaryInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateBinaryInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateBinaryInstruction.java index 1c3d8bc..2e75c9a 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateBinaryInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateBinaryInstruction.java @@ -81,9 +81,7 @@ public class AggregateBinaryInstruction extends BinaryMRInstructionBase implemen return _aggType; } - public static AggregateBinaryInstruction parseInstruction ( String str ) - throws DMLRuntimeException - { + public static AggregateBinaryInstruction parseInstruction ( String str ) { String[] parts = InstructionUtils.getInstructionParts ( str ); byte in1, in2, out; @@ -129,9 +127,7 @@ public class AggregateBinaryInstruction extends BinaryMRInstructionBase implemen @Override public void processInstruction(Class<? extends MatrixValue> valueClass, CachedValueMap cachedValues, IndexedMatrixValue tempValue, - IndexedMatrixValue zeroInput, int blockRowFactor, int blockColFactor) - throws DMLRuntimeException - { + IndexedMatrixValue zeroInput, int blockRowFactor, int blockColFactor) { IndexedMatrixValue in1=cachedValues.getFirst(input1); IndexedMatrixValue in2=cachedValues.getFirst(input2); @@ -179,10 +175,8 @@ public class AggregateBinaryInstruction extends BinaryMRInstructionBase implemen * @param in2 indexed matrix value 2 * @param blockRowFactor ? * @param blockColFactor ? - * @throws DMLRuntimeException if DMLRuntimeException occurs */ private void processMapMultInstruction(Class<? extends MatrixValue> valueClass, CachedValueMap cachedValues, IndexedMatrixValue in1, IndexedMatrixValue in2, int blockRowFactor, int blockColFactor) - throws DMLRuntimeException { boolean removeOutput = true; http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateInstruction.java index be924df..d8038a5 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateInstruction.java @@ -34,9 +34,7 @@ public class AggregateInstruction extends UnaryMRInstructionBase { instString = istr; } - public static AggregateInstruction parseInstruction ( String str ) - throws DMLRuntimeException - { + public static AggregateInstruction parseInstruction ( String str ) { String[] parts = InstructionUtils.getInstructionParts ( str ); byte in, out; @@ -52,7 +50,7 @@ public class AggregateInstruction extends UnaryMRInstructionBase { } else { InstructionUtils.checkNumFields ( str, 2 ); - agg = InstructionUtils.parseAggregateOperator(opcode, null, null); + agg = InstructionUtils.parseAggregateOperator(opcode, null, null); } return new AggregateInstruction(agg, in, out, str); @@ -61,8 +59,7 @@ public class AggregateInstruction extends UnaryMRInstructionBase { @Override public void processInstruction(Class<? extends MatrixValue> valueClass, CachedValueMap cachedValues, IndexedMatrixValue tempValue, - IndexedMatrixValue zeroInput, int blockRowFactor, int blockColFactor) - throws DMLRuntimeException { + IndexedMatrixValue zeroInput, int blockRowFactor, int blockColFactor) { throw new DMLRuntimeException("no processInstruction for AggregateInstruction!"); http://git-wip-us.apache.org/repos/asf/systemml/blob/1f323976/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateUnaryInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateUnaryInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateUnaryInstruction.java index 923d110..6d2b07f 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateUnaryInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/mr/AggregateUnaryInstruction.java @@ -21,7 +21,6 @@ package org.apache.sysml.runtime.instructions.mr; import java.util.ArrayList; -import org.apache.sysml.runtime.DMLRuntimeException; import org.apache.sysml.runtime.functionobjects.ReduceDiag; import org.apache.sysml.runtime.instructions.InstructionUtils; import org.apache.sysml.runtime.matrix.data.MatrixBlock; @@ -42,7 +41,7 @@ public class AggregateUnaryInstruction extends UnaryMRInstructionBase { _dropCorr = dropCorr; } - public static AggregateUnaryInstruction parseInstruction ( String str ) throws DMLRuntimeException { + public static AggregateUnaryInstruction parseInstruction ( String str ) { InstructionUtils.checkNumFields ( str, 3 ); @@ -60,8 +59,7 @@ public class AggregateUnaryInstruction extends UnaryMRInstructionBase { @Override public void processInstruction(Class<? extends MatrixValue> valueClass, CachedValueMap cachedValues, IndexedMatrixValue tempValue, IndexedMatrixValue zeroInput, - int blockRowFactor, int blockColFactor) - throws DMLRuntimeException { + int blockRowFactor, int blockColFactor) { ArrayList<IndexedMatrixValue> blkList = cachedValues.get(input); if( blkList != null )
