[SYSTEMDS-3730] Multi-threaded rev reorg operation#2290
Conversation
|
Hi @mboehm7 , work on invoking the multi-threading part is pending. I verified the logic by directly hard coding number of threads earlier. could you give some prelim comments on this. |
| } | ||
|
|
||
| public static MatrixBlock rev(MatrixBlock in, MatrixBlock out, int k) { | ||
| if (k <= 1 || in.isEmptyBlock(false)) { |
There was a problem hiding this comment.
add a check for a minimum size for parallelization, otherwise fall back to single-threaded as we do it for example in aggregations (LibMatrixAgg).
There was a problem hiding this comment.
I have added something like 3000_000 in the hop for now, for the tests to trigger the multi-thread.
| // Set up thread pool | ||
| ExecutorService pool = CommonThreadPool.get(k); | ||
| try { | ||
| int blklen = (int) Math.ceil((double) numRows / k); |
There was a problem hiding this comment.
I would recommend to create smaller tasks (e.g., numRows/k/4) which yields better load balancing.
| final int endRow = Math.min((i + 1) * blklen, numRows); | ||
|
|
||
| tasks.add(pool.submit(() -> { | ||
| if (!sparse) { |
There was a problem hiding this comment.
create a static method for this kernel which is called from both the single-threaded implementation as well as the multi-threaded implementation
|
|
||
| try | ||
| { | ||
| System.setProperty("sysds.parallel.threads", String.valueOf(numThreads)); |
There was a problem hiding this comment.
remove (I don't think we use this property internally)
CP rev _mVar0.MATRIX.FP64 _mVar1.MATRIX.FP64 8
|
Hi @mboehm7 , thanks for review. At this point, the multi-threading is working. Can we checkpoint this PR till now and refine further in next PR? or need to update the handling. Next:
|
|
Thanks @j143 , I would address then points 3 and 4 in the next days and subsequently merge it in. |
|
Thanks for the patch @j143. During the merge, I fixed the remaining stdout printing, moved the parallelization check from compilation to runtime, used the existing common kernels, fixed test errors (dense operations where running into null-pointer exceptions), and consolidated the tests. |
Basic multi-thread rev implementation.
the rev() Operation
Given a matrix$$( A )$$ of size $$( m \times n )$$ , $$( B )$$ of the same dimensions such that:
rev()produces a matrixfor all$$( 0 \leq i < m )$$ and $$( 0 \leq j < n )$$ .
In words:
Example
Suppose:
Then after
rev(A), you get:Multi-threaded Implementation
Summary Table
test
for every cell$$( (i, j) )$$ ,
output[i][j] == input[rows - 1 - i][j]