Commit b2ec3e57 authored by Antonio J. Pena's avatar Antonio J. Pena Committed by Xin Zhao
Browse files

Fix win_dynamic_acc test for any number of ranks



Fixes #1971
Signed-off-by: default avatarXin Zhao <xinzhao3@illinois.edu>
parent 84000fcc
......@@ -11,7 +11,7 @@
#include <mpi.h>
#include "mpitest.h"
#define ITER 100
#define ITER_PER_RANK 25
const int verbose = 0;
......@@ -19,6 +19,7 @@ int main(int argc, char **argv) {
int i, j, rank, nproc;
int errors = 0, all_errors = 0;
int val = 0, one = 1;
int iter;
MPI_Aint *val_ptrs;
MPI_Win dyn_win;
......@@ -27,6 +28,8 @@ int main(int argc, char **argv) {
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
iter = ITER_PER_RANK * nproc;
val_ptrs = malloc(nproc * sizeof(MPI_Aint));
MPI_Get_address(&val, &val_ptrs[rank]);
......@@ -36,7 +39,7 @@ int main(int argc, char **argv) {
MPI_Win_create_dynamic(MPI_INFO_NULL, MPI_COMM_WORLD, &dyn_win);
MPI_Win_attach(dyn_win, &val, sizeof(int));
for (i = 0; i < ITER; i++) {
for (i = 0; i < iter; i++) {
MPI_Win_fence(MPI_MODE_NOPRECEDE, dyn_win);
MPI_Accumulate(&one, 1, MPI_INT, i%nproc, val_ptrs[i%nproc], 1, MPI_INT, MPI_SUM, dyn_win);
MPI_Win_fence(MPI_MODE_NOSUCCEED, dyn_win);
......@@ -45,9 +48,9 @@ int main(int argc, char **argv) {
MPI_Barrier(MPI_COMM_WORLD);
/* Read and verify my data */
if ( val != ITER ) {
if ( val != iter ) {
errors++;
printf("%d -- Got %d, expected %d\n", rank, val, ITER);
printf("%d -- Got %d, expected %d\n", rank, val, iter);
}
MPI_Win_detach(dyn_win, &val);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment