pour les connaisseurs de mpi
bonjour,voila mon probleme
ce code ne marche pas car il me renvoie a=0
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
int a,b;
#include <stdio.h>
#include <mpi.h>
int main( int argc, char* argv[])
{
int rang, p, valeur, tag = 10;
MPI_Status status;
/* Initialisation */
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD, &p);
MPI_Comm_rank(MPI_COMM_WORLD,&rang);
if ( rang == 0) {
printf("Jai recu la valeur %d du processus de rang 1",a);
}
else if ( rang == 1 )
{ a=22;
MPI_Bcast (&b,1 , MPI_INT, 1,MPI_COMM_WORLD);
}
MPI_Finalize();
return 0;
} |
par contre ce code fonctionne et me retoure la valeur de a=22
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
int a,b;
#include <stdio.h>
#include <mpi.h>
int main( int argc, char* argv[])
{
a=22;
int rang, p, valeur, tag = 10;
MPI_Status status;
/* Initialisation */
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD, &p);
MPI_Comm_rank(MPI_COMM_WORLD,&rang);
if ( rang == 0) {
printf("Jai recu la valeur %d du processus de rang 1",a);
}
else if ( rang == 1 )
{
MPI_Bcast (&b,1 , MPI_INT, 1,MPI_COMM_WORLD);
}
MPI_Finalize();
return 0;
} |
dans le 2ème code juste j'ai changé l'emplacement de la variable a
pourtant je veux initialisé la variable a dans le processus num 1
alors comment de dois faire
aidez moi svp
merci