尝试编译和编程,这将帮助我对机器之间的消息传递进行基准测试,但我得到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,所以我对错误感到困惑
EDIT ::
是的,代码来自谷歌,我希望它能帮助我理解它是如何工作的,所以我可以使用其他一些代码的位
这就是目前的情况:
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 :(得分:5)
没有定义任何变量。看起来像经典的复制/粘贴 定义变量并使用Eclipse。
答案 1 :(得分:2)
您尚未声明变量。
声明所有这些变量,并在局部变量的情况下将它们初始化为默认值。
int my_pe = 0;
对所有其他变量执行相同操作。