use of edu.iu.dsc.tws.comms.stream.SAllGather in project twister2 by DSC-SPIDAL.
the class SAllGatherExample method compute.
@Override
protected void compute(WorkerEnvironment workerEnv) {
LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
// create the communication
gather = new SAllGather(workerEnv.getCommunicator(), logicalPlanBuilder, new FinalReduceReceiver(), MessageTypes.INTEGER_ARRAY);
Set<Integer> sourceTasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
for (int t : sourceTasksOfExecutor) {
finishedSources.put(t, false);
}
if (sourceTasksOfExecutor.size() == 0) {
sourcesDone = true;
}
Set<Integer> targetTasksOfExecutor = logicalPlanBuilder.getTargetsOnThisWorker();
for (int taskId : targetTasksOfExecutor) {
if (logicalPlanBuilder.getTargets().contains(taskId)) {
gatherDone = false;
if (workerId == 0) {
receiverInWorker0 = taskId;
}
}
}
this.resultsVerifier = new ResultsVerifier<>(inputDataArray, (dataArray, args) -> {
List<Tuple<Integer, int[]>> listOfArrays = new ArrayList<>();
for (int i = 0; i < logicalPlanBuilder.getSources().size(); i++) {
listOfArrays.add(new Tuple<>(i, dataArray));
}
return listOfArrays.iterator();
}, new IteratorComparator<>(new TupleComparator<>(IntComparator.getInstance(), IntArrayComparator.getInstance())));
// now initialize the workers
for (int t : sourceTasksOfExecutor) {
// the map thread where data is produced
Thread mapThread = new Thread(new BenchWorker.MapWorker(t));
mapThread.start();
}
}
Aggregations