Skip to content

Commit 37bf832

Browse files
committed
group: make MPIR_Lpid int64_t
The unsigned type uint64_t is dangerous as we perform pmap stride math. Signed integer should always work and we can use assertions to check its range.
1 parent fed0a7f commit 37bf832

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/include/mpir_group.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* in principle, but 64-bit is simpler since we can trivially combine
4848
* (world_idx, world_rank).
4949
*/
50-
typedef uint64_t MPIR_Lpid;
50+
typedef int64_t MPIR_Lpid;
5151

5252
struct MPIR_Pmap {
5353
int size; /* same as group->size, duplicate here so Pmap is logically complete */

src/mpi/group/grouputil.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ int MPIR_Group_create_stride(int size, int rank, MPIR_Session * session_ptr,
129129
* for others it is implied */
130130
*new_group_ptr = MPIR_Group_empty;
131131
} else {
132-
MPIR_Assert(stride > 0 && blocksize > 0);
132+
/* NOTE: stride may be negative */
133+
MPIR_Assert(offset >= 0);
134+
MPIR_Assert(stride != 0);
135+
MPIR_Assert(blocksize > 0);
133136

134137
MPIR_Group *newgrp;
135138
mpi_errno = MPIR_Group_create(size, &newgrp);

0 commit comments

Comments
 (0)