.. title: OpenMPI, MPICH et MPI_THREAD_MULTIPLE :name: openmpi-mpich-et-mpi_thread_multiple `Retour à la page Systèmes <../systeme.html>`__ - `Motivation <#motivation>`__ - `Tests simples <#tests_simples>`__ - `Execution de l'exemple <#execution>`__ .. _motivation: Motivation ---------- Une question de développeur arrivée un vendredi soir me laisse le week-end pour trouver la réponse: comment tester si une implémentation `MPI `__ peut gérer les threads multiples? .. _tests_simples: Petit test simple ----------------- La norme MPI prévoit, au chapitre `C Bindings `__, une fonction ``MPI_Init_thread(int *argc, int ***argv, int required,&provided)`` qui est documentée par exemple dans les pages de `manuel MPI `__. Cela conduit à un petit programme tout simple: .. code:: C #include #include /* This program justs retrieves the level of thread support */ /* for the currently used MPI implementation. */ int main(int argc, char **argv) { int provided; char *s = NULL; MPI_Init_thread(&argc,&argv,MPI_THREAD_MULTIPLE,&provided); MPI_Finalize(); printf("requested=%08x, provided=%08x\n", MPI_THREAD_MULTIPLE, provided); switch(provided) { case MPI_THREAD_SINGLE: s = "MPI_THREAD_SINGLE"; break; case MPI_THREAD_FUNNELED: s = "MPI_THREAD_FUNNELED"; break; case MPI_THREAD_SERIALIZED: s = "MPI_THREAD_SERIALIZED"; break; case MPI_THREAD_MULTIPLE: s = "MPI_THREAD_MULTIPLE"; break; } /* switch */ printf("%s\n",s); return provided; } .. _execution: Execution de l'exemple ---------------------- Exemple d'exécution pour deux librairies différentes (``OpenMPI`` et ``MPich2``): .. code:: bash $ module load openmpi-i386 $ mpicc mpi_initthread.c -o mpi_initthread-ompi $ ./mpi_initthread-ompi requested=00000003, provided=00000000 MPI_THREAD_SINGLE $ module switch openmpi-i386 mpich2-i386 $ mpicc mpi_initthread.c -o mpi_initthread-mpich $ ./mpi_initthread-mpich requested=00000003, provided=00000003 MPI_THREAD_MULTIPLE