2013-03-23 83 views
-12

試圖編譯程序,這將幫助我標杆消息機器之間傳遞,但我得到31個編譯器錯誤:(31的編譯器錯誤:(

這些是我收到的錯誤:

PingPong.java:9: error: cannot find symbol 
     my_pe = MPI.COMM_WORLD.Rank(); 
     ^
    symbol: variable my_pe 
    location: class PingPong 
PingPong.java:10: error: cannot find symbol 
     npes = MPI.COMM_WORLD.Size(); 
     ^
    symbol: variable npes 
    location: class PingPong 
PingPong.java:11: error: cannot find symbol 
     for (log2nbyte = 0; log2nbyte <= LOG2N_MAX; ++log2nbyte) { 
      ^
    symbol: variable log2nbyte 
    location: class PingPong 
PingPong.java:11: error: cannot find symbol 
     for (log2nbyte = 0; log2nbyte <= LOG2N_MAX; ++log2nbyte) { 
          ^
    symbol: variable log2nbyte 
    location: class PingPong 
PingPong.java:11: error: cannot find symbol 
     for (log2nbyte = 0; log2nbyte <= LOG2N_MAX; ++log2nbyte) { 
             ^
    symbol: variable LOG2N_MAX 
    location: class PingPong 
PingPong.java:11: error: cannot find symbol 
     for (log2nbyte = 0; log2nbyte <= LOG2N_MAX; ++log2nbyte) { 
                ^
    symbol: variable log2nbyte 
    location: class PingPong 
PingPong.java:12: error: cannot find symbol 
      nbyte = (1 << log2nbyte); 
      ^
    symbol: variable nbyte 
    location: class PingPong 
PingPong.java:12: error: cannot find symbol 
      nbyte = (1 << log2nbyte); 
         ^
    symbol: variable log2nbyte 
    location: class PingPong 
PingPong.java:13: error: cannot find symbol 
      byte A[] = new byte[nbyte]; 
           ^
    symbol: variable nbyte 
    location: class PingPong 
PingPong.java:14: error: cannot find symbol 
      for (j_pe = 1; j_pe <= npes - 1; ++j_pe) { 
       ^
    symbol: variable j_pe 
    location: class PingPong 
PingPong.java:14: error: cannot find symbol 
      for (j_pe = 1; j_pe <= npes - 1; ++j_pe) { 
         ^
    symbol: variable j_pe 
    location: class PingPong 
PingPong.java:14: error: cannot find symbol 
      for (j_pe = 1; j_pe <= npes - 1; ++j_pe) { 
           ^
    symbol: variable npes 
    location: class PingPong 
PingPong.java:14: error: cannot find symbol 
      for (j_pe = 1; j_pe <= npes - 1; ++j_pe) { 
              ^
    symbol: variable j_pe 
    location: class PingPong 
PingPong.java:16: error: cannot find symbol 
       tf[0] = MPI.Wtime(); 
       ^
    symbol: variable tf 
    location: class PingPong 
PingPong.java:17: error: cannot find symbol 
       for (n_pp = 0; n_pp < PINGPONGS; n_pp++) { 
        ^
    symbol: variable n_pp 
    location: class PingPong 
PingPong.java:17: error: cannot find symbol 
       for (n_pp = 0; n_pp < PINGPONGS; n_pp++) { 
          ^
    symbol: variable n_pp 
    location: class PingPong 
PingPong.java:17: error: cannot find symbol 
       for (n_pp = 0; n_pp < PINGPONGS; n_pp++) { 
            ^
    symbol: variable PINGPONGS 
    location: class PingPong 
PingPong.java:17: error: cannot find symbol 
       for (n_pp = 0; n_pp < PINGPONGS; n_pp++) { 
               ^
    symbol: variable n_pp 
    location: class PingPong 
PingPong.java:18: error: cannot find symbol 
        if (my_pe == j_pe) { 
         ^
    symbol: variable my_pe 
    location: class PingPong 
PingPong.java:18: error: cannot find symbol 
        if (my_pe == j_pe) { 
           ^
    symbol: variable j_pe 
    location: class PingPong 
PingPong.java:19: error: cannot find symbol 
         MPI.COMM_WORLD.Send(A, 0, nbyte, MPI.BYTE, 0, 10); 
               ^
    symbol: variable nbyte 
    location: class PingPong 
PingPong.java:20: error: cannot find symbol 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, 0, 2 
0); 
         ^
    symbol: variable status 
    location: class PingPong 
PingPong.java:20: error: cannot find symbol 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, 0, 2 
0); 
                 ^
    symbol: variable nbyte 
    location: class PingPong 
PingPong.java:22: error: cannot find symbol 
        if (my_pe == 0) { 
         ^
    symbol: variable my_pe 
    location: class PingPong 
PingPong.java:23: error: cannot find symbol 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, j_pe 
, 10); 
         ^
    symbol: variable status 
    location: class PingPong 
PingPong.java:23: error: cannot find symbol 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, j_pe 
, 10); 
                 ^
    symbol: variable nbyte 
    location: class PingPong 
PingPong.java:23: error: cannot find symbol 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, j_pe 
, 10); 
                      ^
    symbol: variable j_pe 
    location: class PingPong 
PingPong.java:24: error: cannot find symbol 
         MPI.COMM_WORLD.Send(A, 0, nbyte, MPI.BYTE, j_pe, 20); 
               ^
    symbol: variable nbyte 
    location: class PingPong 
PingPong.java:24: error: cannot find symbol 
         MPI.COMM_WORLD.Send(A, 0, nbyte, MPI.BYTE, j_pe, 20); 
                   ^
    symbol: variable j_pe 
    location: class PingPong 
PingPong.java:27: error: cannot find symbol 
       tf[ns + 1] = MPI.Wtime(); 
       ^
    symbol: variable tf 
    location: class PingPong 
PingPong.java:27: error: cannot find symbol 
       tf[ns + 1] = MPI.Wtime(); 
       ^
    symbol: variable ns 
    location: class PingPong 
31 errors 

這是我試圖編譯代碼:

public static void main(String[] args) throws MPIException { 

     MPI.Init(args); 
     my_pe = MPI.COMM_WORLD.Rank(); 
     npes = MPI.COMM_WORLD.Size(); 
     for (log2nbyte = 0; log2nbyte <= LOG2N_MAX; ++log2nbyte) { 
      nbyte = (1 << log2nbyte); 
      byte A[] = new byte[nbyte]; 
      for (j_pe = 1; j_pe <= npes - 1; ++j_pe) { 
       MPI.COMM_WORLD.Barrier(); 
       tf[0] = MPI.Wtime(); 
       for (n_pp = 0; n_pp < PINGPONGS; n_pp++) { 
        if (my_pe == j_pe) { 
         MPI.COMM_WORLD.Send(A, 0, nbyte, MPI.BYTE, 0, 10); 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, 0, 20); 
        } 
        if (my_pe == 0) { 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, j_pe, 10); 
         MPI.COMM_WORLD.Send(A, 0, nbyte, MPI.BYTE, j_pe, 20); 
        } 
       } 
       tf[ns + 1] = MPI.Wtime(); 
      } 
     } 
     MPI.Finalize(); 
    } 
} 

爲什麼它被拉起這些錯誤的任何想法,這是我第一次嘗試在CMD代碼,而不是使用NetBeans,所以上午律CON熔合在錯誤

編輯::

是代碼是從谷歌,我期待得到它的工作,幫助我理解它是如何工作的,這樣我就可以使用的比特一些其他的代碼,我

這是它目前是:

import mpi.*; 

class PingPong { 

    public static int j_pe; 
public static int npes; 
public static int log2nbyte; 
public static int nbyte; 
public static int LOG2N_MAX; 
public static int PINGPONGS; 
public static int n_pp; 
public static int status; 
public static int ns; 

public static void main(String[] args) throws MPIException { 

    int my_pe = 0; 

    MPI.Init(args); 
    my_pe = MPI.COMM_WORLD.Rank(); 
    npes = MPI.COMM_WORLD.Size(); 
    for (log2nbyte = 0; log2nbyte <= LOG2N_MAX; ++log2nbyte) { 
     nbyte = (1 << log2nbyte); 
     byte A[] = new byte[nbyte]; 
     for (j_pe = 1; j_pe <= npes - 1; ++j_pe) { 
      MPI.COMM_WORLD.Barrier(); 
      tf[0] = MPI.Wtime(); 
      for (n_pp = 0; n_pp < PINGPONGS; n_pp++) { 
       if (my_pe == j_pe) { 
        MPI.COMM_WORLD.Send(A, 0, nbyte, MPI.BYTE, 0, 10); 
        status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, 0, 20); 
       } 
       if (my_pe == 0) { 
        status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, j_pe, 10); 
        MPI.COMM_WORLD.Send(A, 0, nbyte, MPI.BYTE, j_pe, 20); 
       } 
      } 
      tf[ns + 1] = MPI.Wtime(); 
     } 
    } 
    MPI.Finalize(); 
} 

}

,但我仍然得到這些錯誤:

PingPong.java:29: error: cannot find symbol 
       tf[0] = MPI.Wtime(); 
       ^
    symbol: variable tf 
    location: class PingPong 
PingPong.java:33: error: incompatible types 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, 0, 2 
0); 
                ^
    required: int 
    found: Status 
PingPong.java:36: error: incompatible types 
         status = MPI.COMM_WORLD.Recv(A, 0, nbyte, MPI.BYTE, j_pe 
, 10); 
                ^
    required: int 
    found: Status 
PingPong.java:40: error: cannot find symbol 
       tf[ns + 1] = MPI.Wtime(); 
       ^
    symbol: variable tf 
    location: class PingPong 
4 errors 
+0

你班上的其他人是什麼樣子的? – Xymostech 2013-03-23 22:20:22

回答

5

沒有定義變量。看起來像一個經典的複製/粘貼。
定義變量並使用Eclipse。

+0

是的代碼是從谷歌,我期待得到它的工作,以幫助我瞭解它是如何工作的,所以我可以使用一些其他代碼我有 – user2065929 2013-03-23 22:50:02

2

您還沒有聲明變量。

聲明所有這些變量並在局部變量的情況下將它們初始化爲默認值。

int my_pe = 0; 

對所有其他變量做同樣的事情。