-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq1.c
31 lines (23 loc) · 942 Bytes
/
q1.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
// A group is an ordered set of process identifiers (rank)
// A communicator encapsulates all communication among a set of processes i.e the group.
// https://www.clustermonkey.net/MPI/mpi-groups-and-communicators.html
#include <stdio.h>
#include <mpi.h>
int main (int argc, char *argv[]) {
//Declare int variables for Process number, number of processes and length of processor name.
int rank, size, namelen;
//Declare char variable for name of processor
char name[100];
//Intialize MPI
MPI_Init(&argc, &argv);
//Get number of processes
MPI_Comm_size(MPI_COMM_WORLD, &size);
//Get processes number
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
//Get processesor name
MPI_Get_processor_name(name, &namelen);
printf ("Hello World. Rank %d out of %d running on %s!\n", rank, size, name);
//Terminate MPI environment
MPI_Finalize();
return 0;
}