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

Example applications
ping_pong_ring.c (HP-UX and Linux)
Appendix A 233
if (nbytes > 0) {
sprintf(&str[strlen(str)],
"%d bytes: %.2f MB/sec\n", nbytes,
nbytes / (1024. * 1024.) /
((stop - start) / NLOOPS / 2));
}
fflush(stdout);
} else if (rank == (root+1)%size) {
/*
* warm-up loop
*/
partner = root;
for (i = 0; i < 5; i++) {
RECV(1);
SEND(1);
}
for (i = 0; i < NLOOPS; i++) {
CLRBUF();
RECV(1000 + i);
CHKBUF();
SETBUF();
SEND(2000 + i);
}
}
MPI_Bcast(str, 1024, MPI_CHAR, root, MPI_COMM_WORLD);
if (rank == 0) {
printf("%s", str);
}
}
free(obuf);
MPI_Finalize();
exit(0);
}
ping_pong_ring.c output
Example output might look like:
> Host 0 -- ip 192.168.9.10 -- ranks 0
> Host 1 -- ip 192.168.9.11 -- ranks 1
> Host 2 -- ip 192.168.9.12 -- ranks 2
> Host 3 -- ip 192.168.9.13 -- ranks 3
>
> host | 0 1 2 3
> ======|=====================
> 0 : SHM VAPI VAPI VAPI
> 1 : VAPI SHM VAPI VAPI
> 2 : VAPI VAPI SHM VAPI
> 3 : VAPI VAPI VAPI SHM
>
> [0:hostA] ping-pong 0 bytes ...
> 0 bytes: 4.57 usec/msg