I plan to use MPI for my C++ code. I have installed MPICH2 on my computers. But I do not know much about MPI and hope to find some materials to read. I hope you experts can recommend some good materails to me. Any advice will be appreciated.
7 Answers
I'm assuming you already know how to program C++ pretty well and have a basic understanding of parallel programming (or at least know how you want to parallelize your code).
I would check out the book Using MPI first. Using MPI 2 is the follow on book that discusses using the new bits in MPi-2. Both books were written by the guys who wrote the MPI library and headed up the standardization effort. One nice thing about Using MPI is that it's available online so you can check it out w/o spending money :-)

- 1,421
- 1
- 11
- 14
-
1+1 from me. One small issue, which might or might not be a problem: switches between Fortran, C, and C++ sample code. – stephan Feb 16 '10 at 18:31
-
I agree it could be a bit annoying, but I didn't find it to be a significant detriment to understanding when I was using the book. – J Teller Feb 16 '10 at 18:39
Parallel Programming with MPI by Peter S. Pacheco is a good intro book. Note, the book uses C, but it should be an easy transition to using the C++ MPI bindings.

- 51,004
- 28
- 112
- 141
-
-
I think the book is a good way to learn to program with MPI. If you find my answer, you will discover that I do not favor using C++ for any new MPI development. Since you fail to mention a similar caution, no upvote. You did still get a supportive comment. ;) – Stan Graves Feb 17 '10 at 21:43
-
-
I would advise against using the MPI C++ bindings for any new development. The program itself can be in C++, but invest the extra effort to use the C interface to the MPI library.
The MPI Forum is deprecating the C++ bindings. So, future implementations of MPI will probably drop support for C++. In general, most implementations skimp on features when it comes to C++. The basics will work, but things like dynamic processes (i.e. spawn), the PMPI interfaces, and so on are less well supported.
The C and Fortran bindings are reasonably well supported by all the major implementations, and will continue to be supported into the foreseeable future.

- 5,087
- 6
- 37
- 73

- 6,795
- 2
- 18
- 14
-
For those who intent to stick with C++ which are the alternatives to MPI? To my knowledge its the only way to split things across different machines. There is OpenMP and CUDA but that's another business - I'll say. – KcFnMi Aug 18 '18 at 06:13
As @semiuseless pointed out, the MPI forum is deprecating the C++ bindings. One of the reasons for that is that the boost MPI interface does a much better job.

- 23,676
- 2
- 38
- 40
Mpich2 comes with a number of examples in C++/C. probably the most famous is cpi, which computes pi in parallel. Read through the program together with manuals/books other people suggested. This way you will see actual working code right away and can make your own modifications to play with things.

- 50,217
- 42
- 167
- 261