src/main/java/org/apache/sysds/runtime/compress/lib/LibRightMultBy.java
/**
	 * Multi-threaded version of rightMultByVector.
	 * 
	 * @param colGroups The Column groups used int the multiplication
	 * @param vector	matrix block vector to multiply with
	 * @param result	matrix block result to modify in the multiplication
	 * @param k		 number of threads to use
	 * @param v		 The Precalculated counts and Maximum number of tuple entries in the column groups
	 */
Multi-threaded version of rightMultByVector.


Multi - threaded version of rightMultByVector .
public static void rightMultByVector(List<ColGroup> colGroups, MatrixBlock vector, MatrixBlock result, int k,
		Pair<Integer, int[]> v) {
		result.allocateDenseBlock();
		if(k <= 1) {
			rightMultByVector(colGroups, vector, result, v);
			return;
		}
		try {
			ExecutorService pool = CommonThreadPool.get(k);
			int rlen = colGroups.get(0).getNumRows();
			int seqsz = CompressionSettings.BITMAP_BLOCK_SZ;
			int blklen = (int) (Math.ceil((double) rlen / k));
			blklen += (blklen % seqsz != 0) ? seqsz - blklen % seqsz : 0;
			ArrayList<RightMatrixVectorMultTask> tasks = new ArrayList<>();
			for(int i = 0; i < k & i * blklen < rlen; i++) {
				tasks.add(new RightMatrixVectorMultTask(colGroups, vector, result, i * blklen,
					Math.min((i + 1) * blklen, rlen), v));
			}
			List<Future<Long>> ret = pool.invokeAll(tasks);
			pool.shutdown();
			long lnnz = 0;
			for(Future<Long> tmp : ret)
				lnnz += tmp.get();
			result.setNonZeros(lnnz);
		}
		catch(InterruptedException | ExecutionException e) {
			throw new DMLRuntimeException(e);
		}
	}
public static void rightMultByVector ( List < ColGroup > colGroups , MatrixBlock vector , MatrixBlock result , int k , Pair < Integer , int [ ] > v ) { result . allocateDenseBlock ( ) ; if ( k <= 1 ) { rightMultByVector ( colGroups , vector , result , v ) ; return ; } try { ExecutorService pool = CommonThreadPool . get ( k ) ; int rlen = colGroups . get ( 0 ) . getNumRows ( ) ; int seqsz = CompressionSettings . BITMAP_BLOCK_SZ ; int blklen = ( int ) ( Math . ceil ( ( double ) rlen / k ) ) ; blklen += ( blklen % seqsz != 0 ) ? seqsz - blklen % seqsz : 0 ; ArrayList < RightMatrixVectorMultTask > tasks = new ArrayList < > ( ) ; for ( int i = 0 ; i < k & i * blklen < rlen ; i ++ ) { tasks . add ( new RightMatrixVectorMultTask ( colGroups , vector , result , i * blklen , Math . min ( ( i + 1 ) * blklen , rlen ) , v ) ) ; } List < Future < Long > > ret = pool . invokeAll ( tasks ) ; pool . shutdown ( ) ; long lnnz = 0 ; for ( Future < Long > tmp : ret ) lnnz += tmp . get ( ) ; result . setNonZeros ( lnnz ) ; } catch ( InterruptedException | ExecutionException e ) { throw new DMLRuntimeException ( e ) ; } }
Multi-threaded version of rightMultByVector.
Multi - threaded version of rightMultByVector .
// initialize and allocate the result // multi-threaded execution of all groups // ColGroupUncompressed uc = getUncompressedColGroup(); // compute uncompressed column group in parallel // if(uc != null) // uc.rightMultByVector(vector, result, k); // compute remaining compressed column groups in parallel // note: OLE needs alignment to segment size, otherwise wrong entry // error handling and nnz aggregation