Search in sources :

Example 11 with IteratorComparator

use of edu.iu.dsc.tws.examples.verification.comparators.IteratorComparator 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();
    }
}
Also used : IntArrayComparator(edu.iu.dsc.tws.examples.verification.comparators.IntArrayComparator) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple) SAllGather(edu.iu.dsc.tws.comms.stream.SAllGather) BulkReceiver(edu.iu.dsc.tws.api.comms.BulkReceiver) Iterator(java.util.Iterator) Set(java.util.Set) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) Config(edu.iu.dsc.tws.api.config.Config) Timing(edu.iu.dsc.tws.examples.utils.bench.Timing) MessageTypes(edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes) Logger(java.util.logging.Logger) BenchWorker(edu.iu.dsc.tws.examples.comms.BenchWorker) TIMING_ALL_RECV(edu.iu.dsc.tws.examples.utils.bench.BenchmarkConstants.TIMING_ALL_RECV) BenchmarkConstants(edu.iu.dsc.tws.examples.utils.bench.BenchmarkConstants) ArrayList(java.util.ArrayList) TupleComparator(edu.iu.dsc.tws.examples.verification.comparators.TupleComparator) List(java.util.List) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment) IteratorComparator(edu.iu.dsc.tws.examples.verification.comparators.IteratorComparator) IntComparator(edu.iu.dsc.tws.examples.verification.comparators.IntComparator) BenchmarkUtils(edu.iu.dsc.tws.examples.utils.bench.BenchmarkUtils) ResultsVerifier(edu.iu.dsc.tws.examples.verification.ResultsVerifier) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) SAllGather(edu.iu.dsc.tws.comms.stream.SAllGather) BenchWorker(edu.iu.dsc.tws.examples.comms.BenchWorker) IteratorComparator(edu.iu.dsc.tws.examples.verification.comparators.IteratorComparator) ArrayList(java.util.ArrayList) List(java.util.List) Tuple(edu.iu.dsc.tws.api.comms.structs.Tuple)

Aggregations

BulkReceiver (edu.iu.dsc.tws.api.comms.BulkReceiver)11 MessageTypes (edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes)11 Config (edu.iu.dsc.tws.api.config.Config)11 WorkerEnvironment (edu.iu.dsc.tws.api.resource.WorkerEnvironment)11 LogicalPlanBuilder (edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder)11 BenchmarkUtils (edu.iu.dsc.tws.examples.utils.bench.BenchmarkUtils)11 Timing (edu.iu.dsc.tws.examples.utils.bench.Timing)11 ResultsVerifier (edu.iu.dsc.tws.examples.verification.ResultsVerifier)11 IntArrayComparator (edu.iu.dsc.tws.examples.verification.comparators.IntArrayComparator)11 IteratorComparator (edu.iu.dsc.tws.examples.verification.comparators.IteratorComparator)11 ArrayList (java.util.ArrayList)11 Iterator (java.util.Iterator)11 List (java.util.List)11 Set (java.util.Set)11 Logger (java.util.logging.Logger)11 BenchmarkConstants (edu.iu.dsc.tws.examples.utils.bench.BenchmarkConstants)10 Comparator (java.util.Comparator)9 Tuple (edu.iu.dsc.tws.api.comms.structs.Tuple)8 TupleComparator (edu.iu.dsc.tws.examples.verification.comparators.TupleComparator)8 BenchWorker (edu.iu.dsc.tws.examples.comms.BenchWorker)7