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 76 77 78
|
/*
* 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 non-contig 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 elems = 270000000;
MPI_Status status;
MPI_Datatype dtype;
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(elems * sizeof(long long));
if (cols == NULL) {
printf("malloc of >2GB array failed\n");
errs++;
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
MPI_Type_vector(elems / 2, 1, 2, MPI_LONG_LONG_INT, &dtype);
MPI_Type_commit(&dtype);
if (rank == 0) {
for (i = 0; i < elems; i++)
cols[i] = i;
/* printf("[%d] sending...\n",rank); */
MPI_Send(cols, 1, dtype, 1, 0, MPI_COMM_WORLD);
MPI_Send(cols, 1, dtype, 2, 0, MPI_COMM_WORLD);
} else {
/* printf("[%d] receiving...\n",rank); */
for (i = 0; i < elems; i++)
cols[i] = -1;
MPI_Recv(cols, 1, dtype, 0, 0, MPI_COMM_WORLD, &status);
/* MPI_Get_count(&status,MPI_LONG_LONG_INT,&cnt);
* Get_count still fails because count is not 64 bit */
for (i = 0; i < elems; i++) {
if (i % 2)
continue;
if (cols[i] != i) {
printf("Rank %d, cols[i]=%lld, should be %d\n", rank, cols[i], i);
errs++;
}
}
}
MPI_Type_free(&dtype);
free(cols);
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
|