Search in sources :

Example 16 with ChannelMessage

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);
        }
    }
}
Also used : MPIException(mpi.MPIException) Request(mpi.Request) ChannelMessage(edu.iu.dsc.tws.api.comms.messaging.ChannelMessage) DataBuffer(edu.iu.dsc.tws.api.comms.packing.DataBuffer)

Example 17 with ChannelMessage

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;
}
Also used : OutMessage(edu.iu.dsc.tws.comms.dfw.OutMessage) ArrayList(java.util.ArrayList) InMessage(edu.iu.dsc.tws.comms.dfw.InMessage) MessageHeader(edu.iu.dsc.tws.api.comms.messaging.MessageHeader) DataBuffer(edu.iu.dsc.tws.api.comms.packing.DataBuffer) ChannelMessage(edu.iu.dsc.tws.api.comms.messaging.ChannelMessage)

Aggregations

ChannelMessage (edu.iu.dsc.tws.api.comms.messaging.ChannelMessage)17 DataBuffer (edu.iu.dsc.tws.api.comms.packing.DataBuffer)14 MessageHeader (edu.iu.dsc.tws.api.comms.messaging.MessageHeader)10 InMessage (edu.iu.dsc.tws.comms.dfw.InMessage)10 ArrayList (java.util.ArrayList)9 OutMessage (edu.iu.dsc.tws.comms.dfw.OutMessage)7 DataPacker (edu.iu.dsc.tws.api.comms.packing.DataPacker)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 MessageType (edu.iu.dsc.tws.api.comms.messaging.types.MessageType)2 ChannelListener (edu.iu.dsc.tws.api.comms.channel.ChannelListener)1 TCPMessage (edu.iu.dsc.tws.common.net.tcp.TCPMessage)1 DataDeserializer (edu.iu.dsc.tws.comms.dfw.io.DataDeserializer)1 DataSerializer (edu.iu.dsc.tws.comms.dfw.io.DataSerializer)1 Queue (java.util.Queue)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 MPIException (mpi.MPIException)1 Request (mpi.Request)1 Test (org.junit.Test)1