HP-MPI User's Guide (11th Edition)

Example applications
ping_pong_ring.c (Windows)
Appendix A 237
In each case above, the first mpirun uses 0 bytes per message and is
checking latency. The second mpirun uses 1000000 bytes per message
and is checking bandwidth.
#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32
#include <unistd.h>
#endif
#include <string.h>
#include <math.h>
#include <mpi.h>
#define NLOOPS 1000
#define ALIGN 4096
#define SEND(t) MPI_Send(buf, nbytes, MPI_CHAR, partner, (t), \
MPI_COMM_WORLD)
#define RECV(t) MPI_Recv(buf, nbytes, MPI_CHAR, partner, (t), \
MPI_COMM_WORLD, &status)
#ifdef CHECK
# define SETBUF()for (j=0; j<nbytes; j++) { \
buf[j] = (char) (j + i); \
}
# define CLRBUF()memset(buf, 0, nbytes)
# define CHKBUF()for (j = 0; j < nbytes; j++) { \
if (buf[j] != (char) (j + i)) { \
printf("error: buf[%d] = %d, " \
"not %d\n", \
j, buf[j], j + i); \
break; \
} \
}
#else
# define SETBUF()
# define CLRBUF()
# define CHKBUF()
#endif
int
main(argc, argv)
int argc;
char *argv[];
{
int i;
#ifdef CHECK
int j;
#endif
double start, stop;
intn bytes = 0;