Search in sources :

Example 1 with MessageDeSerializer

use of edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer in project twister2 by DSC-SPIDAL.

the class MPIDataFlowPartition method init.

/**
 * Initialize
 */
public void init(Config cfg, MessageType t, TaskPlan taskPlan, int edge) {
    this.thisSources = TaskPlanUtils.getTasksOfThisExecutor(taskPlan, sources);
    LOG.info(String.format("%d setup loadbalance routing %s", taskPlan.getThisExecutor(), thisSources));
    this.thisTasks = taskPlan.getTasksOfThisExecutor();
    this.router = new PartitionRouter(taskPlan, sources, destinations);
    Map<Integer, Set<Integer>> internal = router.getInternalSendTasks(0);
    Map<Integer, Set<Integer>> external = router.getExternalSendTasks(0);
    this.instancePlan = taskPlan;
    this.type = t;
    LOG.log(Level.FINE, String.format("%d adding internal/external routing", taskPlan.getThisExecutor()));
    for (int s : thisSources) {
        Set<Integer> integerSetMap = internal.get(s);
        if (integerSetMap != null) {
            this.dests.internal.addAll(integerSetMap);
        }
        Set<Integer> integerSetMap1 = external.get(s);
        if (integerSetMap1 != null) {
            this.dests.external.addAll(integerSetMap1);
        }
        LOG.fine(String.format("%d adding internal/external routing %d", taskPlan.getThisExecutor(), s));
        break;
    }
    LOG.log(Level.FINE, String.format("%d done adding internal/external routing", taskPlan.getThisExecutor()));
    // TODO : Does this send the correct receiveExpectedTaskIds for partition communication
    if (this.finalReceiver != null && isLastReceiver()) {
        this.finalReceiver.init(cfg, this, receiveExpectedTaskIds());
    }
    Map<Integer, ArrayBlockingQueue<Pair<Object, MPISendMessage>>> pendingSendMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<Pair<Object, MPIMessage>>> pendingReceiveMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<MPIMessage>> pendingReceiveDeSerializations = new HashMap<>();
    Map<Integer, MessageSerializer> serializerMap = new HashMap<>();
    Map<Integer, MessageDeSerializer> deSerializerMap = new HashMap<>();
    Set<Integer> srcs = TaskPlanUtils.getTasksOfThisExecutor(taskPlan, sources);
    for (int s : srcs) {
        // later look at how not to allocate pairs for this each time
        ArrayBlockingQueue<Pair<Object, MPISendMessage>> pendingSendMessages = new ArrayBlockingQueue<Pair<Object, MPISendMessage>>(MPIContext.sendPendingMax(cfg));
        pendingSendMessagesPerSource.put(s, pendingSendMessages);
        serializerMap.put(s, new MPIMessageSerializer(new KryoSerializer()));
    }
    int maxReceiveBuffers = MPIContext.receiveBufferCount(cfg);
    int receiveExecutorsSize = receivingExecutors().size();
    if (receiveExecutorsSize == 0) {
        receiveExecutorsSize = 1;
    }
    Set<Integer> execs = router.receivingExecutors();
    for (int e : execs) {
        int capacity = maxReceiveBuffers * 2 * receiveExecutorsSize;
        Queue<Pair<Object, MPIMessage>> pendingReceiveMessages = new ArrayBlockingQueue<Pair<Object, MPIMessage>>(capacity);
        pendingReceiveMessagesPerSource.put(e, pendingReceiveMessages);
        pendingReceiveDeSerializations.put(e, new ArrayBlockingQueue<MPIMessage>(capacity));
        deSerializerMap.put(e, new MPIMessageDeSerializer(new KryoSerializer()));
    }
    for (int src : srcs) {
        for (int dest : destinations) {
            sendRoutingParameters(src, dest);
        }
    }
    delegete.setCompletionListener(completionListener);
    delegete.init(cfg, t, taskPlan, edge, router.receivingExecutors(), router.isLastReceiver(), this, pendingSendMessagesPerSource, pendingReceiveMessagesPerSource, pendingReceiveDeSerializations, serializerMap, deSerializerMap, isKeyed);
    delegete.setKeyType(keyType);
}
Also used : Set(java.util.Set) MPIMessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer) MessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageSerializer) MPIMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer) HashMap(java.util.HashMap) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) PartitionRouter(edu.iu.dsc.tws.comms.routing.PartitionRouter) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Queue(java.util.Queue) Pair(org.apache.commons.lang3.tuple.Pair) KryoSerializer(edu.iu.dsc.tws.comms.utils.KryoSerializer) MPIMessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer) MessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer) MPIMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer)

Example 2 with MessageDeSerializer

use of edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer in project twister2 by DSC-SPIDAL.

the class MPIDirectDataFlowCommunication method init.

/**
 * Initialize
 * @param cfg
 * @param t
 * @param taskPlan
 * @param edge
 */
public void init(Config cfg, MessageType t, TaskPlan taskPlan, int edge) {
    this.router = new DirectRouter(taskPlan, sources, destination);
    if (this.finalReceiver != null && isLastReceiver()) {
        this.finalReceiver.init(cfg, this, receiveExpectedTaskIds());
    }
    Map<Integer, ArrayBlockingQueue<Pair<Object, MPISendMessage>>> pendingSendMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<Pair<Object, MPIMessage>>> pendingReceiveMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<MPIMessage>> pendingReceiveDeSerializations = new HashMap<>();
    Map<Integer, MessageSerializer> serializerMap = new HashMap<>();
    Map<Integer, MessageDeSerializer> deSerializerMap = new HashMap<>();
    Set<Integer> srcs = TaskPlanUtils.getTasksOfThisExecutor(taskPlan, sources);
    for (int s : srcs) {
        // later look at how not to allocate pairs for this each time
        ArrayBlockingQueue<Pair<Object, MPISendMessage>> pendingSendMessages = new ArrayBlockingQueue<Pair<Object, MPISendMessage>>(MPIContext.sendPendingMax(cfg));
        pendingSendMessagesPerSource.put(s, pendingSendMessages);
        pendingReceiveDeSerializations.put(s, new ArrayBlockingQueue<MPIMessage>(MPIContext.sendPendingMax(cfg)));
        serializerMap.put(s, new MPIMessageSerializer(new KryoSerializer()));
    }
    MessageDeSerializer messageDeSerializer = new MPIMessageDeSerializer(new KryoSerializer());
    deSerializerMap.put(destination, messageDeSerializer);
    delegete.init(cfg, t, taskPlan, edge, router.receivingExecutors(), isLastReceiver(), this, pendingSendMessagesPerSource, pendingReceiveMessagesPerSource, pendingReceiveDeSerializations, serializerMap, deSerializerMap, false);
}
Also used : MPIMessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer) MPIMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer) MessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageSerializer) HashMap(java.util.HashMap) DirectRouter(edu.iu.dsc.tws.comms.routing.DirectRouter) KryoSerializer(edu.iu.dsc.tws.comms.utils.KryoSerializer) MPIMessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer) MessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer) MPIMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Queue(java.util.Queue) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with MessageDeSerializer

use of edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer in project twister2 by DSC-SPIDAL.

the class MPIDataFlowGather method init.

/**
 * Initialize
 * @param cfg
 * @param t
 * @param taskPlan
 * @param edge
 */
public void init(Config cfg, MessageType t, TaskPlan taskPlan, int edge) {
    this.type = t;
    this.instancePlan = taskPlan;
    this.executor = taskPlan.getThisExecutor();
    // we only have one path
    this.router = new InvertedBinaryTreeRouter(cfg, taskPlan, destination, sources, index);
    // initialize the receive
    if (this.partialReceiver != null && !isLastReceiver()) {
        partialReceiver.init(cfg, this, receiveExpectedTaskIds());
    }
    if (this.finalReceiver != null && isLastReceiver()) {
        this.finalReceiver.init(cfg, this, receiveExpectedTaskIds());
    }
    Map<Integer, ArrayBlockingQueue<Pair<Object, MPISendMessage>>> pendingSendMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<Pair<Object, MPIMessage>>> pendingReceiveMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<MPIMessage>> pendingReceiveDeSerializations = new HashMap<>();
    Map<Integer, MessageSerializer> serializerMap = new HashMap<>();
    Map<Integer, MessageDeSerializer> deSerializerMap = new HashMap<>();
    Set<Integer> srcs = router.sendQueueIds();
    for (int s : srcs) {
        // later look at how not to allocate pairs for this each time
        ArrayBlockingQueue<Pair<Object, MPISendMessage>> pendingSendMessages = new ArrayBlockingQueue<Pair<Object, MPISendMessage>>(MPIContext.sendPendingMax(cfg));
        pendingSendMessagesPerSource.put(s, pendingSendMessages);
        serializerMap.put(s, new MPIMultiMessageSerializer(new KryoSerializer(), executor));
    }
    int maxReceiveBuffers = MPIContext.receiveBufferCount(cfg);
    int receiveExecutorsSize = receivingExecutors().size();
    if (receiveExecutorsSize == 0) {
        receiveExecutorsSize = 1;
    }
    Set<Integer> execs = router.receivingExecutors();
    for (int e : execs) {
        int capacity = maxReceiveBuffers * 2 * receiveExecutorsSize;
        Queue<Pair<Object, MPIMessage>> pendingReceiveMessages = new ArrayBlockingQueue<Pair<Object, MPIMessage>>(capacity);
        pendingReceiveMessagesPerSource.put(e, pendingReceiveMessages);
        pendingReceiveDeSerializations.put(e, new ArrayBlockingQueue<MPIMessage>(capacity));
        deSerializerMap.put(e, new MPIMultiMessageDeserializer(new KryoSerializer(), executor));
    }
    Set<Integer> sourcesOfThisExec = TaskPlanUtils.getTasksOfThisExecutor(taskPlan, sources);
    for (int s : sourcesOfThisExec) {
        sendRoutingParameters(s, pathToUse);
        partialSendRoutingParameters(s, pathToUse);
    }
    delegete.init(cfg, t, taskPlan, edge, router.receivingExecutors(), router.isLastReceiver(), this, pendingSendMessagesPerSource, pendingReceiveMessagesPerSource, pendingReceiveDeSerializations, serializerMap, deSerializerMap, isKeyed);
    delegete.setKeyType(keyType);
}
Also used : MessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageSerializer) MPIMultiMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMultiMessageSerializer) HashMap(java.util.HashMap) MPIMultiMessageDeserializer(edu.iu.dsc.tws.comms.mpi.io.MPIMultiMessageDeserializer) KryoSerializer(edu.iu.dsc.tws.comms.utils.KryoSerializer) InvertedBinaryTreeRouter(edu.iu.dsc.tws.comms.routing.InvertedBinaryTreeRouter) MessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer) MPIMultiMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMultiMessageSerializer) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Queue(java.util.Queue) Pair(org.apache.commons.lang3.tuple.Pair)

Example 4 with MessageDeSerializer

use of edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer in project twister2 by DSC-SPIDAL.

the class MPIDataFlowReduce method init.

/**
 * Initialize
 * @param cfg
 * @param t
 * @param taskPlan
 * @param edge
 */
public void init(Config cfg, MessageType t, TaskPlan taskPlan, int edge) {
    this.instancePlan = taskPlan;
    this.config = cfg;
    this.type = t;
    this.executor = instancePlan.getThisExecutor();
    // we only have one path
    this.router = new InvertedBinaryTreeRouter(cfg, taskPlan, destination, sources, index);
    // initialize the receive
    if (this.partialReceiver != null && !isLastReceiver()) {
        partialReceiver.init(cfg, this, receiveExpectedTaskIds());
    }
    if (this.finalReceiver != null && isLastReceiver()) {
        this.finalReceiver.init(cfg, this, receiveExpectedTaskIds());
    }
    LOG.log(Level.FINE, String.format("%d reduce sources %s dest %d send tasks: %s", executor, sources, destination, router.sendQueueIds()));
    Map<Integer, ArrayBlockingQueue<Pair<Object, MPISendMessage>>> pendingSendMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<Pair<Object, MPIMessage>>> pendingReceiveMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<MPIMessage>> pendingReceiveDeSerializations = new HashMap<>();
    Map<Integer, MessageSerializer> serializerMap = new HashMap<>();
    Map<Integer, MessageDeSerializer> deSerializerMap = new HashMap<>();
    Set<Integer> srcs = router.sendQueueIds();
    for (int s : srcs) {
        // later look at how not to allocate pairs for this each time
        ArrayBlockingQueue<Pair<Object, MPISendMessage>> pendingSendMessages = new ArrayBlockingQueue<Pair<Object, MPISendMessage>>(MPIContext.sendPendingMax(cfg));
        pendingSendMessagesPerSource.put(s, pendingSendMessages);
        serializerMap.put(s, new MPIMessageSerializer(new KryoSerializer()));
    }
    int maxReceiveBuffers = MPIContext.receiveBufferCount(cfg);
    int receiveExecutorsSize = receivingExecutors().size();
    if (receiveExecutorsSize == 0) {
        receiveExecutorsSize = 1;
    }
    Set<Integer> execs = router.receivingExecutors();
    for (int e : execs) {
        int capacity = maxReceiveBuffers * 2 * receiveExecutorsSize;
        Queue<Pair<Object, MPIMessage>> pendingReceiveMessages = new ArrayBlockingQueue<Pair<Object, MPIMessage>>(capacity);
        pendingReceiveMessagesPerSource.put(e, pendingReceiveMessages);
        pendingReceiveDeSerializations.put(e, new ArrayBlockingQueue<MPIMessage>(capacity));
        deSerializerMap.put(e, new MPIMessageDeSerializer(new KryoSerializer()));
    }
    Set<Integer> sourcesOfThisExec = TaskPlanUtils.getTasksOfThisExecutor(taskPlan, sources);
    for (int s : sourcesOfThisExec) {
        sendRoutingParameters(s, pathToUse);
        partialSendRoutingParameters(s, pathToUse);
    }
    this.delegete.setCompletionListener(completionListener);
    delegete.init(cfg, t, taskPlan, edge, router.receivingExecutors(), router.isLastReceiver(), this, pendingSendMessagesPerSource, pendingReceiveMessagesPerSource, pendingReceiveDeSerializations, serializerMap, deSerializerMap, false);
}
Also used : MPIMessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer) MessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageSerializer) MPIMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer) HashMap(java.util.HashMap) KryoSerializer(edu.iu.dsc.tws.comms.utils.KryoSerializer) InvertedBinaryTreeRouter(edu.iu.dsc.tws.comms.routing.InvertedBinaryTreeRouter) MPIMessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer) MessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer) MPIMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Queue(java.util.Queue) Pair(org.apache.commons.lang3.tuple.Pair)

Example 5 with MessageDeSerializer

use of edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer in project twister2 by DSC-SPIDAL.

the class MPIDataFlowBroadcast method init.

/**
 * Initialize
 * @param cfg
 * @param t
 * @param tPlan
 * @param ed
 */
public void init(Config cfg, MessageType t, TaskPlan tPlan, int ed) {
    this.config = cfg;
    this.instancePlan = tPlan;
    this.type = t;
    this.edge = ed;
    this.executor = tPlan.getThisExecutor();
    // we will only have one distinct route
    router = new BinaryTreeRouter(cfg, tPlan, source, destinations);
    if (this.finalReceiver != null) {
        this.finalReceiver.init(cfg, this, receiveExpectedTaskIds());
    } else {
        throw new RuntimeException("Final receiver is required");
    }
    LOG.log(Level.FINE, String.format("%d bast sources %d dest %s send tasks: %s", executor, source, destinations, router.sendQueueIds()));
    Map<Integer, Queue<Pair<Object, MPIMessage>>> pendingReceiveMessagesPerSource = new HashMap<>();
    Map<Integer, Queue<MPIMessage>> pendingReceiveDeSerializations = new HashMap<>();
    Map<Integer, MessageSerializer> serializerMap = new HashMap<>();
    Map<Integer, MessageDeSerializer> deSerializerMap = new HashMap<>();
    Set<Integer> srcs = router.sendQueueIds();
    for (int s : srcs) {
        // later look at how not to allocate pairs for this each time
        ArrayBlockingQueue<Pair<Object, MPISendMessage>> pendingSendMessages = new ArrayBlockingQueue<Pair<Object, MPISendMessage>>(MPIContext.sendPendingMax(cfg));
        pendingSendMessagesPerSource.put(s, pendingSendMessages);
        serializerMap.put(s, new MPIMessageSerializer(new KryoSerializer()));
    }
    int maxReceiveBuffers = MPIContext.receiveBufferCount(cfg);
    int receiveExecutorsSize = receivingExecutors().size();
    if (receiveExecutorsSize == 0) {
        receiveExecutorsSize = 1;
    }
    Set<Integer> execs = router.receivingExecutors();
    for (int e : execs) {
        int capacity = maxReceiveBuffers * 2 * receiveExecutorsSize;
        Queue<Pair<Object, MPIMessage>> pendingReceiveMessages = new ArrayBlockingQueue<Pair<Object, MPIMessage>>(capacity);
        pendingReceiveMessagesPerSource.put(e, pendingReceiveMessages);
        pendingReceiveDeSerializations.put(e, new ArrayBlockingQueue<MPIMessage>(capacity));
        deSerializerMap.put(e, new MPIMessageDeSerializer(new KryoSerializer()));
    }
    for (Integer s : srcs) {
        routingParametersCache.put(s, sendRoutingParameters(s, 0));
    }
    delegete.init(cfg, t, tPlan, ed, router.receivingExecutors(), router.isLastReceiver(), this, pendingSendMessagesPerSource, pendingReceiveMessagesPerSource, pendingReceiveDeSerializations, serializerMap, deSerializerMap, false);
}
Also used : MPIMessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer) MessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageSerializer) MPIMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer) HashMap(java.util.HashMap) KryoSerializer(edu.iu.dsc.tws.comms.utils.KryoSerializer) MPIMessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer) MessageDeSerializer(edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer) MPIMessageSerializer(edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) BinaryTreeRouter(edu.iu.dsc.tws.comms.routing.BinaryTreeRouter) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Queue(java.util.Queue) Pair(org.apache.commons.lang3.tuple.Pair) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair)

Aggregations

MessageDeSerializer (edu.iu.dsc.tws.comms.mpi.io.MessageDeSerializer)6 MessageSerializer (edu.iu.dsc.tws.comms.mpi.io.MessageSerializer)6 KryoSerializer (edu.iu.dsc.tws.comms.utils.KryoSerializer)6 HashMap (java.util.HashMap)6 Queue (java.util.Queue)6 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)6 Pair (org.apache.commons.lang3.tuple.Pair)6 MPIMessageDeSerializer (edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer)5 MPIMessageSerializer (edu.iu.dsc.tws.comms.mpi.io.MPIMessageSerializer)5 InvertedBinaryTreeRouter (edu.iu.dsc.tws.comms.routing.InvertedBinaryTreeRouter)2 PartitionRouter (edu.iu.dsc.tws.comms.routing.PartitionRouter)2 Set (java.util.Set)2 MPIMultiMessageDeserializer (edu.iu.dsc.tws.comms.mpi.io.MPIMultiMessageDeserializer)1 MPIMultiMessageSerializer (edu.iu.dsc.tws.comms.mpi.io.MPIMultiMessageSerializer)1 BinaryTreeRouter (edu.iu.dsc.tws.comms.routing.BinaryTreeRouter)1 DirectRouter (edu.iu.dsc.tws.comms.routing.DirectRouter)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1