use of edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer 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);
}
use of edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer 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);
}
use of edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer 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);
}
use of edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer 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);
}
use of edu.iu.dsc.tws.comms.mpi.io.MPIMessageDeSerializer in project twister2 by DSC-SPIDAL.
the class MPIDataFlowLoadBalance method init.
/**
* Initialize
* @param cfg
* @param t
* @param taskPlan
* @param edge
*/
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.info(String.format("%d adding internal/external routing", taskPlan.getThisExecutor()));
try {
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.info(String.format("%d adding internal/external routing %d", taskPlan.getThisExecutor(), s));
break;
}
} catch (Throwable te) {
te.printStackTrace();
}
LOG.info(String.format("%d done adding internal/external routing", taskPlan.getThisExecutor()));
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()));
}
delegete.init(cfg, t, taskPlan, edge, router.receivingExecutors(), router.isLastReceiver(), this, pendingSendMessagesPerSource, pendingReceiveMessagesPerSource, pendingReceiveDeSerializations, serializerMap, deSerializerMap, false);
}
Aggregations