Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ardhi Putra Pratama
teaching
Commits
153308bd
Commit
153308bd
authored
Jan 26, 2018
by
Ardhi Putra Pratama
Browse files
add mpi hello world
parent
ac6a7f0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
hpc/hello-world/mpi_hello.c
0 → 100644
View file @
153308bd
#include
<mpi.h>
#include
<stdio.h>
int
main
(
int
argc
,
char
**
argv
)
{
// Initialize the MPI environment
MPI_Init
(
NULL
,
NULL
);
// Get the number of processes
int
world_size
;
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
world_size
);
// Get the rank of the process
int
world_rank
;
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
world_rank
);
// Get the name of the processor
char
processor_name
[
MPI_MAX_PROCESSOR_NAME
];
int
name_len
;
MPI_Get_processor_name
(
processor_name
,
&
name_len
);
// Print off a hello world message
printf
(
"Hello world from processor %s, rank %d"
" out of %d processors
\n
"
,
processor_name
,
world_rank
,
world_size
);
// Finalize the MPI environment.
MPI_Finalize
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment