|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2003 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Gather data from a vector to contiguous */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPI_Datatype vec;
|
|
Packit Service |
c5cf8c |
MPI_Comm comm;
|
|
Packit Service |
c5cf8c |
double *vecin, *vecout;
|
|
Packit Service |
c5cf8c |
int minsize = 2, count;
|
|
Packit Service |
c5cf8c |
int root, i, n, stride, errs = 0;
|
|
Packit Service |
c5cf8c |
int rank, size;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
while (MTestGetIntracommGeneral(&comm, minsize, 1)) {
|
|
Packit Service |
c5cf8c |
if (comm == MPI_COMM_NULL)
|
|
Packit Service |
c5cf8c |
continue;
|
|
Packit Service |
c5cf8c |
/* Determine the sender and receiver */
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(comm, &rank;;
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(comm, &size);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (root = 0; root < size; root++) {
|
|
Packit Service |
c5cf8c |
for (count = 1; count < 65000; count = count * 2) {
|
|
Packit Service |
c5cf8c |
n = 12;
|
|
Packit Service |
c5cf8c |
stride = 10;
|
|
Packit Service |
c5cf8c |
vecin = (double *) malloc(n * stride * size * sizeof(double));
|
|
Packit Service |
c5cf8c |
vecout = (double *) malloc(size * n * sizeof(double));
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Type_vector(n, 1, stride, MPI_DOUBLE, &vec;;
|
|
Packit Service |
c5cf8c |
MPI_Type_commit(&vec;;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < n * stride; i++)
|
|
Packit Service |
c5cf8c |
vecin[i] = -2;
|
|
Packit Service |
c5cf8c |
for (i = 0; i < n; i++)
|
|
Packit Service |
c5cf8c |
vecin[i * stride] = rank * n + i;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Gather(vecin, 1, vec, vecout, n, MPI_DOUBLE, root, comm);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (rank == root) {
|
|
Packit Service |
c5cf8c |
for (i = 0; i < n * size; i++) {
|
|
Packit Service |
c5cf8c |
if (vecout[i] != i) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
if (errs < 10) {
|
|
Packit Service |
c5cf8c |
fprintf(stderr, "vecout[%d]=%d\n", i, (int) vecout[i]);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Type_free(&vec;;
|
|
Packit Service |
c5cf8c |
free(vecin);
|
|
Packit Service |
c5cf8c |
free(vecout);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MTestFreeComm(&comm);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* do a zero length gather */
|
|
Packit Service |
c5cf8c |
MPI_Gather(NULL, 0, MPI_BYTE, NULL, 0, MPI_BYTE, 0, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|