Blame test/basic/sr1.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
Packit 0848f5
/*
Packit 0848f5
 * A simple code that can be used to test the basic message passing or
Packit 0848f5
 * debug parts of the code.  This is less a test than a way to exercise
Packit 0848f5
 * the primary code path for short message send-receives
Packit 0848f5
 */
Packit 0848f5
#include <stdio.h>
Packit 0848f5
#include "mpi.h"
Packit 0848f5
Packit 0848f5
int main( int argc, char *argv[] )
Packit 0848f5
{
Packit 0848f5
    int myrank, size, src=0, dest=1, msgsize=1;
Packit 0848f5
    int buf[20];
Packit 0848f5
Packit 0848f5
    MPI_Init( &argc, &argv );
Packit 0848f5
    MPI_Comm_size( MPI_COMM_WORLD, &size );
Packit 0848f5
    MPI_Comm_rank( MPI_COMM_WORLD, &myrank );
Packit 0848f5
Packit 0848f5
    if (myrank == src) {
Packit 0848f5
        buf[0] = 0xabcd0123;
Packit 0848f5
	MPI_Send( buf, msgsize, MPI_INT, dest, 0, MPI_COMM_WORLD );
Packit 0848f5
    }
Packit 0848f5
    else if (myrank == dest) {
Packit 0848f5
        buf[0] = 0xffffffff;
Packit 0848f5
	MPI_Recv( buf, msgsize, MPI_INT, src, 0, MPI_COMM_WORLD, 
Packit 0848f5
		  MPI_STATUS_IGNORE );
Packit 0848f5
	if (buf[0] != 0xabcd0123) {
Packit 0848f5
	    printf( "Expected %x but got %x\n", 0xabcd0123, buf[0] );
Packit 0848f5
	    fflush(stdout);
Packit 0848f5
	}
Packit 0848f5
    }
Packit 0848f5
Packit 0848f5
    MPI_Finalize();
Packit 0848f5
Packit 0848f5
    return 0;
Packit 0848f5
}