1

この実行時エラーが発生しています:

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

minlength を 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

OK、少し試行錯誤した後、19行目の「//len *= 2)」をコメントアウトしました。これをコメントアウトすると、プログラムは実行されますが、常に2バイトで実行され、必要な後に停止しませんでした20ループなので、これが問題だと思いますが、どうすれば解決できますか?

4

2 に答える 2

0

あなたの例外は、このコードブロックによってスローされたようです:

  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よりも小さいようですlengthRecv()そして、それはすべてあなたの呼び出しにつながるようです(私は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) よりも小さくなります。1にminlen設定しました (コメントのように「2」ではありません)。代わりに 2 に設定してみてください。

于 2013-04-13T23:48:26.113 に答える
0

コードの主な問題は、プロセスでからi=0まで実行される内部ループを見逃したことです。外側のループは長さが変化するため、次の外側のループ反復にあるため、プロセスがメッセージを期待している間、プロセスはメッセージを送信しています。print ステートメントを挿入すると、最初のメッセージが正常に完了したことがわかります。しかし、2 回目の繰り返しでは、長さが一致しません。コード修正は次のとおりです。MAX_LOOPrank=1rank=0len=2rank=1len=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);
                }
        }
}
于 2015-02-10T22:31:59.923 に答える