mpiref.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. Note: don't install mpich and openmpi at the same machine
  2. [prefer mpich in linux distributions than openmpi]
  3. MPI API manual pages: https://docs.open-mpi.org/en/v5.0.x/man-openmpi/man3/index.html
  4. Open MPI commands: [https://www.open-mpi.org/doc/current/]
  5. (section 1 man pages)
  6. mpic++ mpif90 ompi_info orted
  7. mpicc mpifort opal_wrapper orterun
  8. mpicxx mpirun orte-clean
  9. mpiexec ompi-clean orte-info
  10. mpif77 ompi-server orte-server
  11. Open MPI general information:
  12. (section 7 man pages)
  13. ompi_crcp orte_filem orte_snapc
  14. opal_crs orte_hosts orte_sstore
  15. MPI Tutorial:
  16. https://mpitutorial.com/tutorials/mpi-hello-world/
  17. Using MPI and Using Advanced MPI:
  18. http://wgropp.cs.illinois.edu/usingmpiweb/index.html
  19. Using MPI with C:
  20. https://curc.readthedocs.io/en/latest/programming/MPI-C.html
  21. Using MPI with Fortran:
  22. https://curc.readthedocs.io/en/latest/programming/MPI-Fortran.html
  23. An introduction to the Message Passing Interface (MPI) using C:
  24. http://condor.cc.ku.edu/~grobe/docs/intro-MPI-C.shtml
  25. MPI C Examples:
  26. https://people.math.sc.edu/Burkardt/c_src/mpi/mpi.html
  27. Beginner's Guide to MPI (MPICH-v1.0.12) [University of Delaware DEC Alpha Cluster]:
  28. https://www.eecis.udel.edu/~pollock/367/manual/manual.html
  29. Hybrid Patternlets in MPI and OpenMP:
  30. http://selkie.macalester.edu/csinparallel/modules/Patternlets/build/html/Hybrid/Hybrid_Patternlets.html
  31. MPI Install:
  32. $ doas apt-get install mpich
  33. $ mpiexec --version /* information of build details */
  34. To compile a single file program.c:
  35. mpicc -c program.c
  36. To link the output and make an executable:
  37. mpicc -o program program.o
  38. Combining compilation and linking in a single command:
  39. mpicc -o program program.c
  40. To see the full compiler invocation line:
  41. mpicc -show
  42. Reference: https://www.mpich.org/static/docs/v3.4.x/www1/mpicc.html
  43. C language MPI environment
  44. -----------------------------------------------------------
  45. char MPI_CHAR
  46. signed short int MPI_SHORT
  47. signed int MPI_INT
  48. signed long int MPI_LONG
  49. signed long long int MPI_LONG_LONG_INT
  50. signed char MPI_SIGNED_CHAR
  51. unsigned char MPI_UNSIGNED_CHAR
  52. unsigned short int MPI_UNSIGNED_SHORT
  53. unsigned int MPI_UNSIGNED
  54. unsigned long int MPI_UNSIGNED_LONG
  55. unsigned long long int MPI_UNSIGNED_LONG_LONG
  56. float MPI_FLOAT
  57. double MPI_DOUBLE
  58. long double MPI_LONG_DOUBLE
  59. wchar_t MPI_WCHAR
  60. _Bool MPI_C_BOOL
  61. float _Complex MPI_C_COMPLEX
  62. double _Complex MPI_C_DOUBLE_COMPLEX
  63. long double _Complex MPI_C_LONG_DOUBLE_COMPLEX
  64. No cirrespondence MPI_BYTE
  65. No correspondence MPI_PACKED
  66. Collective computation built-in operations:
  67. Operation handle Operation
  68. -----------------------------------------------------------
  69. MPI_MIN minimum
  70. MPI_MAX maximum
  71. MPI_SUM sum
  72. MPI_PROD product
  73. MPI_LAND logical AND
  74. MPI_LOR logical OR
  75. MPI_LXOR logical Exclusive OR
  76. MPI_BAND bitwise AND
  77. MPI_BOR bitwise OR
  78. MPI_EXOR bitwise Exclusive OR
  79. MPI_MINLOC minimum value and location
  80. MPI_MAXLOC maximum value and location
  81. C reference:
  82. #include <mpi.h>
  83. MPI_Init(&argc, &argv);
  84. MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  85. MPI_Comm_size(MPI_COMM_WORLD, &size);
  86. /* array gather */
  87. double *wave = (double *) malloc(n * sizeof(double));
  88. double *rwave = (double *) malloc(N * sizeof(double));
  89. MPI_Gather(wave, n, MPI_DOUBLE, rwave, n, MPI_DOUBLE, 0, MPI_COMM_WORLD);
  90. Python reference:
  91. from mpi4py import MPI
  92. comm = MPI.COMM_WORLD
  93. rank = comm.Get_rank()
  94. size = comm.Get_size()
  95. """ numpy array gather """
  96. wave = np.sin(xval[sload:eload])
  97. rwave = np.zeros(len(xval), dtype=np.float64)
  98. comm.Gatherv(wave, rwave, 0)