fork download
  1. #include <mpi.h>
  2. #include <stdio.h>
  3.  
  4. int main(int argc, char** argv) {
  5. // Initialize the MPI environment
  6. MPI_Init(&argc, &argv);
  7.  
  8. // Get the number of processes
  9. int world_size;
  10. MPI_Comm_size(MPI_COMM_WORLD, &world_size);
  11.  
  12. // Get the rank of the process
  13. int world_rank;
  14. MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
  15.  
  16. // Print a hello message from each process
  17. printf("Hello, World! I am process %d of %d\n", world_rank, world_size);
  18.  
  19. // Finalize the MPI environment
  20. MPI_Finalize();
  21. return 0;
  22. }
Success #stdin #stdout #stderr 0.26s 40824KB
stdin
hello
stdout
Standard output is empty
stderr
Error: unexpected symbol in "int main"
Execution halted