Hello, > #3351: JAVA scatter error > ---------------------+----------------------------- > Reporter: rhc | Owner: jsquyres > Type: defect | Status: closed > Priority: critical | Milestone: Open MPI 1.7.1 > Version: trunk | Resolution: invalid > Keywords: | > ---------------------+----------------------------- > Changes (by jsquyres): > > * status: new => closed > * resolution: => invalid > > > Comment: > > I do not believe that the sample code provided is a valid MPI program, for > two reasons (disclaimer: I do ''not'' know Java -- I'm just reading the > code and making some assumptions about Java): > > 1. The datatypes passed to Scatter are not valid MPI datatypes > (MPI.OBJECT). You need to construct a datatype that is specific to the > !MyData class, just like you would in C/C++. I think that this is the > first error that you are seeing (i.e., that OMPI is trying to treat > MPI.OBJECT as an MPI Datatype object, and failing (and therefore throwing > an !ClassCastException exception).
Perhaps you are right and my small example program ist not a valid MPI program. The problem is that I couldn't find any good documentation or example programs how to write a program which uses a structured data type. Therefore I sticked to the mpiJava specification which states for derived datatypes in chapter 3.12 that the effect for MPI_Type_struct can be achieved by using MPI.OBJECT as the buffer type and relying on Java object serialization. "dataItem" is a serializable Java object and I used MPI.OBJECT as buffer type. How can I create a valid MPI datatype MPI.OBJECT so that I get a working example program? MPI.COMM_WORLD.Scatter (dataItem, 0, 1, MPI.OBJECT, objBuffer, 0, 1, MPI.OBJECT, 0); > 1. It looks like you're trying to Scatter a single object to N peers. > That's invalid MPI -- you need to scatter (N*M) objects to N peers, where > M is a positive integer value (e.g., 1 or 2). Are you trying to > broadcast? It is the very first version of the program where I scatter one object to the process itself (at this point it is not the normal application area for scatter, but should nevertheless work). I didn't continue due to the error. I get the same error when I broadcast my data item. tyr java 116 mpiexec -np 1 java -cp $DIRPREFIX_LOCAL/mpi_classfiles \ ObjectScatterMain Exception in thread "main" java.lang.ClassCastException: MyData cannot be cast to [Ljava.lang.Object; at mpi.Intracomm.copyBuffer(Intracomm.java:119) at mpi.Intracomm.Scatter(Intracomm.java:389) at ObjectScatterMain.main(ObjectScatterMain.java:45) "Broadcast" works if I have only a root process and it fails when I have one more process. tyr java 117 mpiexec -np 1 java -cp $DIRPREFIX_LOCAL/mpi_classfiles \ ObjectBroadcastMain Process 0 running on tyr.informatik.hs-fulda.de. Age: 35 Name: Smith Salary: 2545.75 tyr java 118 mpiexec -np 2 java -cp $DIRPREFIX_LOCAL/mpi_classfiles \ ObjectBroadcastMain Exception in thread "main" java.lang.ClassCastException: MyData cannot be cast to [Ljava.lang.Object; at mpi.Comm.Object_Serialize(Comm.java:207) at mpi.Comm.Send(Comm.java:292) at mpi.Intracomm.Bcast(Intracomm.java:202) at ObjectBroadcastMain.main(ObjectBroadcastMain.java:44) > Short version -- I don't think this bug is valid. I'm closing the ticket. If I misunderstood the mpiJava specification and I must create a special MPI object from my Java object: How do I create it? Thank you very much for any help in advance. Kind regards Siegmar
ObjectBroadcastMain.java
Description: ObjectBroadcastMain.java
MyData.java
Description: MyData.java