| 1 | Since revision **67** in SVN branch **inst_procedure** it is possible to use MPI kernels with MUSCLE. |
| 2 | |
| 3 | |
| 4 | == Limits & requirements == |
| 5 | |
| 6 | |
| 7 | |
| 8 | === MPI implementation === |
| 9 | |
| 10 | Currently OpenMPI //does not support// binding with JNI (see [http://www.open-mpi.org/community/lists/devel/2005/09/0359.php this bug]) |
| 11 | |
| 12 | The following implementation have been tested so far: |
| 13 | * [http://software.intel.com/en-us/articles/intel-mpi-library/ Intel MPI] |
| 14 | * [http://www.mcs.anl.gov/research/projects/mpich2/ MPICH2] |
| 15 | |
| 16 | === Running practices === |
| 17 | |
| 18 | |
| 19 | When using MPI in some kernel, this kernel must be run as the only in this muscle instance. Other kernels, as well as main, must be run from other MUSCLE instances. |
| 20 | |
| 21 | == Preparing source code == |
| 22 | |
| 23 | === Java === |
| 24 | |
| 25 | A new method, `public void executeDirectly()`, is available in `CaController` class. Only this method is called instead of normal MUSCLE routines on the processes with non-zero rank. Process with rank 0 is started in the usual way. Portals cannot be attached to slave processes (i.e. to the processes with non-zero rank). The `executeDirectly` method calls by default `execute()`. |
| 26 | |
| 27 | User may (and should) overload the executeDirectly` to better fit ones needs. |
| 28 | |
| 29 | === C/C++ === |
| 30 | |
| 31 | As in Java, only process with Rank 0 may use MUSCLE routines, such as portals or the kernel.willStop() method. User is responsible for stopping all the processes once the kernel should stop. |
| 32 | |
| 33 | MPI should be used in the natural way, i.e. the program should start with MPI::Initialize() and finish with MPI::Finalize(). |
| 34 | |
| 35 | == Running MPI kernels == |
| 36 | |
| 37 | To run a MPI kernel, one must distribute the processes with `mpirun`/`mpiexec` utility. One kernel per one MUSCLE instance allowed. |
| 38 | It is crucial to add the --mpi parameter for the muscle command - otherwise the simulation will fail, as multiple identical MUSCLE instances will arise. |
| 39 | |
| 40 | `mpirun -n 5 muscle --mpi --cxa_file src/cxa/Test.cxa.rb mpi` |
| 41 | |
| 42 | |
| 43 | Of course, in another process the main must be started, as well as other kernels required by the cxa file, for example |
| 44 | |
| 45 | `muscle --main plumber --cxa_file src/cxa/Test.cxa.rb --autoquit` |
| 46 | |
| 47 | An example (started with the commands above) has been added to the SVN in revision 68. |