Fix last batch when n_tasks in not a multiple of batch size.
This commit is contained in:
parent
5cf9e119c6
commit
5c34ae92de
1 changed files with 7 additions and 1 deletions
|
@ -233,7 +233,13 @@ SEXP CCubes(SEXP tt) {
|
||||||
int n_tasks_batch = 512;
|
int n_tasks_batch = 512;
|
||||||
for (int task = 0; task < n_tasks; task+=n_tasks_batch) {
|
for (int task = 0; task < n_tasks; task+=n_tasks_batch) {
|
||||||
/* adjust if batch size is larger than total job size */
|
/* adjust if batch size is larger than total job size */
|
||||||
int current_batch = n_tasks < n_tasks_batch ? n_tasks : n_tasks_batch;
|
int current_batch = n_tasks_batch;
|
||||||
|
/* single batch */
|
||||||
|
if (n_tasks < n_tasks_batch)
|
||||||
|
current_batch = n_tasks;
|
||||||
|
/* last batch */
|
||||||
|
if (n_tasks - task < n_tasks_batch)
|
||||||
|
current_batch = n_tasks - task;
|
||||||
|
|
||||||
log_debug("ccubes", "Tasks %d - %d out of %d",
|
log_debug("ccubes", "Tasks %d - %d out of %d",
|
||||||
task, task + current_batch - 1, n_tasks);
|
task, task + current_batch - 1, n_tasks);
|
||||||
|
|
Loading…
Add table
Reference in a new issue