use of edu.iu.dsc.tws.api.comms.messaging.ChannelMessage in project twister2 by DSC-SPIDAL.
the class TWSMPIChannel method postMessage.
/**
* Send a message to the given rank.
*
* @param requests the message
*/
private void postMessage(MPISendRequests requests) {
ChannelMessage message = requests.message;
for (int i = 0; i < message.getNormalBuffers().size(); i++) {
try {
sendCount++;
DataBuffer buffer = message.getNormalBuffers().get(i);
Request request = comm.iSend(buffer.getByteBuffer(), buffer.getSize(), MPI.BYTE, requests.rank, message.getHeader().getEdge());
// register to the loop to make communicationProgress on the send
requests.pendingSends.add(new MPIRequest(request, buffer));
} catch (MPIException e) {
throw new RuntimeException("Failed to send message to rank: " + requests.rank);
}
}
}
use of edu.iu.dsc.tws.api.comms.messaging.ChannelMessage in project twister2 by DSC-SPIDAL.
the class BaseSerializeTest method keyedSingleValueCase.
public InMessage keyedSingleValueCase(int numBuffers, int size, MessageType type, MessageType keyType, Object data) {
BlockingQueue<DataBuffer> bufferQueue = createDataQueue(numBuffers, size);
OutMessage outMessage = new OutMessage(0, 1, -1, 10, 0, null, null, type, keyType, null, data);
KeyedDataSerializer serializer = new KeyedDataSerializer();
serializer.init(Config.newBuilder().build(), bufferQueue);
List<ChannelMessage> messages = new ArrayList<>();
while (outMessage.getSendState() != OutMessage.SendState.SERIALIZED) {
ChannelMessage ch = serializer.build(data, outMessage);
messages.add(ch);
}
KeyedDataDeSerializer deserializer = new KeyedDataDeSerializer();
deserializer.init(Config.newBuilder().build());
MessageHeader header = deserializer.buildHeader(messages.get(0).getBuffers().get(0), 1);
InMessage inMessage = new InMessage(0, type, null, header);
inMessage.setKeyType(keyType);
for (ChannelMessage channelMessage : messages) {
for (DataBuffer dataBuffer : channelMessage.getBuffers()) {
inMessage.addBufferAndCalculate(dataBuffer);
}
}
deserializer.build(inMessage, 1);
return inMessage;
}
Aggregations