From b53f0564433f22ccb3a1624689a3f4713c2e37ac Mon Sep 17 00:00:00 2001 From: Niketan Pansare Date: Tue, 2 May 2017 20:27:48 -0700 Subject: [PATCH] [SYSTEMML-1572] Enable native BLAS on remote executors --- .../compress/CompressedMatrixBlock.java | 10 ++-- .../cp/AggregateBinaryCPInstruction.java | 4 +- .../mr/AggregateBinaryInstruction.java | 8 ++-- .../instructions/spark/CpmmSPInstruction.java | 9 ++-- .../spark/MapmmSPInstruction.java | 47 ++++++++++++------- .../spark/PMapmmSPInstruction.java | 9 ++-- .../instructions/spark/RmmSPInstruction.java | 9 ++-- .../spark/Tsmm2SPInstruction.java | 17 ++++--- .../spark/ZipmmSPInstruction.java | 9 ++-- .../runtime/matrix/data/CM_N_COVCell.java | 4 +- .../runtime/matrix/data/MatrixBlock.java | 19 ++------ .../sysml/runtime/matrix/data/MatrixCell.java | 4 +- .../runtime/matrix/data/MatrixValue.java | 4 +- .../matrix/data/OperationsOnMatrixValues.java | 12 ++--- .../mapred/MMCJMRReducerWithAggregator.java | 6 ++- .../runtime/matrix/mapred/MMRJMRReducer.java | 3 +- .../org/apache/sysml/utils/NativeHelper.java | 12 +++-- .../compress/BasicMatrixVectorMultTest.java | 5 +- .../compress/BasicVectorMatrixMultTest.java | 5 +- .../compress/LargeMatrixVectorMultTest.java | 5 +- .../LargeParMatrixVectorMultTest.java | 5 +- .../compress/LargeVectorMatrixMultTest.java | 5 +- .../compress/ParMatrixVectorMultTest.java | 5 +- .../compress/ParVectorMatrixMultTest.java | 5 +- 24 files changed, 128 insertions(+), 93 deletions(-) diff --git a/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java b/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java index ed2ab278bfe..96add654dff 100644 --- a/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java +++ b/src/main/java/org/apache/sysml/runtime/compress/CompressedMatrixBlock.java @@ -963,18 +963,18 @@ public MatrixBlock chainMatrixMultOperations(MatrixBlock v, MatrixBlock w, Matri } @Override - public MatrixValue aggregateBinaryOperations(MatrixValue mv1, MatrixValue mv2, MatrixValue result, AggregateBinaryOperator op) + public MatrixValue aggregateBinaryOperations(MatrixValue mv1, MatrixValue mv2, MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { //call uncompressed matrix mult if necessary if( !isCompressed() ) { - return super.aggregateBinaryOperations(mv1, mv2, result, op); + return super.aggregateBinaryOperations(mv1, mv2, result, op, useNativeBLAS); } //multi-threaded mm of single uncompressed colgroup if( isSingleUncompressedGroup() ){ MatrixBlock tmp = ((ColGroupUncompressed)_colGroups.get(0)).getData(); - return tmp.aggregateBinaryOperations(this==mv1?tmp:mv1, this==mv2?tmp:mv2, result, op); + return tmp.aggregateBinaryOperations(this==mv1?tmp:mv1, this==mv2?tmp:mv2, result, op, useNativeBLAS); } Timing time = LOG.isDebugEnabled() ? new Timing(true) : null; @@ -2003,12 +2003,12 @@ public MatrixValue sortOperations(MatrixValue weights, MatrixValue result) @Override public MatrixValue aggregateBinaryOperations(MatrixIndexes m1Index, MatrixValue m1Value, MatrixIndexes m2Index, MatrixValue m2Value, - MatrixValue result, AggregateBinaryOperator op) + MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { printDecompressWarning("aggregateBinaryOperations"); MatrixBlock left = isCompressed() ? decompress() : this; MatrixBlock right = getUncompressed(m2Value); - return left.aggregateBinaryOperations(m1Index, left, m2Index, right, result, op); + return left.aggregateBinaryOperations(m1Index, left, m2Index, right, result, op, useNativeBLAS); } @Override diff --git a/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateBinaryCPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateBinaryCPInstruction.java index 3bcdbdb51aa..0cd8ffe0b59 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateBinaryCPInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateBinaryCPInstruction.java @@ -73,12 +73,12 @@ public void processInstruction(ExecutionContext ec) //get inputs MatrixBlock matBlock1 = ec.getMatrixInput(input1.getName()); MatrixBlock matBlock2 = ec.getMatrixInput(input2.getName()); - + //compute matrix multiplication AggregateBinaryOperator ab_op = (AggregateBinaryOperator) _optr; MatrixBlock soresBlock = null; if( matBlock2 instanceof CompressedMatrixBlock ) - soresBlock = (MatrixBlock) (matBlock2.aggregateBinaryOperations(matBlock1, matBlock2, new MatrixBlock(), ab_op)); + soresBlock = (MatrixBlock) (matBlock2.aggregateBinaryOperations(matBlock1, matBlock2, new MatrixBlock(), ab_op, NativeHelper.isNativeLibraryLoaded())); else { soresBlock = (MatrixBlock) (matBlock1.aggregateBinaryOperations(matBlock1, matBlock2, new MatrixBlock(), ab_op, NativeHelper.isNativeLibraryLoaded())); } 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 e9a023a84cf..575ddfb5e83 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 @@ -44,6 +44,8 @@ public class AggregateBinaryInstruction extends BinaryMRInstructionBase implemen { private String _opcode = null; + boolean useNativeBLAS = false; // Since MR is in maintenance mode + //optional argument for cpmm private MMCJType _aggType = MMCJType.AGG; @@ -166,7 +168,7 @@ public void processInstruction(Class valueClass, in1.getIndexes(), in1.getValue(), in2.getIndexes(), in2.getValue(), out.getIndexes(), out.getValue(), - ((AggregateBinaryOperator)optr)); + ((AggregateBinaryOperator)optr), useNativeBLAS); //put the output value in the cache if(out==tempValue) @@ -213,7 +215,7 @@ private void processMapMultInstruction(Class valueClass, //process instruction OperationsOnMatrixValues.performAggregateBinary(in1.getIndexes(), in1.getValue(), in2BlockIndex, in2BlockValue, out.getIndexes(), out.getValue(), - ((AggregateBinaryOperator)optr)); + ((AggregateBinaryOperator)optr), useNativeBLAS); removeOutput &= ( !_outputEmptyBlocks && out.getValue().isEmpty() ); } @@ -242,7 +244,7 @@ private void processMapMultInstruction(Class valueClass, OperationsOnMatrixValues.performAggregateBinary(in1BlockIndex, in1BlockValue, in2.getIndexes(), in2.getValue(), out.getIndexes(), out.getValue(), - ((AggregateBinaryOperator)optr)); + ((AggregateBinaryOperator)optr), useNativeBLAS); removeOutput &= ( !_outputEmptyBlocks && out.getValue().isEmpty() ); } diff --git a/src/main/java/org/apache/sysml/runtime/instructions/spark/CpmmSPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/spark/CpmmSPInstruction.java index 4a29c5e5887..67a4dcdabc4 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/spark/CpmmSPInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/spark/CpmmSPInstruction.java @@ -39,6 +39,7 @@ import org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator; import org.apache.sysml.runtime.matrix.operators.AggregateOperator; import org.apache.sysml.runtime.matrix.operators.Operator; +import org.apache.sysml.utils.NativeHelper; /** * Cpmm: cross-product matrix multiplication operation (distributed matrix multiply @@ -98,7 +99,7 @@ public void processInstruction(ExecutionContext ec) JavaPairRDD tmp2 = in2.mapToPair(new CpmmIndexFunction(false)); JavaPairRDD out = tmp1 .join(tmp2) // join over common dimension - .mapToPair(new CpmmMultiplyFunction()); // compute block multiplications + .mapToPair(new CpmmMultiplyFunction(NativeHelper.isNativeLibraryLoaded())); // compute block multiplications //process cpmm aggregation and handle outputs if( _aggtype == SparkAggType.SINGLE_BLOCK ) @@ -150,11 +151,13 @@ private static class CpmmMultiplyFunction implements PairFunction call(Tuple2 out = in1.map(new RDDMapMMFunction2(type, in2)); + JavaRDD out = in1.map(new RDDMapMMFunction2(type, in2, NativeHelper.isNativeLibraryLoaded())); MatrixBlock out2 = RDDAggregateUtils.sumStable(out); //put output block into symbol table (no lineage because single block) @@ -155,12 +156,12 @@ public void processInstruction(ExecutionContext ec) +numParts+" partitions to satisfy size restrictions of output partitions."); in1 = in1.repartition(numParts); } - out = in1.flatMapToPair( new RDDFlatMapMMFunction(type, in2) ); + out = in1.flatMapToPair( new RDDFlatMapMMFunction(type, in2, NativeHelper.isNativeLibraryLoaded()) ); } else if( preservesPartitioning(mcRdd, type) ) - out = in1.mapPartitionsToPair(new RDDMapMMPartitionFunction(type, in2), true); + out = in1.mapPartitionsToPair(new RDDMapMMPartitionFunction(type, in2, NativeHelper.isNativeLibraryLoaded()), true); else - out = in1.mapToPair( new RDDMapMMFunction(type, in2) ); + out = in1.mapToPair( new RDDMapMMFunction(type, in2, NativeHelper.isNativeLibraryLoaded()) ); //empty output block filter if( !_outputEmpty ) @@ -252,11 +253,13 @@ private static class RDDMapMMFunction implements PairFunction _pbc; + private boolean _useNativeBLAS; - public RDDMapMMFunction( CacheType type, PartitionedBroadcast binput ) + public RDDMapMMFunction( CacheType type, PartitionedBroadcast binput, boolean useNativeBLAS ) { _type = type; _pbc = binput; + _useNativeBLAS = useNativeBLAS; //created operator for reuse AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject()); @@ -280,7 +283,7 @@ public Tuple2 call( Tuple2 call( Tuple2 _pbc; + private boolean _useNativeBLAS; - public RDDMapMMFunction2( CacheType type, PartitionedBroadcast binput ) + public RDDMapMMFunction2( CacheType type, PartitionedBroadcast binput, boolean useNativeBLAS ) { _type = type; _pbc = binput; + _useNativeBLAS = useNativeBLAS; //created operator for reuse AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject()); @@ -332,7 +337,7 @@ public MatrixBlock call( Tuple2 arg0 ) //execute matrix-vector mult return (MatrixBlock) OperationsOnMatrixValues.performAggregateBinaryIgnoreIndexes( - left, blkIn, new MatrixBlock(), _op); + left, blkIn, new MatrixBlock(), _op, _useNativeBLAS); } else //if( _type == CacheType.RIGHT ) { @@ -341,7 +346,7 @@ public MatrixBlock call( Tuple2 arg0 ) //execute matrix-vector mult return (MatrixBlock) OperationsOnMatrixValues.performAggregateBinaryIgnoreIndexes( - blkIn, right, new MatrixBlock(), _op); + blkIn, right, new MatrixBlock(), _op, _useNativeBLAS); } } } @@ -353,11 +358,13 @@ private static class RDDMapMMPartitionFunction implements PairFlatMapFunction _pbc; + private boolean _useNativeBLAS; - public RDDMapMMPartitionFunction( CacheType type, PartitionedBroadcast binput ) + public RDDMapMMPartitionFunction( CacheType type, PartitionedBroadcast binput, boolean useNativeBLAS ) { _type = type; _pbc = binput; + _useNativeBLAS = useNativeBLAS; //created operator for reuse AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject()); @@ -368,7 +375,7 @@ public RDDMapMMPartitionFunction( CacheType type, PartitionedBroadcast> call(Iterator> arg0) throws Exception { - return new MapMMPartitionIterator(arg0); + return new MapMMPartitionIterator(arg0, _useNativeBLAS); } /** @@ -378,8 +385,10 @@ public LazyIterableIterator> call(Iterator> { - public MapMMPartitionIterator(Iterator> in) { + boolean _useNativeBLAS; + public MapMMPartitionIterator(Iterator> in, boolean useNativeBLAS) { super(in); + _useNativeBLAS = useNativeBLAS; } @Override @@ -396,7 +405,7 @@ protected Tuple2 computeNext(Tuple2 computeNext(Tuple2(ixIn, blkOut); @@ -419,11 +428,13 @@ private static class RDDFlatMapMMFunction implements PairFlatMapFunction _pbc; + private boolean _useNativeBLAS; - public RDDFlatMapMMFunction( CacheType type, PartitionedBroadcast binput ) + public RDDFlatMapMMFunction( CacheType type, PartitionedBroadcast binput, boolean useNativeBLAS ) { _type = type; _pbc = binput; + _useNativeBLAS = useNativeBLAS; //created operator for reuse AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject()); @@ -451,7 +462,7 @@ public Iterator> call( Tuple2(ixOut, blkOut)); } @@ -469,7 +480,7 @@ public Iterator> call( Tuple2(ixOut, blkOut)); } diff --git a/src/main/java/org/apache/sysml/runtime/instructions/spark/PMapmmSPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/spark/PMapmmSPInstruction.java index eceeabc0c0c..a606a3ae7bc 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/spark/PMapmmSPInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/spark/PMapmmSPInstruction.java @@ -49,6 +49,7 @@ import org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator; import org.apache.sysml.runtime.matrix.operators.AggregateOperator; import org.apache.sysml.runtime.matrix.operators.Operator; +import org.apache.sysml.utils.NativeHelper; /** * This pmapmm matrix multiplication instruction is still experimental @@ -119,7 +120,7 @@ public void processInstruction(ExecutionContext ec) //matrix multiplication JavaPairRDD rdd2 = in2 - .flatMapToPair(new PMapMMFunction(bpmb, i/mc1.getRowsPerBlock())); + .flatMapToPair(new PMapMMFunction(bpmb, i/mc1.getRowsPerBlock(), NativeHelper.isNativeLibraryLoaded())); rdd2 = RDDAggregateUtils.sumByKeyStable(rdd2, false); rdd2.persist(pmapmmStorageLevel) .count(); @@ -171,11 +172,13 @@ private static class PMapMMFunction implements PairFlatMapFunction> _pbc = null; private long _offset = -1; + private boolean _useNativeBLAS; - public PMapMMFunction( Broadcast> binput, long offset ) + public PMapMMFunction( Broadcast> binput, long offset, boolean useNativeBLAS ) { _pbc = binput; _offset = offset; + _useNativeBLAS = useNativeBLAS; //created operator for reuse AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject()); @@ -202,7 +205,7 @@ public Iterator> call(Tuple2 out = tmp1.join( tmp2 ) //join by result block - .mapToPair( new RmmMultiplyFunction() ); //do matrix multiplication + .mapToPair( new RmmMultiplyFunction(NativeHelper.isNativeLibraryLoaded()) ); //do matrix multiplication out = RDDAggregateUtils.sumByKeyStable(out, false); //aggregation per result block //put output block into symbol table (no lineage because single block) @@ -162,11 +163,13 @@ private static class RmmMultiplyFunction implements PairFunction call( Tuple2(ixOut, blkOut); diff --git a/src/main/java/org/apache/sysml/runtime/instructions/spark/Tsmm2SPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/spark/Tsmm2SPInstruction.java index 1f1b3e4d5a9..553bea5ff9a 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/spark/Tsmm2SPInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/spark/Tsmm2SPInstruction.java @@ -50,6 +50,7 @@ import org.apache.sysml.runtime.matrix.operators.AggregateBinaryOperator; import org.apache.sysml.runtime.matrix.operators.AggregateOperator; import org.apache.sysml.runtime.matrix.operators.Operator; +import org.apache.sysml.utils.NativeHelper; import scala.Tuple2; @@ -109,7 +110,7 @@ public void processInstruction(ExecutionContext ec) if( OptimizerUtils.estimateSize(outputDim, outputDim) <= 32*1024*1024 ) { //default: <=32MB //output large blocks and reduceAll to avoid skew on combineByKey JavaRDD tmp2 = in.map( - new RDDTSMM2ExtFunction(bpmb, _type, outputDim, (int)mc.getRowsPerBlock())); + new RDDTSMM2ExtFunction(bpmb, _type, outputDim, (int)mc.getRowsPerBlock(), NativeHelper.isNativeLibraryLoaded())); MatrixBlock out = RDDAggregateUtils.sumStable(tmp2); //put output block into symbol table (no lineage because single block) @@ -118,7 +119,7 @@ public void processInstruction(ExecutionContext ec) } else { //output individual output blocks and aggregate by key (no action) - JavaPairRDD tmp2 = in.flatMapToPair(new RDDTSMM2Function(bpmb, _type)); + JavaPairRDD tmp2 = in.flatMapToPair(new RDDTSMM2Function(bpmb, _type, NativeHelper.isNativeLibraryLoaded())); JavaPairRDD out = RDDAggregateUtils.sumByKeyStable(tmp2, false); //put output RDD handle into symbol table @@ -135,10 +136,12 @@ private static class RDDTSMM2Function implements PairFlatMapFunction> _pb = null; private MMTSJType _type = null; private AggregateBinaryOperator _op = null; + private boolean _useNativeBLAS; - public RDDTSMM2Function( Broadcast> pb, MMTSJType type ) { + public RDDTSMM2Function( Broadcast> pb, MMTSJType type, boolean useNativeBLAS ) { _pb = pb; _type = type; + _useNativeBLAS = useNativeBLAS; //created operator for reuse AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject()); @@ -166,7 +169,7 @@ public Iterator> call(Tuple2(ixout2, out2)); @@ -192,12 +195,14 @@ private static class RDDTSMM2ExtFunction implements Function> pb, MMTSJType type, int outputDim, int blen ) { + public RDDTSMM2ExtFunction( Broadcast> pb, MMTSJType type, int outputDim, int blen, boolean useNativeBLAS ) { _pb = pb; _type = type; _outputDim = outputDim; _blen = blen; + _useNativeBLAS = useNativeBLAS; //created operator for reuse AggregateOperator agg = new AggregateOperator(0, Plus.getPlusFnObject()); @@ -228,7 +233,7 @@ public MatrixBlock call(Tuple2 arg0) MatrixBlock mbin2t = transpose(mbin2, new MatrixBlock()); //prep for transpose rewrite mm MatrixBlock out2 = (MatrixBlock) OperationsOnMatrixValues.performAggregateBinaryIgnoreIndexes( //mm - _type.isLeft() ? mbin2t : mbin, _type.isLeft() ? mbin : mbin2t, new MatrixBlock(), _op); + _type.isLeft() ? mbin2t : mbin, _type.isLeft() ? mbin : mbin2t, new MatrixBlock(), _op, _useNativeBLAS); MatrixIndexes ixout2 = _type.isLeft() ? new MatrixIndexes(2,1) : new MatrixIndexes(1,2); out.copy((int)(ixout2.getRowIndex()-1)*_blen, (int)(ixout2.getRowIndex()-1)*_blen+out2.getNumRows()-1, diff --git a/src/main/java/org/apache/sysml/runtime/instructions/spark/ZipmmSPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/spark/ZipmmSPInstruction.java index e21eefacbe8..1c34a213001 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/spark/ZipmmSPInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/spark/ZipmmSPInstruction.java @@ -40,6 +40,7 @@ import org.apache.sysml.runtime.matrix.operators.AggregateOperator; import org.apache.sysml.runtime.matrix.operators.Operator; import org.apache.sysml.runtime.matrix.operators.ReorgOperator; +import org.apache.sysml.utils.NativeHelper; public class ZipmmSPInstruction extends BinarySPInstruction @@ -90,7 +91,7 @@ public void processInstruction(ExecutionContext ec) //process core zipmm matrix multiply (in contrast to cpmm, the join over original indexes //preserves the original partitioning and with that potentially unnecessary join shuffle) JavaRDD out = in1.join(in2).values() // join over original indexes - .map(new ZipMultiplyFunction(_tRewrite)); // compute block multiplications, incl t(y) + .map(new ZipMultiplyFunction(_tRewrite, NativeHelper.isNativeLibraryLoaded())); // compute block multiplications, incl t(y) //single-block aggregation (guaranteed by zipmm blocksize constraint) MatrixBlock out2 = RDDAggregateUtils.sumStable(out); @@ -113,13 +114,15 @@ private static class ZipMultiplyFunction implements Function arg0) MatrixBlock tmp = (MatrixBlock)in2.reorgOperations(_rop, new MatrixBlock(), 0, 0, 0); //core matrix multiplication (for t(y)%*%X or t(X)%*%y) - return (MatrixBlock)tmp.aggregateBinaryOperations(tmp, in1, new MatrixBlock(), _abop); + return (MatrixBlock)tmp.aggregateBinaryOperations(tmp, in1, new MatrixBlock(), _abop, _useNativeBLAS); } } } diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/CM_N_COVCell.java b/src/main/java/org/apache/sysml/runtime/matrix/data/CM_N_COVCell.java index 7da497981ca..c0305342f42 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/data/CM_N_COVCell.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/data/CM_N_COVCell.java @@ -53,7 +53,7 @@ public String toString() @Override public MatrixValue aggregateBinaryOperations(MatrixValue m1Value, - MatrixValue m2Value, MatrixValue result, AggregateBinaryOperator op) + MatrixValue m2Value, MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { throw new DMLRuntimeException("operation not supported fro WeightedCell"); } @@ -319,7 +319,7 @@ public MatrixValue aggregateUnaryOperations(AggregateUnaryOperator op, @Override public MatrixValue aggregateBinaryOperations(MatrixIndexes m1Index, MatrixValue m1Value, MatrixIndexes m2Index, MatrixValue m2Value, - MatrixValue result, AggregateBinaryOperator op) + MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { throw new DMLRuntimeException("operation not supported fro WeightedCell"); } diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixBlock.java b/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixBlock.java index 4172e44c79f..df15d040220 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixBlock.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixBlock.java @@ -85,7 +85,6 @@ import org.apache.sysml.runtime.util.FastBufferedDataOutputStream; import org.apache.sysml.runtime.util.IndexRange; import org.apache.sysml.runtime.util.UtilFunctions; -import org.apache.sysml.utils.NativeHelper; @@ -4874,24 +4873,14 @@ private double sumWeightForQuantile() return sum_wt; } - - public MatrixValue aggregateBinaryOperations(MatrixIndexes m1Index, MatrixValue m1Value, MatrixIndexes m2Index, MatrixValue m2Value, - MatrixValue result, AggregateBinaryOperator op ) throws DMLRuntimeException - { - return aggregateBinaryOperations(m1Value, m2Value, result, op, NativeHelper.isNativeLibraryLoaded()); - } public MatrixValue aggregateBinaryOperations(MatrixIndexes m1Index, MatrixValue m1Value, MatrixIndexes m2Index, MatrixValue m2Value, - MatrixValue result, AggregateBinaryOperator op, boolean enableNativeBLAS ) throws DMLRuntimeException + MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS ) throws DMLRuntimeException { - return aggregateBinaryOperations(m1Value, m2Value, result, op, enableNativeBLAS); - } - - public MatrixValue aggregateBinaryOperations(MatrixValue m1Value, MatrixValue m2Value, MatrixValue result, AggregateBinaryOperator op) throws DMLRuntimeException { - return aggregateBinaryOperations(m1Value, m2Value, result, op, NativeHelper.isNativeLibraryLoaded()); + return aggregateBinaryOperations(m1Value, m2Value, result, op, useNativeBLAS); } - public MatrixValue aggregateBinaryOperations(MatrixValue m1Value, MatrixValue m2Value, MatrixValue result, AggregateBinaryOperator op, boolean nativeMatMult) + public MatrixValue aggregateBinaryOperations(MatrixValue m1Value, MatrixValue m2Value, MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { //check input types, dimensions, configuration @@ -4917,7 +4906,7 @@ public MatrixValue aggregateBinaryOperations(MatrixValue m1Value, MatrixValue m2 ret.reset(rl, cl, sp.sparse, sp.estimatedNonZeros); //compute matrix multiplication (only supported binary aggregate operation) - if( nativeMatMult ) + if( useNativeBLAS ) LibMatrixNative.matrixMult(m1, m2, ret, op.getNumThreads()); else if( op.getNumThreads() > 1 ) LibMatrixMult.matrixMult(m1, m2, ret, op.getNumThreads()); diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixCell.java b/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixCell.java index 62db808a3ed..6b0e1b154e0 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixCell.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixCell.java @@ -170,7 +170,7 @@ public void write(DataOutput out) throws IOException { @Override public MatrixValue aggregateBinaryOperations(MatrixValue value1, - MatrixValue value2, MatrixValue result, AggregateBinaryOperator op) + MatrixValue value2, MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { MatrixCell c1=checkType(value1); @@ -431,7 +431,7 @@ public MatrixValue aggregateUnaryOperations(AggregateUnaryOperator op, @Override public MatrixValue aggregateBinaryOperations(MatrixIndexes m1Index, MatrixValue m1Value, MatrixIndexes m2Index, MatrixValue m2Value, - MatrixValue result, AggregateBinaryOperator op) + MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { throw new DMLRuntimeException("MatrixCell.aggregateBinaryOperations should never be called"); } diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixValue.java b/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixValue.java index bb95af25e8d..02b1f3aa9f9 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixValue.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/data/MatrixValue.java @@ -146,11 +146,11 @@ public abstract MatrixValue aggregateUnaryOperations(AggregateUnaryOperator op, throws DMLRuntimeException; public abstract MatrixValue aggregateBinaryOperations(MatrixValue m1Value, MatrixValue m2Value, - MatrixValue result, AggregateBinaryOperator op) + MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException; public abstract MatrixValue aggregateBinaryOperations(MatrixIndexes m1Index, MatrixValue m1Value, MatrixIndexes m2Index, MatrixValue m2Value, - MatrixValue result, AggregateBinaryOperator op) + MatrixValue result, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException; public abstract MatrixValue unaryOperations(UnaryOperator op, MatrixValue result) diff --git a/src/main/java/org/apache/sysml/runtime/matrix/data/OperationsOnMatrixValues.java b/src/main/java/org/apache/sysml/runtime/matrix/data/OperationsOnMatrixValues.java index 27734e1b4aa..dfa59aee8e8 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/data/OperationsOnMatrixValues.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/data/OperationsOnMatrixValues.java @@ -261,7 +261,7 @@ public static void performAggregateUnary(MatrixIndexes indexesIn, MatrixValue va } public static void performAggregateBinary(MatrixIndexes indexes1, MatrixValue value1, MatrixIndexes indexes2, MatrixValue value2, - MatrixIndexes indexesOut, MatrixValue valueOut, AggregateBinaryOperator op) + MatrixIndexes indexesOut, MatrixValue valueOut, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { //compute output index @@ -269,21 +269,21 @@ public static void performAggregateBinary(MatrixIndexes indexes1, MatrixValue va //perform on the value if( value2 instanceof CompressedMatrixBlock ) - value2.aggregateBinaryOperations(value1, value2, valueOut, op); + value2.aggregateBinaryOperations(value1, value2, valueOut, op, useNativeBLAS); else //default - value1.aggregateBinaryOperations(indexes1, value1, indexes2, value2, valueOut, op); + value1.aggregateBinaryOperations(indexes1, value1, indexes2, value2, valueOut, op, useNativeBLAS); } public static MatrixValue performAggregateBinaryIgnoreIndexes( MatrixValue value1, MatrixValue value2, - MatrixValue valueOut, AggregateBinaryOperator op) + MatrixValue valueOut, AggregateBinaryOperator op, boolean useNativeBLAS) throws DMLRuntimeException { //perform on the value if( value2 instanceof CompressedMatrixBlock ) - value2.aggregateBinaryOperations(value1, value2, valueOut, op); + value2.aggregateBinaryOperations(value1, value2, valueOut, op, useNativeBLAS); else - value1.aggregateBinaryOperations(value1, value2, valueOut, op); + value1.aggregateBinaryOperations(value1, value2, valueOut, op, useNativeBLAS); return valueOut; } diff --git a/src/main/java/org/apache/sysml/runtime/matrix/mapred/MMCJMRReducerWithAggregator.java b/src/main/java/org/apache/sysml/runtime/matrix/mapred/MMCJMRReducerWithAggregator.java index 85306a6803f..04af1996880 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/mapred/MMCJMRReducerWithAggregator.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/mapred/MMCJMRReducerWithAggregator.java @@ -47,6 +47,8 @@ public class MMCJMRReducerWithAggregator extends MMCJMRCombinerReducerBase public static long MIN_CACHE_SIZE = 64*1024*1024; //64MB + boolean useNativeBLAS = false; // Since MR is in maintenance mode + private MMCJMRInputCache cache = null; private PartialAggregator aggregator = null; @@ -124,14 +126,14 @@ private void processJoin(int tag, long inIndex, MatrixValue inValue) //perform matrix multiplication indexesbuffer.setIndexes(tmp.getKey().getRowIndex(), inIndex); OperationsOnMatrixValues.performAggregateBinaryIgnoreIndexes(tmp.getValue(), inValue, valueBuffer, - (AggregateBinaryOperator)aggBinInstruction.getOperator()); + (AggregateBinaryOperator)aggBinInstruction.getOperator(), useNativeBLAS); } else //right cached { //perform matrix multiplication indexesbuffer.setIndexes(inIndex, tmp.getKey().getColumnIndex()); OperationsOnMatrixValues.performAggregateBinaryIgnoreIndexes(inValue, tmp.getValue(), valueBuffer, - (AggregateBinaryOperator)aggBinInstruction.getOperator()); + (AggregateBinaryOperator)aggBinInstruction.getOperator(), useNativeBLAS); } //aggregate block to output buffer or direct output diff --git a/src/main/java/org/apache/sysml/runtime/matrix/mapred/MMRJMRReducer.java b/src/main/java/org/apache/sysml/runtime/matrix/mapred/MMRJMRReducer.java index 2b500b72893..4380f092b25 100644 --- a/src/main/java/org/apache/sysml/runtime/matrix/mapred/MMRJMRReducer.java +++ b/src/main/java/org/apache/sysml/runtime/matrix/mapred/MMRJMRReducer.java @@ -50,6 +50,7 @@ public class MMRJMRReducer extends ReduceBase //aggregate binary instruction for the mmrj protected AggregateBinaryInstruction[] aggBinInstructions=null; // private MatrixIndexes indexBuf=new MatrixIndexes(); + private boolean useNativeBLAS = false; // Since MR is in maintenance mode @Override public void reduce(TripleIndexes triple, Iterator values, @@ -112,7 +113,7 @@ private void processAggBinaryPerGroup(MatrixIndexes indexes, AggregateBinaryInst { try { resultblock=left.getValue().aggregateBinaryOperations(left.getValue(), right.getValue(), - resultblock, (AggregateBinaryOperator) aggBinInstruction.getOperator()); + resultblock, (AggregateBinaryOperator) aggBinInstruction.getOperator(), useNativeBLAS); // System.out.println("resultblock: \n"+resultblock); IndexedMatrixValue out=cachedValues.getFirst(aggBinInstruction.output); if(out==null) diff --git a/src/main/java/org/apache/sysml/utils/NativeHelper.java b/src/main/java/org/apache/sysml/utils/NativeHelper.java index 129824b7aa0..e13e785d309 100644 --- a/src/main/java/org/apache/sysml/utils/NativeHelper.java +++ b/src/main/java/org/apache/sysml/utils/NativeHelper.java @@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory; import java.util.HashMap; +import java.util.HashSet; import java.util.Vector; import java.io.InputStream; import java.io.OutputStream; @@ -196,16 +197,21 @@ private static boolean isOpenBLASAvailable() { return loadBLAS("openblas", null); } + // This avoids unnecessary loading of previously loaded libraries. + private static HashSet failedLoadingBLAS = new HashSet(); private static boolean loadBLAS(String blas, String optionalMsg) { try { - System.loadLibrary(blas); - return true; + if(failedLoadingBLAS.contains(blas)) + return false; + System.loadLibrary(blas); + return true; } catch (UnsatisfiedLinkError e) { if(!hintOnFailures.contains(blas)) hintOnFailures = hintOnFailures + blas + " "; + failedLoadingBLAS.add(blas); if(optionalMsg != null) - LOG.debug("Unable to load " + blas + "(" + optionalMsg + "):" + e.getMessage()); + LOG.warn("Unable to load " + blas + "(" + optionalMsg + "):" + e.getMessage()); else LOG.debug("Unable to load " + blas + ":" + e.getMessage()); return false; diff --git a/src/test/java/org/apache/sysml/test/integration/functions/compress/BasicMatrixVectorMultTest.java b/src/test/java/org/apache/sysml/test/integration/functions/compress/BasicMatrixVectorMultTest.java index 5a19f6e1bf0..335e97043c0 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/compress/BasicMatrixVectorMultTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/compress/BasicMatrixVectorMultTest.java @@ -41,6 +41,7 @@ public class BasicMatrixVectorMultTest extends AutomatedTestBase private static final double sparsity1 = 0.9; private static final double sparsity2 = 0.1; private static final double sparsity3 = 0.0; + private static final boolean useNativeBLAS = false; public enum SparsityType { DENSE, @@ -176,10 +177,10 @@ private void runMatrixVectorMultTest(SparsityType sptype, ValueType vtype, boole //matrix-vector uncompressed AggregateOperator aop = new AggregateOperator(0, Plus.getPlusFnObject()); AggregateBinaryOperator abop = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), aop); - MatrixBlock ret1 = (MatrixBlock)mb.aggregateBinaryOperations(mb, vector, new MatrixBlock(), abop); + MatrixBlock ret1 = (MatrixBlock)mb.aggregateBinaryOperations(mb, vector, new MatrixBlock(), abop, useNativeBLAS); //matrix-vector compressed - MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(cmb, vector, new MatrixBlock(), abop); + MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(cmb, vector, new MatrixBlock(), abop, useNativeBLAS); //compare result with input double[][] d1 = DataConverter.convertToDoubleMatrix(ret1); diff --git a/src/test/java/org/apache/sysml/test/integration/functions/compress/BasicVectorMatrixMultTest.java b/src/test/java/org/apache/sysml/test/integration/functions/compress/BasicVectorMatrixMultTest.java index 69a8016fd1d..bbe94a28b16 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/compress/BasicVectorMatrixMultTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/compress/BasicVectorMatrixMultTest.java @@ -41,6 +41,7 @@ public class BasicVectorMatrixMultTest extends AutomatedTestBase private static final double sparsity1 = 0.9; private static final double sparsity2 = 0.1; private static final double sparsity3 = 0.0; + private static final boolean useNativeBLAS = false; public enum SparsityType { DENSE, @@ -176,10 +177,10 @@ private void runMatrixVectorMultTest(SparsityType sptype, ValueType vtype, boole //matrix-vector uncompressed AggregateOperator aop = new AggregateOperator(0, Plus.getPlusFnObject()); AggregateBinaryOperator abop = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), aop); - MatrixBlock ret1 = (MatrixBlock)vector.aggregateBinaryOperations(vector, mb, new MatrixBlock(), abop); + MatrixBlock ret1 = (MatrixBlock)vector.aggregateBinaryOperations(vector, mb, new MatrixBlock(), abop, useNativeBLAS); //matrix-vector compressed - MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(vector, cmb, new MatrixBlock(), abop); + MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(vector, cmb, new MatrixBlock(), abop, useNativeBLAS); //compare result with input double[][] d1 = DataConverter.convertToDoubleMatrix(ret1); diff --git a/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeMatrixVectorMultTest.java b/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeMatrixVectorMultTest.java index f5a5a4b36e0..5c9ae7ad8b1 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeMatrixVectorMultTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeMatrixVectorMultTest.java @@ -41,6 +41,7 @@ public class LargeMatrixVectorMultTest extends AutomatedTestBase private static final double sparsity1 = 0.9; private static final double sparsity2 = 0.1; private static final double sparsity3 = 0.0; + private static final boolean useNativeBLAS = false; public enum SparsityType { DENSE, @@ -176,10 +177,10 @@ private void runMatrixVectorMultTest(SparsityType sptype, ValueType vtype, boole //matrix-vector uncompressed AggregateOperator aop = new AggregateOperator(0, Plus.getPlusFnObject()); AggregateBinaryOperator abop = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), aop); - MatrixBlock ret1 = (MatrixBlock)mb.aggregateBinaryOperations(mb, vector, new MatrixBlock(), abop); + MatrixBlock ret1 = (MatrixBlock)mb.aggregateBinaryOperations(mb, vector, new MatrixBlock(), abop, useNativeBLAS); //matrix-vector compressed - MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(cmb, vector, new MatrixBlock(), abop); + MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(cmb, vector, new MatrixBlock(), abop, useNativeBLAS); //compare result with input double[][] d1 = DataConverter.convertToDoubleMatrix(ret1); diff --git a/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeParMatrixVectorMultTest.java b/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeParMatrixVectorMultTest.java index 4b6d0331a36..18d9bd85067 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeParMatrixVectorMultTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeParMatrixVectorMultTest.java @@ -42,6 +42,7 @@ public class LargeParMatrixVectorMultTest extends AutomatedTestBase private static final double sparsity1 = 0.9; private static final double sparsity2 = 0.1; private static final double sparsity3 = 0.0; + private static final boolean useNativeBLAS = false; public enum SparsityType { DENSE, @@ -178,10 +179,10 @@ private void runMatrixVectorMultTest(SparsityType sptype, ValueType vtype, boole AggregateOperator aop = new AggregateOperator(0, Plus.getPlusFnObject()); AggregateBinaryOperator abop = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), aop, InfrastructureAnalyzer.getLocalParallelism()); - MatrixBlock ret1 = (MatrixBlock)mb.aggregateBinaryOperations(mb, vector, new MatrixBlock(), abop); + MatrixBlock ret1 = (MatrixBlock)mb.aggregateBinaryOperations(mb, vector, new MatrixBlock(), abop, useNativeBLAS); //matrix-vector compressed - MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(cmb, vector, new MatrixBlock(), abop); + MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(cmb, vector, new MatrixBlock(), abop, useNativeBLAS); //compare result with input double[][] d1 = DataConverter.convertToDoubleMatrix(ret1); diff --git a/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeVectorMatrixMultTest.java b/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeVectorMatrixMultTest.java index 4da0a799bbb..c320f79dc64 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeVectorMatrixMultTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/compress/LargeVectorMatrixMultTest.java @@ -41,6 +41,7 @@ public class LargeVectorMatrixMultTest extends AutomatedTestBase private static final double sparsity1 = 0.9; private static final double sparsity2 = 0.1; private static final double sparsity3 = 0.0; + private static final boolean useNativeBLAS = false; public enum SparsityType { DENSE, @@ -176,10 +177,10 @@ private void runMatrixVectorMultTest(SparsityType sptype, ValueType vtype, boole //matrix-vector uncompressed AggregateOperator aop = new AggregateOperator(0, Plus.getPlusFnObject()); AggregateBinaryOperator abop = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), aop); - MatrixBlock ret1 = (MatrixBlock)vector.aggregateBinaryOperations(vector, mb, new MatrixBlock(), abop); + MatrixBlock ret1 = (MatrixBlock)vector.aggregateBinaryOperations(vector, mb, new MatrixBlock(), abop, useNativeBLAS); //matrix-vector compressed - MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(vector, cmb, new MatrixBlock(), abop); + MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(vector, cmb, new MatrixBlock(), abop, useNativeBLAS); //compare result with input double[][] d1 = DataConverter.convertToDoubleMatrix(ret1); diff --git a/src/test/java/org/apache/sysml/test/integration/functions/compress/ParMatrixVectorMultTest.java b/src/test/java/org/apache/sysml/test/integration/functions/compress/ParMatrixVectorMultTest.java index 30e57b48fc2..23aa62b5a46 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/compress/ParMatrixVectorMultTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/compress/ParMatrixVectorMultTest.java @@ -42,6 +42,7 @@ public class ParMatrixVectorMultTest extends AutomatedTestBase private static final double sparsity1 = 0.9; private static final double sparsity2 = 0.1; private static final double sparsity3 = 0.0; + private static final boolean useNativeBLAS = false; public enum SparsityType { DENSE, @@ -178,10 +179,10 @@ private void runMatrixVectorMultTest(SparsityType sptype, ValueType vtype, boole AggregateOperator aop = new AggregateOperator(0, Plus.getPlusFnObject()); AggregateBinaryOperator abop = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), aop, InfrastructureAnalyzer.getLocalParallelism()); - MatrixBlock ret1 = (MatrixBlock)mb.aggregateBinaryOperations(mb, vector, new MatrixBlock(), abop); + MatrixBlock ret1 = (MatrixBlock)mb.aggregateBinaryOperations(mb, vector, new MatrixBlock(), abop, useNativeBLAS); //matrix-vector compressed - MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(cmb, vector, new MatrixBlock(), abop); + MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(cmb, vector, new MatrixBlock(), abop, useNativeBLAS); //compare result with input double[][] d1 = DataConverter.convertToDoubleMatrix(ret1); diff --git a/src/test/java/org/apache/sysml/test/integration/functions/compress/ParVectorMatrixMultTest.java b/src/test/java/org/apache/sysml/test/integration/functions/compress/ParVectorMatrixMultTest.java index 5281404e316..a86b582b2d9 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/compress/ParVectorMatrixMultTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/compress/ParVectorMatrixMultTest.java @@ -41,6 +41,7 @@ public class ParVectorMatrixMultTest extends AutomatedTestBase private static final double sparsity1 = 0.9; private static final double sparsity2 = 0.1; private static final double sparsity3 = 0.0; + private static final boolean useNativeBLAS = false; public enum SparsityType { DENSE, @@ -177,10 +178,10 @@ private void runMatrixVectorMultTest(SparsityType sptype, ValueType vtype, boole AggregateOperator aop = new AggregateOperator(0, Plus.getPlusFnObject()); AggregateBinaryOperator abop = new AggregateBinaryOperator(Multiply.getMultiplyFnObject(), aop, InfrastructureAnalyzer.getLocalParallelism()); - MatrixBlock ret1 = (MatrixBlock)vector.aggregateBinaryOperations(vector, mb, new MatrixBlock(), abop); + MatrixBlock ret1 = (MatrixBlock)vector.aggregateBinaryOperations(vector, mb, new MatrixBlock(), abop, useNativeBLAS); //matrix-vector compressed - MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(vector, cmb, new MatrixBlock(), abop); + MatrixBlock ret2 = (MatrixBlock)cmb.aggregateBinaryOperations(vector, cmb, new MatrixBlock(), abop, useNativeBLAS); //compare result with input double[][] d1 = DataConverter.convertToDoubleMatrix(ret1);