Skip to content

Commit

Permalink
Chap 4 - Collectives de déplacement de données
Browse files Browse the repository at this point in the history
  • Loading branch information
plstonge committed May 10, 2024
1 parent 2626150 commit 3359b7f
Showing 1 changed file with 101 additions and 3 deletions.
104 changes: 101 additions & 3 deletions 4-collectives.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
},
{
"cell_type": "markdown",
"id": "0f26d881-eb90-4ff6-b202-3e3f4ec0417e",
"id": "88e3f8b9-6001-4453-a866-59ef3fb7545f",
"metadata": {},
"source": [
"[En **C**](https://www.mpi-forum.org/docs/mpi-4.1/mpi41-report.pdf#section.6.5) :\n",
Expand All @@ -143,8 +143,14 @@
"ierr = MPI_Gather(&a, 1, MPI_INT,\n",
" b, 1, MPI_INT, 2, MPI_COMM_WORLD);\n",
"\n",
"```\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "c7a6cd00-0ec9-4afa-9e6f-ed43ff50ef3b",
"metadata": {},
"source": [
"[En **Python**](https://mpi4py.readthedocs.io/en/latest/reference/mpi4py.MPI.Comm.html#mpi4py.MPI.Comm.gather) :\n",
"\n",
"```Python\n",
Expand All @@ -154,6 +160,98 @@
"```"
]
},
{
"cell_type": "markdown",
"id": "321dd480-724b-4261-9c87-efd2591f7439",
"metadata": {},
"source": [
"### Regroupement à tous avec `MPI_Allgather`\n",
"\n",
"C'est l'équivalent de `MPI_Gather` + `MPI_Bcast`,\n",
"mais en plus efficace :\n",
"\n",
"![Figure MPI_Allgather](images/mpi_allgather.svg)"
]
},
{
"cell_type": "markdown",
"id": "d50e117b-3d33-40e2-a1f8-ba8825471c05",
"metadata": {},
"source": [
"[En **C**](https://www.mpi-forum.org/docs/mpi-4.1/mpi41-report.pdf#section.6.7) :\n",
"\n",
"```C\n",
"// int MPI_Allgather(\n",
"// void *envoi, int compte_envoi, MPI_Datatype type_envoi,\n",
"// void *recep, int compte_recep, MPI_Datatype type_recep,\n",
"// MPI_Comm comm)\n",
"\n",
"ierr = MPI_Allgather(&a, 1, MPI_INT,\n",
" b, 1, MPI_INT, MPI_COMM_WORLD);\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "07b7b72a-17d2-413d-b8a1-fa5bee599e02",
"metadata": {},
"source": [
"[En **Python**](https://mpi4py.readthedocs.io/en/latest/reference/mpi4py.MPI.Comm.html#mpi4py.MPI.Comm.allgather) :\n",
"\n",
"```Python\n",
"# allgather(envoi: Any) -> list[Any]\n",
"\n",
"b = comm.allgather(a)\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "5724389a-680a-44ca-8776-a1b3b01ab7e2",
"metadata": {},
"source": [
"### Transposition globale avec `MPI_Alltoall`\n",
"\n",
"C'est l'équivalent de `MPI_Scatter` * `MPI_Gather`,\n",
"mais en plus efficace :\n",
"\n",
"![Figure MPI_Alltoall](images/mpi_alltoall.svg)"
]
},
{
"cell_type": "markdown",
"id": "f2e6f727-8b46-4a04-92e5-738b609989a0",
"metadata": {},
"source": [
"[En **C**](https://www.mpi-forum.org/docs/mpi-4.1/mpi41-report.pdf#section.6.8) :\n",
"\n",
"```C\n",
"// int MPI_Alltoall(\n",
"// void *envoi, int compte_envoi, MPI_Datatype type_envoi,\n",
"// void *recep, int compte_recep, MPI_Datatype type_recep,\n",
"// MPI_Comm comm)\n",
"\n",
"ierr = MPI_Alltoall(&a, 1, MPI_INT,\n",
" b, 1, MPI_INT, MPI_COMM_WORLD);\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "98bf10fa-85de-4aad-baa8-5034e55e87e4",
"metadata": {},
"source": [
"[En **Python**](https://mpi4py.readthedocs.io/en/latest/reference/mpi4py.MPI.Comm.html#mpi4py.MPI.Comm.alltoall) :\n",
"\n",
"```Python\n",
"# alltoall(envoi: Sequence[Any]) -> list[Any]\n",
"\n",
"b = comm.alltoall(a)\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit 3359b7f

Please sign in to comment.