|
20 | 20 | * and Technology (RIST). All rights reserved.
|
21 | 21 | * Copyright (c) 2018 Triad National Security, LLC. All rights
|
22 | 22 | * reserved.
|
| 23 | + * Copyright (c) 2021 IBM Corporation. All rights reserved. |
23 | 24 | * $COPYRIGHT$
|
24 | 25 | *
|
25 | 26 | * Additional copyrights may follow
|
@@ -510,10 +511,41 @@ static inline bool ompi_op_is_valid(ompi_op_t * op, ompi_datatype_t * ddt,
|
510 | 511 | * is not defined to have that operation, it is likely to seg fault.
|
511 | 512 | */
|
512 | 513 | static inline void ompi_op_reduce(ompi_op_t * op, void *source,
|
513 |
| - void *target, int count, |
| 514 | + void *target, size_t full_count, |
514 | 515 | ompi_datatype_t * dtype)
|
515 | 516 | {
|
516 | 517 | MPI_Fint f_dtype, f_count;
|
| 518 | + int count = full_count; |
| 519 | + |
| 520 | + /* |
| 521 | + * If the full_count is > INT_MAX then we need to call the reduction op |
| 522 | + * in iterations of counts <= INT_MAX since it has an `int *len` |
| 523 | + * parameter. |
| 524 | + * |
| 525 | + * Note: When we add BigCount support then we can distinguish between |
| 526 | + * a reduction operation with `int *len` and `MPI_Count *len`. At which |
| 527 | + * point we can avoid this loop. |
| 528 | + */ |
| 529 | + if( OPAL_UNLIKELY(full_count > INT_MAX) ) { |
| 530 | + size_t done_count = 0, shift; |
| 531 | + int iter_count; |
| 532 | + ptrdiff_t ext, lb; |
| 533 | + |
| 534 | + ompi_datatype_get_extent(dtype, &lb, &ext); |
| 535 | + |
| 536 | + while(done_count < full_count) { |
| 537 | + if(done_count + INT_MAX > full_count) { |
| 538 | + iter_count = full_count - done_count; |
| 539 | + } else { |
| 540 | + iter_count = INT_MAX; |
| 541 | + } |
| 542 | + shift = done_count * ext; |
| 543 | + // Recurse one level in iterations of 'int' |
| 544 | + ompi_op_reduce(op, (char*)source + shift, (char*)target + shift, iter_count, dtype); |
| 545 | + done_count += iter_count; |
| 546 | + } |
| 547 | + return; |
| 548 | + } |
517 | 549 |
|
518 | 550 | /*
|
519 | 551 | * Call the reduction function. Two dimensions: a) if both the op
|
|
0 commit comments