Skip to content

Commit 82746f2

Browse files
authored
Merge pull request #9719 from bosilca/fix/9717
Rework the MPI_Op support.
2 parents 3deb0de + 786bd35 commit 82746f2

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

ompi/mca/op/base/op_base_functions.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
int i; \
4646
type *a = (type *) in; \
4747
type *b = (type *) out; \
48-
for (i = 0; i < *count; ++i) { \
48+
for (i = *count; i > 0; i--) { \
4949
*(b++) op *(a++); \
5050
} \
5151
}
@@ -65,7 +65,7 @@
6565
int i; \
6666
type *a = (type *) in; \
6767
type *b = (type *) out; \
68-
for (i = 0; i < *count; ++i) { \
68+
for (i = *count; i > 0; i--) { \
6969
*(b) = current_func(*(b), *(a)); \
7070
++b; \
7171
++a; \
@@ -93,7 +93,7 @@
9393
int i; \
9494
ompi_op_predefined_##type_name##_t *a = (ompi_op_predefined_##type_name##_t*) in; \
9595
ompi_op_predefined_##type_name##_t *b = (ompi_op_predefined_##type_name##_t*) out; \
96-
for (i = 0; i < *count; ++i, ++a, ++b) { \
96+
for (i = *count; i > 0; i--, ++a, ++b) { \
9797
if (a->v op b->v) { \
9898
b->v = a->v; \
9999
b->k = a->k; \
@@ -117,7 +117,7 @@
117117
int i; \
118118
type (*a)[2] = (type (*)[2]) in; \
119119
type (*b)[2] = (type (*)[2]) out; \
120-
for (i = 0; i < *count; ++i, ++a, ++b) { \
120+
for (i = *count; i > 0; i--, ++a, ++b) { \
121121
(*b)[0] += (*a)[0]; \
122122
(*b)[1] += (*a)[1]; \
123123
} \
@@ -138,7 +138,7 @@
138138
type (*a)[2] = (type (*)[2]) in; \
139139
type (*b)[2] = (type (*)[2]) out; \
140140
type c[2]; \
141-
for (i = 0; i < *count; ++i, ++a, ++b) { \
141+
for (i = *count; i > 0; i--, ++a, ++b) { \
142142
c[0] = (*a)[0] * (*b)[0] - (*a)[1] * (*b)[1]; \
143143
c[1] = (*a)[0] * (*b)[1] + (*a)[1] * (*b)[0]; \
144144
(*b)[0] = c[0]; \
@@ -693,7 +693,7 @@ LOC_FUNC(minloc, long_double_int, <)
693693
type *a1 = (type *) in1; \
694694
type *a2 = (type *) in2; \
695695
type *b = (type *) out; \
696-
for (i = 0; i < *count; ++i) { \
696+
for (i = *count; i > 0; i--) { \
697697
*(b++) = *(a1++) op *(a2++); \
698698
} \
699699
}
@@ -715,7 +715,7 @@ LOC_FUNC(minloc, long_double_int, <)
715715
type *a1 = (type *) in1; \
716716
type *a2 = (type *) in2; \
717717
type *b = (type *) out; \
718-
for (i = 0; i < *count; ++i) { \
718+
for (i = *count; i > 0; i--) { \
719719
*(b) = current_func(*(a1), *(a2)); \
720720
++b; \
721721
++a1; \
@@ -748,7 +748,7 @@ LOC_FUNC(minloc, long_double_int, <)
748748
ompi_op_predefined_##type_name##_t *a1 = (ompi_op_predefined_##type_name##_t*) in1; \
749749
ompi_op_predefined_##type_name##_t *a2 = (ompi_op_predefined_##type_name##_t*) in2; \
750750
ompi_op_predefined_##type_name##_t *b = (ompi_op_predefined_##type_name##_t*) out; \
751-
for (i = 0; i < *count; ++i, ++a1, ++a2, ++b ) { \
751+
for (i = *count; i > 0; i--, ++a1, ++a2, ++b ) { \
752752
if (a1->v op a2->v) { \
753753
b->v = a1->v; \
754754
b->k = a1->k; \
@@ -778,7 +778,7 @@ LOC_FUNC(minloc, long_double_int, <)
778778
type (*a1)[2] = (type (*)[2]) in1; \
779779
type (*a2)[2] = (type (*)[2]) in2; \
780780
type (*b)[2] = (type (*)[2]) out; \
781-
for (i = 0; i < *count; ++i, ++a1, ++a2, ++b) { \
781+
for (i = *count; i > 0; i--, ++a1, ++a2, ++b) { \
782782
(*b)[0] = (*a1)[0] + (*a2)[0]; \
783783
(*b)[1] = (*a1)[1] + (*a2)[1]; \
784784
} \
@@ -800,7 +800,7 @@ LOC_FUNC(minloc, long_double_int, <)
800800
type (*a1)[2] = (type (*)[2]) in1; \
801801
type (*a2)[2] = (type (*)[2]) in2; \
802802
type (*b)[2] = (type (*)[2]) out; \
803-
for (i = 0; i < *count; ++i, ++a1, ++a2, ++b) { \
803+
for (i = *count; i > 0; i--, ++a1, ++a2, ++b) { \
804804
(*b)[0] = (*a1)[0] * (*a2)[0] - (*a1)[1] * (*a2)[1]; \
805805
(*b)[1] = (*a1)[0] * (*a2)[1] + (*a1)[1] * (*a2)[0]; \
806806
} \

test/datatype/reduce_local.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ do { \
161161
for(int _r = repeats; _r > 0; _r--) { \
162162
memcpy(_p2, _p3, sizeof(TYPE) * (COUNT)); \
163163
tstart = MPI_Wtime(); \
164-
MPI_Reduce_local(_p1+_k, _p2+_k, (COUNT), (MPITYPE), (MPIOP)); \
164+
MPI_Reduce_local(_p1+_k, _p2+_k, (COUNT)-_k, (MPITYPE), (MPIOP)); \
165165
tend = MPI_Wtime(); \
166166
duration[_k] += (tend - tstart); \
167167
if( check ) { \
@@ -281,6 +281,7 @@ int main(int argc, char **argv)
281281
" -1 <number> : (mis)alignment in elements for the first op\n"
282282
" -2 <number> : (mis)alignment in elements for the result\n"
283283
" -v: increase the verbosity level\n"
284+
" -f: turn off correctness checks\n"
284285
" -h: this help message\n",
285286
argv[0]);
286287
exit(0);

0 commit comments

Comments
 (0)