Skip to content

Commit 1d8e717

Browse files
authored
Merge pull request #5005 from xinzhao3/topic/shmem-alltoall-v3.1.x
ompi/oshmem: fix bug in shmem_alltoall in mca/scoll/basic.
2 parents 48325ce + 3387133 commit 1d8e717

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

oshmem/mca/scoll/basic/scoll_basic_alltoall.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,13 @@ get_stride_elem(const void *base, ptrdiff_t sst, size_t nelems, size_t elem_size
105105
}
106106

107107
static inline int
108-
get_dst_pe(struct oshmem_group_t *group, int src_blk_idx, int dst_blk_idx)
108+
get_dst_pe(struct oshmem_group_t *group, int src_blk_idx, int dst_blk_idx, int *dst_pe_idx)
109109
{
110-
int dst_grp_pe;
111-
112110
/* index permutation for better distribution of traffic */
113-
dst_grp_pe = (dst_blk_idx + src_blk_idx) % group->proc_count;
111+
(*dst_pe_idx) = (dst_blk_idx + src_blk_idx) % group->proc_count;
114112

115113
/* convert to the global pe */
116-
return oshmem_proc_pe(group->proc_array[dst_grp_pe]);
114+
return oshmem_proc_pe(group->proc_array[*dst_pe_idx]);
117115
}
118116

119117
static int a2as_alg_simple(struct oshmem_group_t *group,
@@ -127,6 +125,7 @@ static int a2as_alg_simple(struct oshmem_group_t *group,
127125
int dst_pe;
128126
int src_blk_idx;
129127
int dst_blk_idx;
128+
int dst_pe_idx;
130129
size_t elem_idx;
131130

132131
SCOLL_VERBOSE(14,
@@ -137,14 +136,14 @@ static int a2as_alg_simple(struct oshmem_group_t *group,
137136

138137
for (src_blk_idx = 0; src_blk_idx < group->proc_count; src_blk_idx++) {
139138

140-
dst_pe = get_dst_pe(group, src_blk_idx, dst_blk_idx);
139+
dst_pe = get_dst_pe(group, src_blk_idx, dst_blk_idx, &dst_pe_idx);
141140
for (elem_idx = 0; elem_idx < nelems; elem_idx++) {
142141
rc = MCA_SPML_CALL(put(
143142
get_stride_elem(target, tst, nelems, element_size,
144143
dst_blk_idx, elem_idx),
145144
element_size,
146145
get_stride_elem(source, sst, nelems, element_size,
147-
src_blk_idx, elem_idx),
146+
dst_pe_idx, elem_idx),
148147
dst_pe));
149148
if (OSHMEM_SUCCESS != rc) {
150149
return rc;
@@ -164,6 +163,7 @@ static int a2a_alg_simple(struct oshmem_group_t *group,
164163
int dst_pe;
165164
int src_blk_idx;
166165
int dst_blk_idx;
166+
int dst_pe_idx;
167167
void *dst_blk;
168168

169169
SCOLL_VERBOSE(14,
@@ -177,11 +177,11 @@ static int a2a_alg_simple(struct oshmem_group_t *group,
177177

178178
for (src_blk_idx = 0; src_blk_idx < group->proc_count; src_blk_idx++) {
179179

180-
dst_pe = get_dst_pe(group, src_blk_idx, dst_blk_idx);
180+
dst_pe = get_dst_pe(group, src_blk_idx, dst_blk_idx, &dst_pe_idx);
181181
rc = MCA_SPML_CALL(put(dst_blk,
182182
nelems * element_size,
183183
get_stride_elem(source, 1, nelems,
184-
element_size, src_blk_idx, 0),
184+
element_size, dst_pe_idx, 0),
185185
dst_pe));
186186
if (OSHMEM_SUCCESS != rc) {
187187
return rc;

0 commit comments

Comments
 (0)