Skip to content

Commit

Permalink
Fixes MPI compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
lesquoyb committed Feb 22, 2024
1 parent 6779ee1 commit b2d7616
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions femto_st.gama.mpi/src/femto_st/gama/mpi/MPISkill.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import msi.gama.util.IList;
import msi.gaml.skills.Skill;
import msi.gaml.types.IType;
import ummisco.gama.serializer.factory.StreamConverter;
import java.util.Arrays;
import ummisco.gama.serializer.implementations.BinarySerialisation;

@vars ({ @variable (
name = IMPISkill.MPI_RANK,
Expand Down Expand Up @@ -145,38 +144,38 @@ public int getMPIRANK(final IScope scope) {
returns = "",
examples = { @example ("") }))
public void send(final IScope scope) {

System.out.println("xxxxxHHHHxxxxxx ");
final IList mesg = (IList) scope.getArg(IMPISkill.MESG, IType.LIST);
final int dest = ((Integer) scope.getArg(IMPISkill.DEST, IType.INT)).intValue();
final int stag = ((Integer) scope.getArg(IMPISkill.STAG, IType.INT)).intValue();

System.out.println("mesg = " + mesg);
System.out.println("dest = " + dest);
System.out.println("stag = " + stag);


String conversion = StreamConverter.convertNetworkObjectToStream(scope, mesg);
System.out.println("xxxxxxxxxxx " +conversion);

final byte[] message = StreamConverter.convertNetworkObjectToStream(scope, mesg).getBytes();
final int[] size = new int[1];
size[0] = message.length;


System.out.println("size of message : "+size[0]);
try {
System.out.println("send size: "+Arrays.toString(size));
MPI.COMM_WORLD.send(size, 1, MPI.INT, dest, stag);
System.out.println("send message: "+message.length);
MPI.COMM_WORLD.send(message, message.length, MPI.BYTE, dest, stag);
System.out.println("end try");

} catch (final MPIException mpiex) {
System.out.println("MPI send Error" + mpiex);
}

System.out.println("End send ");
// TODO: not working but needed to compile
// System.out.println("xxxxxHHHHxxxxxx ");
// final IList mesg = (IList) scope.getArg(IMPISkill.MESG, IType.LIST);
// final int dest = ((Integer) scope.getArg(IMPISkill.DEST, IType.INT)).intValue();
// final int stag = ((Integer) scope.getArg(IMPISkill.STAG, IType.INT)).intValue();
//
// System.out.println("mesg = " + mesg);
// System.out.println("dest = " + dest);
// System.out.println("stag = " + stag);
//
//
// String conversion = StreamConverter.convertNetworkObjectToStream(scope, mesg);
// System.out.println("xxxxxxxxxxx " +conversion);
//
// final byte[] message = StreamConverter.convertNetworkObjectToStream(scope, mesg).getBytes();
// final int[] size = new int[1];
// size[0] = message.length;
//
//
// System.out.println("size of message : "+size[0]);
// try {
// System.out.println("send size: "+Arrays.toString(size));
// MPI.COMM_WORLD.send(size, 1, MPI.INT, dest, stag);
// System.out.println("send message: "+message.length);
// MPI.COMM_WORLD.send(message, message.length, MPI.BYTE, dest, stag);
// System.out.println("end try");
//
// } catch (final MPIException mpiex) {
// System.out.println("MPI send Error" + mpiex);
// }
//
// System.out.println("End send ");
}

@action (
Expand Down Expand Up @@ -219,7 +218,8 @@ public IList recv(final IScope scope) {

System.out.println("Before rcvMesg");

final IList rcvMesg = (IList) StreamConverter.convertNetworkStreamToObject(scope, new String(message));
//TODO: probably breaking but needed to compile
final IList rcvMesg = (IList)BinarySerialisation.createFromString(scope, new String(message));
System.out.println("rcvMesg "+rcvMesg);

return rcvMesg;
Expand Down

0 comments on commit b2d7616

Please sign in to comment.