2013-04-13 34 views
1

我得到這個運行時的錯誤,我從來沒有見過:MPJ快遞錯誤之前

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(); 
    } 
} 

什麼是導致錯誤,如何解決?

EDITTTTT

改變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 

EDIT 2

好了,在第19行註釋掉了'// len * = 2'',這個註釋掉了,程序會運行,但它運行con穩定在2字節,並沒有停止所需的20循環後,所以我認爲這是問題,但如何解決這個問題?

+0

哪一行是29行? – Kevin

+0

它只是符號} – user2065929

+0

不應該以'minlen = 2'開頭。 – Esailija

回答

0

你的例外似乎是由這個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。

+0

即使調整計數後,他聲稱也會得到相同的錯誤:> – Esailija

+0

將錯誤添加到原始問題以及當前代碼 – user2065929

+0

確定添加了另一個編輯,我認爲我已經找到了問題,但不確定如何解決它 – user2065929

0

你的代碼的主要問題是你錯過了一個從i=0運行到MAX_LOOPrank=1處理的內循環。由於外循環長度不同,因此使用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); 
       } 
     } 
}