use of edu.iu.dsc.tws.comms.utils.KryoSerializer in project twister2 by DSC-SPIDAL.
the class MPIDataFlowOperation method setStoreBased.
public void setStoreBased(boolean storeBased) {
isStoreBased = storeBased;
if (isStoreBased) {
// TODO : need to load this from config file, both the type of memory manager and the datapath
// TODO : need to make the memory manager available globally
opertionID = (int) System.currentTimeMillis();
this.kryoSerializer = new KryoSerializer();
// Path dataPath = new Path("/scratch/pulasthi/terasort/lmdbdatabase_" + this.executor);
Path dataPath = new Path(MPIContext.networkStoragePath(config) + " /lmdbdatabase_" + this.executor);
this.memoryManager = new LMDBMemoryManager(dataPath);
if (!isKeyed) {
this.operationMemoryManager = memoryManager.addOperation(opertionID, MessageTypeUtils.toDataMessageType(type));
} else {
this.operationMemoryManager = memoryManager.addOperation(opertionID, MessageTypeUtils.toDataMessageType(type), MessageTypeUtils.toDataMessageType(keyType));
}
}
}
use of edu.iu.dsc.tws.comms.utils.KryoSerializer 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.utils.KryoSerializer 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.utils.KryoSerializer 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);
}
use of edu.iu.dsc.tws.comms.utils.KryoSerializer 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);
}
Aggregations