-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelloworldmpi.c
More file actions
44 lines (34 loc) · 1.19 KB
/
Copy pathhelloworldmpi.c
File metadata and controls
44 lines (34 loc) · 1.19 KB
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
36
37
38
39
40
41
42
43
44
// #include <stdio.h> /* printf and BUFSIZ defined there */
// #include <stdlib.h> /* exit defined there */
// #include <mpi.h> /* all MPI-2 functions defined there */
// int main(argc, argv)
// int argc;
// char *argv[];
// {
// int rank, size, length;
// char name[BUFSIZ];
// MPI_Init(&argc, &argv);
// MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// MPI_Comm_size(MPI_COMM_WORLD, &size);
// MPI_Get_processor_name(name, &length);
// printf("%s: hello world from process %d of %d\n", name, rank, size);
// MPI_Finalize();
// exit(0);
// }
#include <stdio.h> /* printf and BUFSIZ defined there */
#include <stdlib.h> /* exit defined there */
#include <mpi.h> /* all MPI-2 functions defined there */
int main(argc, argv)
int argc;
char *argv[];
{
int rank, size, length;
char name[BUFSIZ];
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Get_processor_name(name, &length);
printf("%s: hello world from process %d of %d\n", name, rank, size);
MPI_Finalize();
exit(0);
}