1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include "mpitest.h"
/* tests send/recv of a message > 2GB. count=270M, type=long long
run with 3 processes to exercise both shared memory and TCP in Nemesis tests*/
int main(int argc, char *argv[])
{
int i, size, rank;
int cnt = 270000000;
int stat_cnt = 0;
MPI_Status status;
long long *cols;
int errs = 0;
MTest_Init(&argc, &argv);
/* need large memory */
if (sizeof(void *) < 8) {
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (size != 3) {
fprintf(stderr, "[%d] usage: mpiexec -n 3 %s\n", rank, argv[0]);
MPI_Abort(MPI_COMM_WORLD, 1);
}
cols = malloc(cnt * sizeof(long long));
if (cols == NULL) {
printf("malloc of >2GB array failed\n");
errs++;
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
if (rank == 0) {
for (i = 0; i < cnt; i++)
cols[i] = i;
/* printf("[%d] sending...\n",rank); */
MPI_Send(cols, cnt, MPI_LONG_LONG_INT, 1, 0, MPI_COMM_WORLD);
MPI_Send(cols, cnt, MPI_LONG_LONG_INT, 2, 0, MPI_COMM_WORLD);
} else {
/* printf("[%d] receiving...\n",rank); */
for (i = 0; i < cnt; i++)
cols[i] = -1;
MPI_Recv(cols, cnt, MPI_LONG_LONG_INT, 0, 0, MPI_COMM_WORLD, &status);
MPI_Get_count(&status, MPI_LONG_LONG_INT, &stat_cnt);
if (cnt != stat_cnt) {
fprintf(stderr, "Output of MPI_Get_count (%d) does not match expected count (%d).\n",
stat_cnt, cnt);
errs++;
}
for (i = 0; i < cnt; i++) {
if (cols[i] != i) {
/*printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i); */
errs++;
}
}
}
free(cols);
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
|