2016-07-02 9 views
1

Ich habe gerade erst begonnen MPI Lernen und das ist mein erstes Programm zum Senden und Daten zwischen zwei Prozessor empfangen ...MPI mit C: Kommunikationszeit

  MPI_Status status; 
      MPI_Init(&argc,&argv); 
      MPI_Comm_rank(MPI_COMM_WORLD,&rank); 
      MPI_Comm_size(MPI_COMM_WORLD,&size); 
      printf("Comm Size %d",size); 
      printf("Rank %d",rank); 
      if (rank == 0) 
        { 
          for(j=1;j<size;j++); 
            { 
              tmp = clock(); 
              start_time = clock(); 
              MPI_Send(&N,1,MPI_INT,j,j,MPI_COMM_WORLD); 
              MPI_Recv(&N,1,MPI_INT,j,j,MPI_COMM_WORLD,&status); 
              end_time = clock(); 
              timer_overhead = start_time - tmp; 
              total_time = end_time - start_time - timer_overhead; 
              communication_time = total_time/2; 
              printf("%d",total_time); 
            } 
        } 
      else 
        { 
          MPI_Recv(&N,1,MPI_INT,0,rank,MPI_COMM_WORLD,&status); 
          MPI_Send(&N,1,MPI_INT,0,rank,MPI_COMM_WORLD); 
        } 

      MPI_Finalize(); 
    } 

~
Aber dieses Programm behalten hängen immer, Kann mir bitte jemand helfen.

Antwort

3

In der Zeile, wo Sie die for-Schleife haben, haben Sie ';' Am Ende.

for(j=1;j<size;j++); 

Entfernen Sie das ';'.