HP-MPI User's Guide (11th Edition)
Example applications
ping_pong_ring.c (HP-UX and Linux)
Appendix A 231
#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;
int rank, size;
int root;
int partner;
MPI_Status status;
char *buf, *obuf;
char myhost[MPI_MAX_PROCESSOR_NAME];
int len;
char str[1024];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Get_processor_name(myhost, &len);