Search in sources :

Example 1 with LoadBalanceSelector

use of edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector in project twister2 by DSC-SPIDAL.

the class SPartitionExample method compute.

@Override
protected void compute(WorkerEnvironment workerEnv) {
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
    // create the communication
    partition = new SPartition(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER_ARRAY, new PartitionReceiver(), new LoadBalanceSelector());
    this.resultsVerifier = new ResultsVerifier<>(inputDataArray, (ints, args) -> ints, IntArrayComparator.getInstance());
    logicalPlanBuilder.getTargetsOnThisWorker().forEach(t -> {
        if (workerId == 0) {
            recvrInWorker0 = t;
        }
    });
    Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
    // now initialize the workers
    for (int t : tasksOfExecutor) {
        // the map thread where data is produced
        Thread mapThread = new Thread(new MapWorker(t));
        mapThread.start();
    }
}
Also used : IntArrayComparator(edu.iu.dsc.tws.examples.verification.comparators.IntArrayComparator) TIMING_MESSAGE_RECV(edu.iu.dsc.tws.examples.utils.bench.BenchmarkConstants.TIMING_MESSAGE_RECV) LoadBalanceSelector(edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector) SingularReceiver(edu.iu.dsc.tws.api.comms.SingularReceiver) 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) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment) SPartition(edu.iu.dsc.tws.comms.stream.SPartition) 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) SPartition(edu.iu.dsc.tws.comms.stream.SPartition) LoadBalanceSelector(edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector)

Example 2 with LoadBalanceSelector

use of edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector in project twister2 by DSC-SPIDAL.

the class BPartitionExample method compute.

@Override
protected void compute(WorkerEnvironment workerEnv) {
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
    // create the communication
    partition = new BPartition(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.INTEGER_ARRAY, new PartitionReceiver(), new LoadBalanceSelector(), false);
    this.resultsVerifier = new ResultsVerifier<>(inputDataArray, (ints, args) -> {
        int lowestTarget = logicalPlanBuilder.getTargets().stream().min(Comparator.comparingInt(o -> (Integer) o)).get();
        int target = Integer.parseInt(args.get("target").toString());
        int toThisFromOneSource = jobParameters.getTotalIterations() / logicalPlanBuilder.getTargets().size();
        if (jobParameters.getTotalIterations() % logicalPlanBuilder.getTargets().size() > (target - lowestTarget)) {
            toThisFromOneSource++;
        }
        List<int[]> expectedData = new ArrayList<>();
        for (int i = 0; i < toThisFromOneSource * logicalPlanBuilder.getSources().size(); i++) {
            expectedData.add(ints);
        }
        return expectedData.iterator();
    }, new IteratorComparator<>(IntArrayComparator.getInstance()));
    Set<Integer> tasksOfExecutor = logicalPlanBuilder.getSourcesOnThisWorker();
    // 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();
    }
}
Also used : IntArrayComparator(edu.iu.dsc.tws.examples.verification.comparators.IntArrayComparator) LoadBalanceSelector(edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector) BulkReceiver(edu.iu.dsc.tws.api.comms.BulkReceiver) Iterator(java.util.Iterator) BPartition(edu.iu.dsc.tws.comms.batch.BPartition) 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) BenchmarkConstants(edu.iu.dsc.tws.examples.utils.bench.BenchmarkConstants) ArrayList(java.util.ArrayList) List(java.util.List) WorkerEnvironment(edu.iu.dsc.tws.api.resource.WorkerEnvironment) IteratorComparator(edu.iu.dsc.tws.examples.verification.comparators.IteratorComparator) BenchmarkUtils(edu.iu.dsc.tws.examples.utils.bench.BenchmarkUtils) ResultsVerifier(edu.iu.dsc.tws.examples.verification.ResultsVerifier) Comparator(java.util.Comparator) Collections(java.util.Collections) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) BPartition(edu.iu.dsc.tws.comms.batch.BPartition) 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) LoadBalanceSelector(edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector)

Example 3 with LoadBalanceSelector

use of edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector in project twister2 by DSC-SPIDAL.

the class SKeyedGatherExample method compute.

@Override
protected void compute(WorkerEnvironment workerEnv) {
    LogicalPlanBuilder logicalPlanBuilder = LogicalPlanBuilder.plan(jobParameters.getSources(), jobParameters.getTargets(), workerEnv).withFairDistribution();
    keyedGather = new SKeyedGather(workerEnv.getCommunicator(), logicalPlanBuilder, MessageTypes.OBJECT, MessageTypes.OBJECT, new GatherBulkReceiver(), new LoadBalanceSelector());
    Set<Integer> sourceTasks = logicalPlanBuilder.getSourcesOnThisWorker();
    for (int t : sourceTasks) {
        finishedSources.put(t, false);
    }
    if (sourceTasks.size() == 0) {
        sourcesDone = true;
    }
    Set<Integer> sinkTasks = logicalPlanBuilder.getTargetsOnThisWorker();
    LOG.log(Level.INFO, String.format("Worker[%d], Source Tasks %s , Sink Tasks %s", workerId, sourceTasks, sinkTasks));
    // now initialize the workers
    for (int t : sourceTasks) {
        // the map thread where data is produced
        MapWorker mapWorker = new MapWorker(t);
        mapWorker.setTimingForLowestTargetOnly(true);
        Thread mapThread = new Thread(mapWorker);
        mapThread.start();
    }
}
Also used : SKeyedGather(edu.iu.dsc.tws.comms.stream.SKeyedGather) LogicalPlanBuilder(edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder) LoadBalanceSelector(edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector)

Aggregations

LoadBalanceSelector (edu.iu.dsc.tws.comms.selectors.LoadBalanceSelector)3 LogicalPlanBuilder (edu.iu.dsc.tws.comms.utils.LogicalPlanBuilder)3 MessageTypes (edu.iu.dsc.tws.api.comms.messaging.types.MessageTypes)2 Config (edu.iu.dsc.tws.api.config.Config)2 WorkerEnvironment (edu.iu.dsc.tws.api.resource.WorkerEnvironment)2 BenchWorker (edu.iu.dsc.tws.examples.comms.BenchWorker)2 BenchmarkUtils (edu.iu.dsc.tws.examples.utils.bench.BenchmarkUtils)2 Timing (edu.iu.dsc.tws.examples.utils.bench.Timing)2 ResultsVerifier (edu.iu.dsc.tws.examples.verification.ResultsVerifier)2 IntArrayComparator (edu.iu.dsc.tws.examples.verification.comparators.IntArrayComparator)2 Set (java.util.Set)2 Logger (java.util.logging.Logger)2 BulkReceiver (edu.iu.dsc.tws.api.comms.BulkReceiver)1 SingularReceiver (edu.iu.dsc.tws.api.comms.SingularReceiver)1 BPartition (edu.iu.dsc.tws.comms.batch.BPartition)1 SKeyedGather (edu.iu.dsc.tws.comms.stream.SKeyedGather)1 SPartition (edu.iu.dsc.tws.comms.stream.SPartition)1 BenchmarkConstants (edu.iu.dsc.tws.examples.utils.bench.BenchmarkConstants)1 TIMING_ALL_RECV (edu.iu.dsc.tws.examples.utils.bench.BenchmarkConstants.TIMING_ALL_RECV)1 TIMING_MESSAGE_RECV (edu.iu.dsc.tws.examples.utils.bench.BenchmarkConstants.TIMING_MESSAGE_RECV)1