fork download
  1. #include <mpi.h>
  2. #include <stdio.h>
  3.  
  4. void main(int argc, char** argv) {
  5. // Initialize the MPI environment
  6. MPI_Init(NULL, NULL);
  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. // Get the name of the processor
  17. char processor_name[MPI_MAX_PROCESSOR_NAME];
  18. int name_len;
  19. MPI_Get_processor_name(processor_name, &name_len);
  20.  
  21. // Print off a hello world message
  22. printf("Hello world from processor %s, rank %d"
  23. " out of %d processors\n",
  24. processor_name, world_rank, world_size);
  25.  
  26. // Finalize the MPI environment.
  27. MPI_Finalize();
  28. }
  29.  
  30.  
  31.  
Success #stdin #stdout #stderr 0.16s 175424KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: unexpected symbol in "void main"
Execution halted