【发布时间】:2015-06-30 06:47:36
【问题描述】:
我试图在 JDK 中编译下面的代码,但它似乎没有编译,我得到错误不是第 41 行的语句,即使它是。
导致错误的行是:
long endTime = System.currentTimeMillis();
代码如下:
import mpi.*;
public class MultidimMatrix {
public static final int N = 10;
public static void main (String args[]){
MPI.Init(args);
long startTime = System.currentTimeMillis();
int rank = MPI.COMM_WORLD.Rank();
int size = MPI.COMM_WORLD.Size();
int tag = 10, peer = (rank==0) ? 1:0;
if(rank == 0) {
double [][] a = new double [N][N];
for(int i = 0; i < N; i++)
for(int j = 0; j < N; j++)
a[i][j] = 10.0;
Object[] sendObjectArray = new Object[1];
sendObjectArray[0] = (Object) a;
MPI.COMM_WORLD.Send(sendObjectArray, 0, 1, MPI.OBJECT, peer, tag);
} else if(rank == 1){
double [][] b = new double [N][N];
for(int i = 0; i < N; i++)
for(int j = 0; j < N; i++)
b[i][j] = 0;
Object[] recvObjectArray = new Object[1];
MPI.COMM_WORLD.Recv(recvObjectArray, 0, 1, MPI.OBJECT, peer, tag);
b = (double[][]) recvObjectArray[0];
for(int i = 0; i < 4; i++){
for(int j = 0; j < N; i++)
long endTime = System.currentTimeMillis();
System.out.print(b[i][j]+"\t");
System.out.println("\n");
System.out.println("Calculated in " +
(endTime - startTime) + " milliseconds");
}
}
MPI.Finalize() ;
}
}
非常感谢任何帮助!
【问题讨论】:
-
圣典格式化蝙蝠侠!
-
你能试试
import java.lang.*;吗? -
仍然出现错误。
-
编辑您发布的代码,重新正确格式化并再次发布 - 也许我们可以提供帮助。目前,可怕的未格式化代码和“出错”并没有提供帮助的动力。
标签: java matrix mpi mpj-express