1 | /* hello.c
|
---|
2 | *
|
---|
3 | * Simple "Hello World" program in MPI.
|
---|
4 | *
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "mpi.h"
|
---|
8 | #include <stdio.h>
|
---|
9 | int main(int argc, char *argv[]) {
|
---|
10 |
|
---|
11 | int numprocs; /* Number of processors */
|
---|
12 | int procnum; /* Processor number */
|
---|
13 |
|
---|
14 | /* Initialize MPI */
|
---|
15 | MPI_Init(&argc, &argv);
|
---|
16 |
|
---|
17 | /* Find this processor number */
|
---|
18 | MPI_Comm_rank(MPI_COMM_WORLD, &procnum);
|
---|
19 |
|
---|
20 | /* Find the number of processors */
|
---|
21 | MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
|
---|
22 | printf ("Hello world! from processor %d out of %d\n", procnum, numprocs);
|
---|
23 |
|
---|
24 | /* Shut down MPI */
|
---|
25 | MPI_Finalize();
|
---|
26 | return 0;
|
---|
27 | }
|
---|