root@dcs-977baf93-0:/workspace/pthread# mpic++ t07.cpp -o 2.out
root@dcs-977baf93-0:/workspace/pthread# mpirun -n 4 ./2.out
Hello World from process 1 of 4
Hello World from process 0 of 4
Hello World from process 2 of 4
root@dcs-977baf93-0:/workspace/pthread# mpirun -n 6 ./2.out
Hello World from process 3 of 6
===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= PID 235 RUNNING AT dcs-977baf93-0
= EXIT CODE: 9
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Killed (signal 9)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
root@dcs-977baf93-0:/workspace/pthread# mpirun -n 2 ./2.out
Hello World from process 1 of 2
root@dcs-977baf93-0:/workspace/pthread# mpirun -n 1 ./2.out
Hello World from process 0 of 1
root@dcs-977baf93-0:/workspace/pthread# mpic++ t07.cpp -o 2.out
root@dcs-977baf93-0:/workspace/pthread# mpirun -n 1 ./2.out
Hello World from process 0 of 1
root@dcs-977baf93-0:/workspace/pthread# mpirun -n 3 ./2.out
Hello World from process 0 of 3
Hello World from process 1 of 3
Hello World from process 2 of 3
root@dcs-977baf93-0:/workspace/pthread# mpirun -n 4 ./2.out
Hello World from process 2 of 4
Hello World from process 3 of 4
Hello World from process 1 of 4
Hello World from process 0 of 4
root@dcs-977baf93-0:/workspace/pthread# mpirun -n 2 ./2.out
Hello World from process 1 of 2
Hello World from process 0 of 2
root@dcs-977baf93-0:/workspace/pthread#
cpp
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
int process_Rank, size_Of_Cluster;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size_Of_Cluster);
MPI_Comm_rank(MPI_COMM_WORLD, &process_Rank);
printf("Hello World from process %d of %d\n", process_Rank,
size_Of_Cluster);
MPI_Finalize();
return 0;
}