PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : MPI: Problem mit -mpilog, Programm terminiert nicht mehr!


AlSvartr
2007-11-13, 19:40:08
Folgendes einfaches Programm:

1 #include <mpi.h>
2 #include <stdio.h>
3
4 int main(int argc, char **argv) {
5
6 int err;
7 err=MPI_Init(&argc, &argv); /* Initialize MPI */
8
9 int num_local;
10 int num_procs;
11
12
13 err=MPI_Comm_rank(MPI_COMM_WORLD, &num_local);
14
15 err=MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
16
17 /* this is for proc 0 */
18 if (num_local==0) {
19 int a[num_procs];
20 a[0]=1;
21 /* more than one proc available -> follow the assignment instructions ;) */
22 if (num_procs>1) {
23 for (int i=1;i<num_procs;i++) {
24 a[i]=0;
25 }
26 err=MPI_Send(a,num_procs,MPI_INT,1,0,MPI_COMM_WORLD);
27
28 /* receive and check the results for correctness */
29 err=MPI_Recv(a,num_procs,MPI_INT,num_procs-1,0,MPI_COMM_WORLD,0);
30 for(int i=0;i<num_procs;i++) {
31 printf("a[%d]==%d: ",i,a[i]);
32 if(a[i]==i+1) {
33 printf("TRUE\n");
34 }
35 else {
36 printf("FALSE\n");
37 break;
38 }
39 }
40 }
41 else {
42 printf("booooooring! :S\n");
43 }
44 }
45 /* this is for the other procs */
46 else {
47 int a[num_procs];
48 err=MPI_Recv(a,num_procs,MPI_INT,num_local-1,0,MPI_COMM_WORLD,0);
49 a[num_local]=num_local+1;
50 err=MPI_Send(a,num_procs,MPI_INT,(num_local+1)%num_procs,0,MPI_COMM_WORLD);
51 }
52 err=MPI_Finalize();
53 }


Linke ich das ganze nun mit -mpilog, so terminiert das Programm für mpirun -np m mit m>=2 nicht mehr, ohne die Linker-Option läufts jedoch problemlos - hat da irgendwer ne Idee?

AlSvartr
2007-11-13, 22:38:05
Das Problem hat sich erledigt, es war lediglich notwendig, bei MPI_Recv() Statusvariablen mit zu verwenden. Die werden wohl scheinbar durch die Instrumentierung irgendwie benötigt.