|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* A simple code that can be used to test the basic message passing or
|
|
Packit Service |
c5cf8c |
* debug parts of the code. This is less a test than a way to exercise
|
|
Packit Service |
c5cf8c |
* the primary code path for short message send-receives
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int myrank, size, src = 0, dest = 1, msgsize = 1;
|
|
Packit Service |
c5cf8c |
int buf[20];
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (myrank == src) {
|
|
Packit Service |
c5cf8c |
buf[0] = 0xabcd0123;
|
|
Packit Service |
c5cf8c |
MPI_Send(buf, msgsize, MPI_INT, dest, 0, MPI_COMM_WORLD);
|
|
Packit Service |
c5cf8c |
} else if (myrank == dest) {
|
|
Packit Service |
c5cf8c |
buf[0] = 0xffffffff;
|
|
Packit Service |
c5cf8c |
MPI_Recv(buf, msgsize, MPI_INT, src, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|
Packit Service |
c5cf8c |
if (buf[0] != 0xabcd0123) {
|
|
Packit Service |
c5cf8c |
printf("Expected %x but got %x\n", 0xabcd0123, buf[0]);
|
|
Packit Service |
c5cf8c |
fflush(stdout);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Finalize();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|