use of edu.iu.dsc.tws.comms.batch.BDirect in project twister2 by DSC-SPIDAL.
the class InputDataStreamer method execute.
@Override
protected void execute(WorkerEnvironment workerEnv) {
List<Integer> sources = new ArrayList<>();
List<Integer> targets = new ArrayList<>();
Integer noOfSourceTasks = taskStages.get(0);
for (int i = 0; i < noOfSourceTasks; i++) {
sources.add(i);
}
Integer noOfTargetTasks = taskStages.get(1);
for (int i = 0; i < noOfTargetTasks; i++) {
targets.add(noOfSourceTasks + i);
}
direct = new BDirect(workerEnv.getCommunicator(), logicalPlan, sources, targets, new DirectReceiver(), MessageTypes.DOUBLE);
Set<Integer> tasksOfExecutor = Utils.getTasksOfExecutor(workerId, logicalPlan, taskStages, 0);
for (int t : tasksOfExecutor) {
finishedSources.put(t, false);
}
if (tasksOfExecutor.size() == 0) {
sourcesDone = true;
}
for (int t : tasksOfExecutor) {
Thread mapThread = new Thread(new DataStreamer(t));
mapThread.start();
}
}
use of edu.iu.dsc.tws.comms.batch.BDirect in project twister2 by DSC-SPIDAL.
the class BDirectExample method compute.
@Override
protected void compute(WorkerEnvironment workerEnv) {
if (!jobParameters.getTaskStages().get(0).equals(jobParameters.getTaskStages().get(1))) {
int min = Math.min(jobParameters.getTaskStages().get(0), jobParameters.getTaskStages().get(1));
LOG.warning("Setting sources and sinks to " + min);
jobParameters.getTaskStages().set(0, min);
jobParameters.getTaskStages().set(1, min);
}
Integer noOfSourceTasks = jobParameters.getTaskStages().get(0);
List<Integer> sources = IntStream.range(0, noOfSourceTasks).boxed().collect(Collectors.toList());
Integer noOfTargetTasks = jobParameters.getTaskStages().get(1);
List<Integer> targets = IntStream.range(0, noOfTargetTasks).boxed().collect(Collectors.toList());
LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
// create the communication
direct = new BDirect(workerEnv.getCommunicator(), logicalPlanBuilder, new DirectReceiver(), MessageTypes.INTEGER_ARRAY, false);
resultsVerifier = new ResultsVerifier<>(inputDataArray, (ints, args) -> {
List<int[]> expectedData = new ArrayList<>();
for (int i = 0; i < jobParameters.getTotalIterations(); i++) {
expectedData.add(ints);
}
return expectedData.iterator();
}, new IteratorComparator<>(IntArrayComparator.getInstance()));
Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
for (int t : tasksOfExecutor) {
finishedSources.put(t, false);
}
if (tasksOfExecutor.size() == 0) {
sourcesDone = true;
}
// now initialize the workers
for (int t : tasksOfExecutor) {
// the map thread where data is produced
Thread mapThread = new Thread(new BenchWorker.MapWorker(t));
mapThread.start();
}
}
Aggregations