【问题标题】:MPJ Express error I have never seen before我从未见过的 MPJ Express 错误
【发布时间】:2013-04-06 07:39:31
【问题描述】:

我收到此运行时错误:

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 个循环之后,所以我认为这是问题所在,但是如何解决呢?

【问题讨论】:

  • 只是符号 }
  • 你不应该以minlen = 2开头。
  • 我试过 minlen = 2,同样的错误,它是 1 因为 1 个字符是 2 个字节
  • @user2065929 错误说count1,如果你现在将count 传递为2,你怎么可能得到同样的错误。仔细检查您是否没有将1 作为count 传递到任何地方。
  • 啊抱歉,我还以为你说的是​​别的,我没有改计数,现在试试

标签: java mpi


【解决方案1】:

这个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(这不是 cmets 所说的“2”),请尝试将其设置为 2。

【讨论】:

  • 即使在调整计数后他声称得到了同样的错误:>
  • 将错误与当前代码一起添加到原始问题中
  • 好的添加了另一个编辑,我想我已经找到了问题但不确定如何解决它
【解决方案2】:

您的代码的主要问题是您错过了在rank=1 的进程中从i=0 运行到MAX_LOOP 的内部循环。由于外部循环的长度不同,您的rank=0 进程正在发送len=2 的消息,而rank=1 的进程正在期待len=4 的消息,因为它在下一个外部循环迭代中。如果您插入打印语句,您将看到您的第一条消息已成功完成。但是对于第二次迭代,它的长度是不匹配的。这是代码修复:

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();
                        System.out.println("Processor 0 printing len="+len);
                        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) {
                for(int i =0; i < MAX_LOOPS; i++){
                        System.out.println("Processor 1 printing len="+len);
                        MPI.COMM_WORLD.Recv(recvbuff, 0, len, MPI.CHAR, 0, tag);
                        MPI.COMM_WORLD.Send(recvbuff, 0, len, MPI.CHAR, 0, tag);
                }
        }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-18
    • 2012-12-21
    • 2015-07-04
    • 2016-07-21
    • 2014-09-06
    • 1970-01-01
    • 2020-07-30
    • 1970-01-01
    相关资源
    最近更新 更多