use of edu.iu.dsc.tws.api.comms.packing.DataBuffer in project twister2 by DSC-SPIDAL.
the class TWSMPIChannel method postReceive.
private void postReceive(MPIReceiveRequests requests) {
DataBuffer byteBuffer = requests.availableBuffers.poll();
while (byteBuffer != null) {
// post the receive
pendingReceiveCount++;
Request request = postReceive(requests.rank, requests.edge, byteBuffer);
requests.pendingRequests.add(new MPIRequest(request, byteBuffer));
byteBuffer = requests.availableBuffers.poll();
}
}
use of edu.iu.dsc.tws.api.comms.packing.DataBuffer in project twister2 by DSC-SPIDAL.
the class TWSTCPChannel method postReceive.
private void postReceive(TCPReceiveRequests requests) {
DataBuffer byteBuffer = requests.availableBuffers.poll();
if (byteBuffer != null) {
// post the receive
TCPMessage request = postReceive(requests.rank, requests.edge, byteBuffer);
requests.pendingRequests.add(new Request(request, byteBuffer));
}
}
use of edu.iu.dsc.tws.api.comms.packing.DataBuffer in project twister2 by DSC-SPIDAL.
the class TWSTCPChannel method postMessage.
/**
* Send a message to the given rank.
*
* @param requests the message
*/
private void postMessage(TCPSendRequests requests) {
ChannelMessage message = requests.message;
for (int i = 0; i < message.getNormalBuffers().size(); i++) {
sendCount++;
DataBuffer buffer = message.getNormalBuffers().get(i);
TCPMessage request = channel.iSend(buffer.getByteBuffer(), buffer.getSize(), requests.rank, message.getHeader().getEdge());
// register to the loop to make communicationProgress on the send
requests.pendingSends.add(new Request(request, buffer));
}
}
use of edu.iu.dsc.tws.api.comms.packing.DataBuffer in project twister2 by DSC-SPIDAL.
the class BaseSerializeTest method keyedListValueCase.
public InMessage keyedListValueCase(int numBuffers, int size, List<Object> data, MessageType type, MessageType keyType) {
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;
}
use of edu.iu.dsc.tws.api.comms.packing.DataBuffer in project twister2 by DSC-SPIDAL.
the class KeyedSerializerLargeTest method keyedListValueCase.
public InMessage keyedListValueCase(int numBuffers, int size, List<Object> data, MessageType type, MessageType keyType) {
OutMessage outMessage = new OutMessage(0, 1, -1, 10, 0, null, null, type, keyType, null, data);
List<ChannelMessage> messages = new ArrayList<>();
int count = 0;
while (outMessage.getSendState() != OutMessage.SendState.SERIALIZED) {
ChannelMessage ch = serializer.build(data, outMessage);
messages.add(ch);
System.out.println("Adding count " + count++);
}
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);
for (ChannelMessage d : inMessage.getBuiltMessages()) {
for (DataBuffer buffer : d.getNormalBuffers()) {
buffer.getByteBuffer().clear();
bufferQueue.offer(buffer);
}
}
return inMessage;
}
Aggregations