Message Passing Interface (MPI)
MPC is fully MPI-1.3 compliant and supports the MPI_THREAD_MULTIPLE level from standard 2. See the document ”MPI: A Message-Passing Interface Standard” version 1.3 (May 2008) for more details.
Remove global variables
In MPC, every MPI task is a thread and thus all tasks share global variables with each other. We propose several solutions to ease the removal of global variables:
Use the option -Wmpc with the patched GCC compiler to generate warnings. In this mode, the compiler will warn you about every global variable declared in the program.
Use the option -fmpc-privatize to automatically privatize the global variables. In this mode, every global variable is duplicated for every MPI task such as the code can run correctly with MPC. Note than in versions older than 2.4.0, the application has to be compiled as a dynamic library for this solution to work.
MPC is fully OpenMP-2.5 compliant. See the document OpenMP Application Program Interface version 2.5 (May 2005) for more details. For version older than 2.4.0 you need to build you program as a dynamic library.
To compile applications with OpenMP directives (C, C++ or Fortran), you have to use the default compiler coming with the MPC Distribution (see Installation for explanation to install MPC). This compiler is a patched version of GCC generating code for the MPC library when transforming OpenMP directives. Thus, to activate the OpenMP transformation, use the -fopenmp option with the compiler drivers mpc_cc (C), mpc_cxx (C++) or mpc_f77 (Fortran).
The OpenMP standard proposes a directive to create threadprivate variables. The MPC implementation follows the standard and supports this feature.
MPC provides a POSIX Thread 2003 compatible API.
The main command mpcrun accepts the -m option to choose between several kind of threads. Here is a list of the current available thread types:
ethread: Mx1 user level thread model.
ethread_mxn: MxN user level thread model.
pthread: underlying POSIX Thread library.
The article Documentation/PerJouNam08EuroPar.pdf contains more details on the multiple thread types and their characteristics.
Do not mix thread libraries
It is dangerous to mix MPC POSIX Threads and system POSIX Threads! This mix may lead to an undefined behavior.