Skip to content

Commit

Permalink
Chap 5 - Conclusion et informations supplémentaires
Browse files Browse the repository at this point in the history
  • Loading branch information
plstonge committed May 15, 2024
1 parent f211225 commit 71b2ee4
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 1 deletion.
5 changes: 4 additions & 1 deletion 0-a_propos.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
" 1. Déplacements de données\n",
" 1. Calculs collectifs\n",
" 1. Division de l'espace de travail\n",
"1. [Conclusion](5-conclusion.ipynb)"
"1. [Conclusion](5-conclusion.ipynb)\n",
" 1. MPI dans les autres langages\n",
" 1. Défis de parallélisation supplémentaires\n",
" 1. Bonus - Notions avancées"
]
},
{
Expand Down
166 changes: 166 additions & 0 deletions 5-conclusion.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "60341bdf-a714-4257-a24f-36e78071faff",
"metadata": {},
"source": [
"# Conclusion\n",
"\n",
"Rappel de quelques concepts du parallélisme :\n",
"\n",
"* Communications et synchronisations\n",
" * Dépendances entre processeurs\n",
"* [Scalabilité](https://docs.alliancecan.ca/wiki/Scalability/fr) et\n",
" [loi d'Amdahl](https://fr.wikipedia.org/wiki/Loi_d%27Amdahl)\n",
" * Granularité - quantité minimale de travail à faire de manière autonome\n",
" * Répartition de la charge"
]
},
{
"cell_type": "markdown",
"id": "c13f5761-af71-4529-a701-c836fe1cfb1f",
"metadata": {},
"source": [
"## MPI dans les autres langages\n",
"\n",
"* Fortran : le standard MPI est déjà défini en Fortran\n",
"* C++ :\n",
" * MPI 3.0 a éliminé les interfaces C++\n",
" * [Boost MPI](https://www.boost.org/doc/libs/release/libs/mpi/) :\n",
" bibliothèque pratique et très puissante\n",
" pour les développeurs en C++\n",
" * [Midi-conférence Boost-MPI](https://www.youtube.com/watch?v=U0axIKTO3wM)\n",
"\n",
"```C++\n",
"boost::mpi::environment env(argc, argv);\n",
"boost::mpi::communicator world;\n",
"std::string s;\n",
"\n",
"if (world.rank() == 0)\n",
" world.recv(boost::mpi::any_source, 746, s);\n",
"\n",
"```\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "b1069897-835c-4e43-ba78-00f5430a841f",
"metadata": {},
"source": [
"## Défis de parallélisation supplémentaires\n",
"\n",
"Les codes suivants fonctionnent déjà en mode séquentiel.\n",
"C'est maintenant à vous de les paralléliser avec MPI :\n",
"\n",
"* [Écoulement de chaleur](https://github.com/calculquebec/cq-formation-ecoulement-chaleur)\n",
"* [Convolution sur une image](https://github.com/calculquebec/cq-formation-convolution/tree/main/defi-mpi)\n",
"* [Problème à N corps](https://github.com/calculquebec/cq-formation-nbody)\n",
"\n",
"Pour mesurer le temps d’exécution d’un programme,\n",
"la commande `time srun` doit être dans un\n",
"[script de tâche](https://docs.alliancecan.ca/wiki/Running_jobs/fr#T.C3.A2che_MPI)\n",
"soumis avec la commande `sbatch` :\n",
"\n",
"```Bash\n",
"#!/bin/bash\n",
"#SBATCH --ntasks=4\n",
"#SBATCH … # temps, mémoire, etc.\n",
"\n",
"time srun ./programme\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "ef2704f6-5e88-4a23-90f6-66619b2c86d7",
"metadata": {},
"source": [
"## Bonus - Notions avancées\n",
"\n",
"MPI possède d'autres fonctionnalités :\n",
"\n",
"* collectives à partitions inégales\n",
"* collectives non bloquantes (MPI 3)\n",
"* entrées-sorties parallèles (MPI-IO)\n",
"* **groupes, communicateurs, topologie**\n",
"* types dérivés\n",
"* accès distant (one-sided communication)\n",
"* communications persistantes\n",
"* processus dynamiques et fils"
]
},
{
"cell_type": "markdown",
"id": "3dcbe303-04d4-4397-8083-78c64cdab612",
"metadata": {},
"source": [
"### Collectives à partitions inégales\n",
"\n",
"* Les fonctions de communication collective vues jusqu'ici envoyaient\n",
" des données de **même taille** pour chaque processus MPI\n",
"* Lorsque les données varient en taille, il faut dans certains\n",
" cas utiliser des fonctions avec des arguments supplémentaires :\n",
" * [MPI_Scatterv](https://www.mpi-forum.org/docs/mpi-4.1/mpi41-report.pdf#page=252)\n",
" * [MPI_Gatherv](https://www.mpi-forum.org/docs/mpi-4.1/mpi41-report.pdf#page=242)\n",
" * [MPI_Allgatherv](https://www.mpi-forum.org/docs/mpi-4.1/mpi41-report.pdf#page=258)\n",
" * [MPI_Alltoallv](https://www.mpi-forum.org/docs/mpi-4.1/mpi41-report.pdf#page=262)"
]
},
{
"cell_type": "markdown",
"id": "d3240603-afa3-47b6-965a-d64617fd64b8",
"metadata": {},
"source": [
"* Chaque processus a alors besoin de la position\n",
" (**déplacement**) du premier élément qui le concerne et\n",
" du nombre (**compte**) d'éléments à envoyer ou recevoir\n",
"* Tous les processus doivent calculer ces **déplacements**\n",
" et **comptes** dans une étape préliminaire"
]
},
{
"cell_type": "markdown",
"id": "432539d9-1704-4cd5-8602-53ff50cd9a89",
"metadata": {},
"source": [
"`rank` | 0 | 1 | 2\n",
":---------------------:|:--------:|:--------:|:--------:\n",
"vecteur (`n` éléments) | 5 8 3 12 | 34 12 45 | 43 65 2 1\n",
"Indices | 0 1 2 3 | 4 5 6 | 7 8 9 10\n",
"déplacement (`debut`) | 0 | 4 | 7\n",
"compte (`fin-debut`) | 4 | 3 | 4"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ac6d33b7-c3e5-4a57-acc3-ad8030104ed9",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
1 change: 1 addition & 0 deletions _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ chapters:
- file: 2-mpi
- file: 3-point-a-point
- file: 4-collectives
- file: 5-conclusion
- file: 99-references

0 comments on commit 71b2ee4

Please sign in to comment.