You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
450 B
25 lines
450 B
5 years ago
|
#include <stdio.h>
|
||
|
#include "mpi.h"
|
||
|
|
||
|
main(int argc, char** argv)
|
||
|
{
|
||
|
|
||
|
int my_rank;
|
||
|
int size;
|
||
|
int namelen;
|
||
|
char proc_name[MPI_MAX_PROCESSOR_NAME];
|
||
|
|
||
|
MPI_Init(&argc, &argv);
|
||
|
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
|
||
|
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
||
|
MPI_Get_processor_name(proc_name, &namelen);
|
||
|
|
||
|
if (my_rank == 2)
|
||
|
printf("Hello – I am process 2\n");
|
||
|
else
|
||
|
printf("Hello from process %d of %d on %s\n", my_rank, size, proc_name);
|
||
|
|
||
|
MPI_Finalize();
|
||
|
}
|
||
|
|