Skip to content

Commit ce23151

Browse files
committed
[MINOR] Cocode intelligent parallel allocation
1 parent 15c6abe commit ce23151

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/java/org/apache/sysds/runtime/compress/cocode/CoCodeGreedy.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private List<CompressedSizeInfoColGroup> coCodeBruteForce(List<CompressedSizeInf
6565

6666
final List<ColIndexes> workSet = new ArrayList<>(inputColumns.size());
6767
k = k <= 0 ? InfrastructureAnalyzer.getLocalParallelism() : k;
68-
final ExecutorService pool = CommonThreadPool.get(k);
68+
final ExecutorService pool = k > 1 ? CommonThreadPool.get(k) : null;
6969
try {
7070
for(int i = 0; i < inputColumns.size(); i++) {
7171
CompressedSizeInfoColGroup g = inputColumns.get(i);
@@ -183,7 +183,8 @@ else if((newCostIfJoined < changeInCost ||
183183
return ret;
184184
}
185185
finally {
186-
pool.shutdown();
186+
if(pool != null)
187+
pool.shutdown();
187188
}
188189
}
189190

@@ -195,8 +196,12 @@ protected void parallelFirstCombine(List<ColIndexes> workSet, ExecutorService po
195196
for(int j = i + 1; j < size; j++)
196197
tasks.add(new CombineTask(workSet.get(i), workSet.get(j)));
197198

198-
for(Future<Object> t : pool.invokeAll(tasks))
199-
t.get();
199+
if(pool != null)
200+
for(Future<Object> t : pool.invokeAll(tasks))
201+
t.get();
202+
else
203+
for(CombineTask t: tasks)
204+
t.call();
200205
}
201206
catch(Exception e) {
202207
throw new DMLCompressionException("Failed parallelize first level all join all", e);

0 commit comments

Comments
 (0)