Search in sources :

Example 6 with DataBuffer

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

Example 7 with DataBuffer

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));
    }
}
Also used : TCPMessage(edu.iu.dsc.tws.common.net.tcp.TCPMessage) DataBuffer(edu.iu.dsc.tws.api.comms.packing.DataBuffer)

Example 8 with DataBuffer

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));
    }
}
Also used : TCPMessage(edu.iu.dsc.tws.common.net.tcp.TCPMessage) ChannelMessage(edu.iu.dsc.tws.api.comms.messaging.ChannelMessage) DataBuffer(edu.iu.dsc.tws.api.comms.packing.DataBuffer)

Example 9 with DataBuffer

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;
}
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)

Example 10 with DataBuffer

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;
}
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) ChannelMessage(edu.iu.dsc.tws.api.comms.messaging.ChannelMessage) DataBuffer(edu.iu.dsc.tws.api.comms.packing.DataBuffer)

Aggregations

DataBuffer (edu.iu.dsc.tws.api.comms.packing.DataBuffer)23 ChannelMessage (edu.iu.dsc.tws.api.comms.messaging.ChannelMessage)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 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 DataPacker (edu.iu.dsc.tws.api.comms.packing.DataPacker)4 MessageType (edu.iu.dsc.tws.api.comms.messaging.types.MessageType)2 TCPMessage (edu.iu.dsc.tws.common.net.tcp.TCPMessage)2 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)2 Request (mpi.Request)2 ChannelListener (edu.iu.dsc.tws.api.comms.channel.ChannelListener)1 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)1 DataDeserializer (edu.iu.dsc.tws.comms.dfw.io.DataDeserializer)1 DataSerializer (edu.iu.dsc.tws.comms.dfw.io.DataSerializer)1 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)1 ByteBuffer (java.nio.ByteBuffer)1 Queue (java.util.Queue)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1