JAVA循环问题

时间:2013-04-15 13:13:28

标签: java mpi

大家好我的代码循环问题,我要做的是运行一段代码20次,跟踪所用的时间,然后计算平均值除以20

此处的代码目前无效:

edit

它给了我以下错误:

PJ Express (0.35) is started in the cluster configuration
Starting process <0> on <Tornado>
Starting process <1> on <Predator>
mpi.MPIException: Error in SimplePacker : count <1> is less than length <2>
        at mpi.SimplePackerChar.unpack(SimplePackerChar.java:105)
        at mpi.Comm.recv(Comm.java:1305)
        at mpi.Comm.Recv(Comm.java:1255)
        at PingPongVariousLengths.main(PingPongVariousLengths.java:29)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at runtime.daemon.Wrapper.execute(Wrapper.java:165)
        at runtime.daemon.Wrapper.main(Wrapper.java:180)
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at runtime.daemon.Wrapper.execute(Wrapper.java:165)
        at runtime.daemon.Wrapper.main(Wrapper.java:180)
Caused by: mpi.MPIException: mpi.MPIException: mpi.MPIException: Error in Simple
Packer : count <1> is less than length <2>
        at mpi.Comm.Recv(Comm.java:1259)
        at PingPongVariousLengths.main(PingPongVariousLengths.java:29)
        ... 6 more
Caused by: mpi.MPIException: mpi.MPIException: Error in SimplePacker : count <1>
 is less than length <2>
        at mpi.Comm.recv(Comm.java:1317)
        at mpi.Comm.Recv(Comm.java:1255)
        ... 7 more
Caused by: mpi.MPIException: Error in SimplePacker : count <1> is less than leng
th <2>
        at mpi.SimplePackerChar.unpack(SimplePackerChar.java:105)
        at mpi.Comm.recv(Comm.java:1305)
        ... 8 more

然而,在添加循环之前,我有这个代码,它工作正常:

修改

是什么导致程序中的循环给出错误消息,我该如何解决这个问题?

谢谢

1 个答案:

答案 0 :(得分:1)

错误在SimplePacker中,并抛出MPIException。 你能提供一些你的SimplePacker编码器,它可以在MPI.Rec() - 方法中调用吗?