#include <mpi.h>
#include <stdio.h>
int main(int argc, char **argv) {
int rank;
// Initialize MPI
MPI_Init(&argc, &argv);
// Get my rank
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// Print the message only once (only process 0 does this)
if (rank == 0) {
printf("Hello from process %d of %d\n", rank
, MPI_Comm_size
(MPI_COMM_WORLD
, &rank
)); }
// Rest of your MPI code here...
// Finalize MPI
MPI_Finalize();
return 0;
}
I2luY2x1ZGUgPG1waS5oPgojaW5jbHVkZSA8c3RkaW8uaD4KCmludCBtYWluKGludCBhcmdjLCBjaGFyICoqYXJndikgewogICAgaW50IHJhbms7CgogICAgLy8gSW5pdGlhbGl6ZSBNUEkKICAgIE1QSV9Jbml0KCZhcmdjLCAmYXJndik7CgogICAgLy8gR2V0IG15IHJhbmsKICAgIE1QSV9Db21tX3JhbmsoTVBJX0NPTU1fV09STEQsICZyYW5rKTsKCiAgICAvLyBQcmludCB0aGUgbWVzc2FnZSBvbmx5IG9uY2UgKG9ubHkgcHJvY2VzcyAwIGRvZXMgdGhpcykKICAgIGlmIChyYW5rID09IDApIHsKICAgICAgICBwcmludGYoIkhlbGxvIGZyb20gcHJvY2VzcyAlZCBvZiAlZFxuIiwgcmFuaywgTVBJX0NvbW1fc2l6ZShNUElfQ09NTV9XT1JMRCwgJnJhbmspKTsKICAgIH0KCiAgICAvLyBSZXN0IG9mIHlvdXIgTVBJIGNvZGUgaGVyZS4uLgoKICAgIC8vIEZpbmFsaXplIE1QSQogICAgTVBJX0ZpbmFsaXplKCk7CiAgICByZXR1cm4gMDsKfQo=