fork download
  1. #include <mpi.h>
  2. #include <stdio.h>
  3. #include <windows.h>
  4.  
  5. int main(int argc, char** argv) {
  6.  
  7. MPI_Init(&argc, &argv);
  8.  
  9. int rank;
  10. MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  11.  
  12. int size;
  13. MPI_Comm_size(MPI_COMM_WORLD, &size);
  14.  
  15. char processor_name[MPI_MAX_PROCESSOR_NAME];
  16. int name_len;
  17. MPI_Get_processor_name(processor_name, &name_len);
  18.  
  19. double timer_resolution = MPI_Wtick();
  20.  
  21. double start_time = MPI_Wtime();
  22.  
  23. Sleep(1000);
  24.  
  25. double end_time = MPI_Wtime();
  26. double avg_time = (end_time - start_time);
  27.  
  28. printf("Process %d is running on CPU: %s\n", rank, processor_name);
  29. printf("MPI timer resolution: %0.10f\n", timer_resolution);
  30. printf("Average execution time: %0.10f seconds\n\n", avg_time);
  31.  
  32. MPI_Finalize();
  33.  
  34. return 0;
  35. }
  36.  
  37.  
Success #stdin #stdout #stderr 0.31s 40720KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: unexpected symbol in "int main"
Execution halted