Skip to content

Commit

Permalink
Programme MPI avec rank et size
Browse files Browse the repository at this point in the history
  • Loading branch information
plstonge committed Apr 23, 2024
1 parent 2678086 commit ce955c7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
18 changes: 10 additions & 8 deletions demos/bonjour.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#include <stdio.h>
#include <mpi.h>

int main(int argc,char *argv[]) {
int p, np;
MPI_Init(&argc,&argv);
int main(int argc, char *argv[])
{
int p, np;

MPI_Comm_rank(MPI_COMM_WORLD, &p);
MPI_Comm_size(MPI_COMM_WORLD, &np);
printf( "Ici le processus %d de %d\n", p, np );
MPI_Init(&argc, &argv);

MPI_Finalize();
return 0;
MPI_Comm_rank(MPI_COMM_WORLD, &p);
MPI_Comm_size(MPI_COMM_WORLD, &np);
printf("Ici le processus %d de %d\n", p, np);

MPI_Finalize();
return 0;
}
17 changes: 17 additions & 0 deletions demos/bonjour.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env python

from mpi4py import MPI # MPI.Init() implicite

def main():
"""
Programme principal
"""

p = MPI.COMM_WORLD.Get_rank()
np = MPI.COMM_WORLD.Get_size()
print(f'Ici le processus {p} de {np}')

MPI.Finalize()

if __name__ == '__main__':
main()

0 comments on commit ce955c7

Please sign in to comment.