Blame test/mpi/pt2pt/isendself.c

Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *  (C) 2001 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#include "mpi.h"
Packit 0848f5
#include "mpitest.h"
Packit 0848f5
Packit 0848f5
int main(int argc, char *argv[])
Packit 0848f5
{
Packit 0848f5
    int a[10], b[10], i;
Packit 0848f5
    MPI_Status status;
Packit 0848f5
    MPI_Request request;
Packit 0848f5
    int rank, count;
Packit 0848f5
    int errs = 0;
Packit 0848f5
Packit 0848f5
Packit 0848f5
    MTest_Init(0, 0);
Packit 0848f5
Packit 0848f5
    MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
Packit 0848f5
Packit 0848f5
    for (i = 0; i < 10; i++)
Packit 0848f5
        a[i] = i + 1;
Packit 0848f5
Packit 0848f5
    status.MPI_ERROR = 0;
Packit 0848f5
    MPI_Isend(a, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request);
Packit 0848f5
    MPI_Recv(b, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
Packit 0848f5
    MPI_Get_count(&status, MPI_INT, &count);
Packit 0848f5
    if (status.MPI_SOURCE != rank || status.MPI_TAG != 0 || status.MPI_ERROR != 0 || count != 0) {
Packit 0848f5
        errs++;
Packit 0848f5
        printf("1 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG,
Packit 0848f5
               status.MPI_ERROR, count);
Packit 0848f5
    }
Packit 0848f5
    /* printf("b[0] = %d\n", b[0]); */
Packit 0848f5
    MPI_Wait(&request, &status);
Packit 0848f5
Packit 0848f5
    MPI_Isend(NULL, 0, MPI_INT, rank, 0, MPI_COMM_WORLD, &request);
Packit 0848f5
    MPI_Recv(NULL, 0, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
Packit 0848f5
    MPI_Get_count(&status, MPI_INT, &count);
Packit 0848f5
    if (status.MPI_SOURCE != rank || status.MPI_TAG != 0 || status.MPI_ERROR != 0 || count != 0) {
Packit 0848f5
        errs++;
Packit 0848f5
        printf("2 status = %d %d %d %d\n", status.MPI_SOURCE, status.MPI_TAG,
Packit 0848f5
               status.MPI_ERROR, count);
Packit 0848f5
    }
Packit 0848f5
    MPI_Wait(&request, &status);
Packit 0848f5
Packit 0848f5
    MTest_Finalize(errs);
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
    return 0;
Packit 0848f5
}