use of edu.iu.dsc.tws.api.comms.packing.DataBuffer 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.packing.DataBuffer in project twister2 by DSC-SPIDAL.
the class TWSUCXChannel method sendMessage.
@Override
public boolean sendMessage(int id, ChannelMessage message, ChannelListener callback) {
AtomicInteger buffersLeft = new AtomicInteger(message.getBuffers().size());
for (DataBuffer buffer : message.getBuffers()) {
buffer.getByteBuffer().limit(buffer.getSize());
buffer.getByteBuffer().position(0);
int tag = this.workerId * tagWIdOffset + message.getHeader().getEdge();
LOG.log(Level.FINE, () -> String.format("SENDING to %d[%d] : %s, TAG[%d]", id, message.getHeader().getEdge(), buffer.getByteBuffer(), tag));
this.endpoints.get(id).sendTaggedNonBlocking(buffer.getByteBuffer(), tag, new UcxCallback() {
@Override
public void onSuccess(UcpRequest request) {
pendingSendRequests.decrementAndGet();
if (buffersLeft.decrementAndGet() == 0) {
callback.onSendComplete(id, message.getHeader().getEdge(), message);
}
}
@Override
public void onError(int ucsStatus, String errorMsg) {
// This is a catastrophic failure
LOG.severe("UCX send request failed to worker " + id + " with status " + ucsStatus + ". Error : " + errorMsg);
throw new Twister2RuntimeException("Send request to worker : " + id + " failed. " + errorMsg);
}
});
this.pendingSendRequests.incrementAndGet();
}
return true;
}
use of edu.iu.dsc.tws.api.comms.packing.DataBuffer 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