Skip to content

Commit fc30a33

Browse files
committed
comment on parallelization threshold
1 parent 4b8a8ee commit fc30a33

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/main/java/org/apache/sysds/runtime/frame/data/columns/Array.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
public abstract class Array<T> implements Writable {
5151
protected static final Log LOG = LogFactory.getLog(Array.class.getName());
5252

53+
/** Parallelization threshold for parallelizing vector operations */
5354
public static int ROW_PARALLELIZATION_THRESHOLD = 10000;
5455

5556
/** A soft reference to a memorization of this arrays mapping, used in transformEncode */
@@ -176,7 +177,7 @@ protected Map<T, Integer> createRecodeMap(int estimate, ExecutorService pool)
176177
private Map<T, Integer> parallelCreateRecodeMap(int estimate, ExecutorService pool, final int s, int k)
177178
throws InterruptedException, ExecutionException {
178179

179-
final int blk = Math.max(ROW_PARALLELIZATION_THRESHOLD, (s + k) / k);
180+
final int blk = Math.max(ROW_PARALLELIZATION_THRESHOLD / 2, (s + k) / k);
180181
final List<Future<Map<T, Integer>>> tasks = new ArrayList<>();
181182
for(int i = blk; i < s; i += blk) { // start at blk for the other threads
182183
final int start = i;
@@ -343,7 +344,7 @@ public double getAsNaNDouble(int i) {
343344
* @param ru row upper (inclusive)
344345
* @param value value array to take values from (same type) offset by rl.
345346
*/
346-
public final void set(int rl, int ru, Array<T> value){
347+
public final void set(int rl, int ru, Array<T> value) {
347348
set(rl, ru, value, 0);
348349
}
349350

src/main/java/org/apache/sysds/runtime/transform/encode/CompressedEncode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ private AMapToData binEncode(Array<?> a, ColumnEncoderBin b, boolean nulls)
247247
private void BinEncodeParallel(Array<?> a, ColumnEncoderBin b, boolean nulls, final AMapToData m, final int rlen)
248248
throws InterruptedException, ExecutionException {
249249
final List<Future<?>> tasks = new ArrayList<>();
250-
final int blockSize = Math.max(ROW_PARALLELIZATION_THRESHOLD, rlen + k / k);
250+
final int blockSize = Math.max(ROW_PARALLELIZATION_THRESHOLD / 2, rlen + k / k);
251251
final ExecutorService pool = CommonThreadPool.get(k);
252-
try{
252+
try {
253253

254254
for(int i = 0; i < rlen; i += blockSize) {
255255
final int start = i;
@@ -264,7 +264,7 @@ private void BinEncodeParallel(Array<?> a, ColumnEncoderBin b, boolean nulls, fi
264264
for(Future<?> t : tasks)
265265
t.get();
266266
}
267-
finally{
267+
finally {
268268
pool.shutdown();
269269
}
270270
}
@@ -436,7 +436,7 @@ private <T> AMapToData createMappingAMapToData(Array<T> a, Map<T, Integer> map,
436436

437437
private <T> AMapToData CreateMappingParallel(Array<T> a, Map<T, Integer> map, boolean containsNull, final int si,
438438
final int nRow, final AMapToData m) throws InterruptedException, ExecutionException {
439-
final int blkz = Math.max(ROW_PARALLELIZATION_THRESHOLD, (nRow + k) / k);
439+
final int blkz = Math.max(ROW_PARALLELIZATION_THRESHOLD / 2, (nRow + k) / k);
440440

441441
List<Future<?>> tasks = new ArrayList<>();
442442
// make a thread local pool.

0 commit comments

Comments
 (0)