gpt4 book ai didi

java - 我以前从未见过 MPJ Express 错误

转载 作者:行者123 更新时间:2023-12-01 04:45:05 26 4
gpt4 key购买 nike

我收到此运行时错误:

MPJ 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

不明白什么意思

这是导致它的代码:

import mpi.* ;

class PingPongVariousLengths {

static public void main(String[] args) {

MPI.Init(args);
int myrank = MPI.COMM_WORLD.Rank();
int tag = 99;
int maxlen = 104857600; //200 megabytes 104857600 characters * 2 bytes per character = 209715200 bytes total, or 200 megabytes
int minlen = 1; // 2 bytes
char [] sendbuff = new char [maxlen];
char [] recvbuff = new char [maxlen];
long speedKbps;
long speedMbps;
long durationseconds;
int MAX_LOOPS = 20;

for (int len = minlen; len <= maxlen; len *= 2) {
if (myrank == 0) {
durationseconds = 0;
for (int i = 0; i < MAX_LOOPS; i++) {
long startTime = System.nanoTime();
MPI.COMM_WORLD.Send(sendbuff, 0, len, MPI.CHAR, 1, tag);
MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 1, tag);
long endTime = System.nanoTime();
long duration = endTime - startTime;
durationseconds = durationseconds + (duration* 10-9);
}
durationseconds = durationseconds / MAX_LOOPS;
System.out.println("Average time for the ping to be sent and recived of " + (len*2) + " bytes is " + durationseconds + " seconds");
double transferRateMb = ((len*524288.0) / durationseconds );
System.out.println("average transferRate (megabytes) : " + transferRateMb + " megabytes per second");
} else if (myrank == 1) {
MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 0, tag);
MPI.COMM_WORLD.Send(recvbuff, 0, len, MPI.CHAR, 0, tag);
}
}

MPI.Finalize();
}
}

导致错误的原因以及如何解决?

编辑TTTT

将最小长度更改为 2

import mpi.* ;

class PingPongVariousLengths {

static public void main(String[] args) {

MPI.Init(args);
int myrank = MPI.COMM_WORLD.Rank();
int tag = 99;
int maxlen = 104857600; //200 megabytes 104857600 characters * 2 bytes per character = 209715200 bytes total, or 200 megabytes
int minlen = 2; // 2 bytes
char [] sendbuff = new char [maxlen];
char [] recvbuff = new char [maxlen];
long speedKbps;
long speedMbps;
long durationseconds;
int MAX_LOOPS = 20;

for (int len = minlen; len <= maxlen; len *= 2) {//len=*2 doubles the ping size each time
if (myrank == 0) {
durationseconds = 0;
for (int i = 0; i < MAX_LOOPS; i++) {
long startTime = System.nanoTime();
MPI.COMM_WORLD.Send(sendbuff, 0, len, MPI.CHAR, 1, tag);
MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 1, tag);
long endTime = System.nanoTime();
long duration = endTime - startTime;
durationseconds = durationseconds + (duration* 10-9);// Converts nanoseconds to seconds
}
durationseconds = durationseconds / MAX_LOOPS;
//double transferRate = ((len*2.0) / durationseconds ) ; //amount of data in bytes transferred in 1 second. Currently returning 0 for every result
//System.out.println("transferRate: " + transferRate + " bytes per second");
System.out.println("Average time for the ping to be sent and recived of " + (len*2) + " bytes is " + durationseconds + " seconds");
double transferRateMb = ((len*524288.0) / durationseconds );
System.out.println("average transferRate (megabytes) : " + transferRateMb + " megabytes per second");
} else if (myrank == 1) {
MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 0, tag);
MPI.COMM_WORLD.Send(recvbuff, 0, len, MPI.CHAR, 0, tag);
}
}

MPI.Finalize();
}
}

并且收到此错误:

PongVariousLengths
MPJ 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 <2> is less than length <4>
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:25)
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 <2> is less than length <4>
at mpi.Comm.Recv(Comm.java:1259)
at PingPongVariousLengths.main(PingPongVariousLengths.java:25)
... 6 more
Caused by: mpi.MPIException: mpi.MPIException: Error in SimplePacker : count <2>
is less than length <4>
at mpi.Comm.recv(Comm.java:1317)
at mpi.Comm.Recv(Comm.java:1255)
... 7 more
Caused by: mpi.MPIException: Error in SimplePacker : count <2> is less than leng
th <4>
at mpi.SimplePackerChar.unpack(SimplePackerChar.java:105)
at mpi.Comm.recv(Comm.java:1305)
... 8 more

编辑2

好吧,经过一番尝试和错误后,我在第 19 行注释掉了 '//len *= 2)',注释掉后,程序会运行,但它会持续以 2 个字节运行,并且不会停止在所需的 20 个循环之后,所以我认为这就是问题所在,但是如何解决这个问题?

最佳答案

您的异常似乎是由此 block of code: 引发的

  public void unpack(mpjbuf.Buffer mpjbuf, int length, Object buf,
int offset, int count) throws MPIException {

if(count * numEls < length) {
throw new MPIException ("Error in SimplePacker : count <"+
(count*numEls)+"> is less than length <"+length+">");
}

因此,count * numEls 似乎小于length。这一切似乎都会导致您的 Recv() 调用(我认为是第 29 行):

MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 1, tag);

MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 0, tag);

因此“计数”(len) 小于长度(即 2)。您将 minlen 设置为 1(不是像评论所说的“2”),请尝试将其设置为 2。

关于java - 我以前从未见过 MPJ Express 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15994032/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com