fork download
  1. #include <iostream>
  2. #include <mpi.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. // initialize the MPI environment
  8. MPI_Init(NULL, NULL);
  9.  
  10. // get the number of processes
  11. int worldSize;
  12. MPI_Comm_size(MPI_COMM_WORLD, &worldSize);
  13.  
  14. // get the rank of the process
  15. int rank;
  16. MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  17.  
  18. cout << "Hello world from process " << rank << " out of " << worldSize << endl;
  19.  
  20. MPI_Finalize();
  21. return 0;
  22. }
  23.  
Success #stdin #stdout #stderr 0.32s 40536KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: unexpected symbol in "using namespace"
Execution halted