/
helloC.c
35 lines (26 loc) · 1.08 KB
/
helloC.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/** -*- fill-column:110 -*-
@file helloC.c
@author Mitch Richling <https://www.mitchr.me/>
@Copyright Copyright 1999 by Mitch Richling. All rights reserved.
@brief First MPI program@EOL
@Keywords LAM MPICH MPI
@Std C89 MPI1
This is a "hello world" program for MPI using the C bindings. Functions illustrated:
MPI_Init
MPI_Comm_rank
MPI_Comm_size
MPI_Finalize
Not all platforms allow console I/O on all MPI processes, so this program can fail on some
platforms.
*/
#include <stdio.h> /* I/O lib C89 */
#include <mpi.h> /* MPI Std MPI */
int main(int argc, char *argv[]) {
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("I am %d of %d\n", rank, size);
MPI_Finalize();
return 0;
} /* end func main */