|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2013 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* This test checks for proper error checking in MPI_Reduce_local, especially
|
|
Packit Service |
c5cf8c |
* handling of MPI_IN_PLACE and buffer aliasing. */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include <assert.h>
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* quick cop-out for now */
|
|
Packit Service |
c5cf8c |
#define check(c_) assert(c_)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int err, errs = 0, len, i, errclass;
|
|
Packit Service |
c5cf8c |
int rank = -1, size = -1;
|
|
Packit Service |
c5cf8c |
int *buf;
|
|
Packit Service |
c5cf8c |
int *recvbuf;
|
|
Packit Service |
c5cf8c |
char msg[MPI_MAX_ERROR_STRING];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
buf = malloc(size * sizeof(int));
|
|
Packit Service |
c5cf8c |
recvbuf = malloc(size * sizeof(int));
|
|
Packit Service |
c5cf8c |
for (i = 0; i < size; ++i) {
|
|
Packit Service |
c5cf8c |
buf[i] = i;
|
|
Packit Service |
c5cf8c |
recvbuf[i] = -1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* check valid reduce_local does not fail */
|
|
Packit Service |
c5cf8c |
err = MPI_Reduce_local(buf, recvbuf, size, MPI_INT, MPI_SUM);
|
|
Packit Service |
c5cf8c |
check(err == MPI_SUCCESS);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ERR: check inbuf==MPI_IN_PLACE */
|
|
Packit Service |
c5cf8c |
err = MPI_Reduce_local(MPI_IN_PLACE, recvbuf, size, MPI_INT, MPI_SUM);
|
|
Packit Service |
c5cf8c |
check(err != MPI_SUCCESS);
|
|
Packit Service |
c5cf8c |
MPI_Error_class(err, &errclass);
|
|
Packit Service |
c5cf8c |
check(errclass == MPI_ERR_BUFFER);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ERR: check inoutbuf==MPI_IN_PLACE */
|
|
Packit Service |
c5cf8c |
err = MPI_Reduce_local(buf, MPI_IN_PLACE, size, MPI_INT, MPI_SUM);
|
|
Packit Service |
c5cf8c |
check(err != MPI_SUCCESS);
|
|
Packit Service |
c5cf8c |
MPI_Error_class(err, &errclass);
|
|
Packit Service |
c5cf8c |
check(errclass == MPI_ERR_BUFFER);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ERR: check buffer aliasing is caught */
|
|
Packit Service |
c5cf8c |
err = MPI_Reduce_local(recvbuf, recvbuf, size, MPI_INT, MPI_SUM);
|
|
Packit Service |
c5cf8c |
check(err != MPI_SUCCESS);
|
|
Packit Service |
c5cf8c |
MPI_Error_class(err, &errclass);
|
|
Packit Service |
c5cf8c |
check(errclass == MPI_ERR_BUFFER);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
free(recvbuf);
|
|
Packit Service |
c5cf8c |
free(buf);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|