Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
documentation:examples:sommevecvecpar.c [2013/02/06 16:37] – créée ltaulell | documentation:examples:sommevecvecpar.c [2023/01/13 09:37] (Version actuelle) – supprimée ccalugar | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | <code c SommeVecVecPAR.c> | ||
- | #include < | ||
- | #include < | ||
- | void main (int argc, char *argv[]) | ||
- | { | ||
- | MPI_Status statut; | ||
- | int etiquette=100; | ||
- | int A[10], | ||
- | int i; | ||
- | int nb_procs, | ||
- | |||
- | MPI_Init(& | ||
- | MPI_Comm_size(MPI_COMM_WORLD,& | ||
- | MPI_Comm_rank(MPI_COMM_WORLD,& | ||
- | |||
- | if (rang == 0) | ||
- | { | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | | ||
- | |||
- | | ||
- | | ||
- | { | ||
- | | ||
- | } | ||
- | |||
- | | ||
- | | ||
- | { | ||
- | | ||
- | } | ||
- | } | ||
- | |||
- | MPI_Barrier (MPI_COMM_WORLD); | ||
- | |||
- | if (rang == 0) | ||
- | { | ||
- | MPI_Send (& | ||
- | MPI_Send (& | ||
- | MPI_Send (& | ||
- | MPI_Send (& | ||
- | } | ||
- | |||
- | MPI_Recv (& | ||
- | MPI_Recv (& | ||
- | |||
- | MPI_Barrier ( MPI_COMM_WORLD); | ||
- | if (rang == 0) | ||
- | { | ||
- | | ||
- | } | ||
- | |||
- | MPI_Barrier ( MPI_COMM_WORLD); | ||
- | |||
- | printf ("Je suis le proc %d parmi %d processus", | ||
- | |||
- | printf (" \n A local ( proc %d ) = ", | ||
- | for(i=1; | ||
- | { | ||
- | printf (" %d ", | ||
- | } | ||
- | |||
- | MPI_Barrier ( MPI_COMM_WORLD); | ||
- | |||
- | printf (" \n B local ( proc %d ) = ", | ||
- | for(i=1; | ||
- | { | ||
- | printf (" %d ", | ||
- | } | ||
- | |||
- | MPI_Barrier ( MPI_COMM_WORLD); | ||
- | |||
- | for(i=1; | ||
- | { | ||
- | Cloc[i-1] = Aloc[i-1] + Bloc[i-1]; | ||
- | } | ||
- | |||
- | MPI_Barrier ( MPI_COMM_WORLD); | ||
- | |||
- | if (rang == 0) | ||
- | { | ||
- | | ||
- | } | ||
- | |||
- | MPI_Barrier ( MPI_COMM_WORLD); | ||
- | |||
- | printf (" \n C local ( proc %d ) = ", | ||
- | for(i=1; | ||
- | { | ||
- | printf (" %d ", | ||
- | } | ||
- | |||
- | MPI_Barrier ( MPI_COMM_WORLD); | ||
- | |||
- | MPI_Send (& | ||
- | |||
- | if (rang == 0) | ||
- | { | ||
- | MPI_Recv (& | ||
- | MPI_Recv (& | ||
- | } | ||
- | |||
- | if (rang == 0) | ||
- | { | ||
- | printf (" \n LE VECTEUR SOMME : "); | ||
- | for(i=1; | ||
- | { | ||
- | | ||
- | } | ||
- | printf (" \n "); | ||
- | } | ||
- | |||
- | MPI_Finalize(); | ||
- | } | ||
- | </ |