Skip to content

Commit 17655b7

Browse files
committed
Correct batch mode partitiion count calculation
1 parent 746b58e commit 17655b7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Driver/Compilation.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,14 @@ namespace driver {
13651365
size_t NumTasks = TQ->getNumberOfParallelTasks();
13661366
size_t NumFiles = PendingExecution.size();
13671367
size_t SizeLimit = Comp.getBatchSizeLimit().getValueOr(DefaultSizeLimit);
1368-
return std::max(NumTasks, NumFiles / SizeLimit);
1368+
1369+
// An explanation of why the partition calculation isn't simple division.
1370+
// Using the default limit as an example, a module of 26 files must be
1371+
// compiled in 2 batches. Simple division yields 26/25 = 1 batch, but a
1372+
// single batch of 26 would exceed the limit of 25. To round up, the
1373+
// calculation is: `(x - 1) / y + 1`.
1374+
size_t NumPartitions = (NumFiles - 1) / SizeLimit + 1;
1375+
return std::max(NumTasks, NumPartitions);
13691376
}
13701377

13711378
/// Select jobs that are batch-combinable from \c PendingExecution, combine

0 commit comments

Comments
 (0)