Search in sources :

Example 1 with IExecution

use of edu.iu.dsc.tws.api.compute.executor.IExecution in project twister2 by DSC-SPIDAL.

the class BenchTaskWorker method execute.

@Override
public void execute(WorkerEnvironment workerEnv) {
    ComputeEnvironment cEnv = ComputeEnvironment.init(workerEnv);
    int workerId = workerEnv.getWorkerId();
    Config config = workerEnv.getConfig();
    if (resultsRecorder == null) {
        resultsRecorder = new BenchmarkResultsRecorder(config, workerId == 0);
    }
    Timing.setDefaultTimingUnit(TimingUnit.NANO_SECONDS);
    jobParameters = JobParameters.build(config);
    computeGraphBuilder = ComputeGraphBuilder.newBuilder(config);
    if (jobParameters.isStream()) {
        computeGraphBuilder.setMode(OperationMode.STREAMING);
    } else {
        computeGraphBuilder.setMode(OperationMode.BATCH);
    }
    inputDataArray = DataGenerator.generateIntData(jobParameters.getSize());
    buildTaskGraph();
    computeGraph = computeGraphBuilder.build();
    executionPlan = cEnv.getTaskExecutor().plan(computeGraph);
    IExecution execution = cEnv.getTaskExecutor().createExecution(computeGraph, executionPlan).iExecute();
    if (jobParameters.isStream()) {
        while (execution.progress() && (sendersInProgress.get() != 0 || receiversInProgress.get() != 0)) {
        // do nothing
        }
        // now just spin for several iterations to progress the remaining communication.
        // todo fix streaming to return false, when comm is done
        long timeNow = System.currentTimeMillis();
        LOG.info("Streaming Example task will wait 10secs to finish communication...");
        while (System.currentTimeMillis() - timeNow < 10000) {
            execution.progress();
        }
    } else {
        while (execution.progress()) {
        // do nothing
        }
    }
    LOG.info("Stopping execution....");
    execution.stop();
    execution.close();
}
Also used : ComputeEnvironment(edu.iu.dsc.tws.task.ComputeEnvironment) IExecution(edu.iu.dsc.tws.api.compute.executor.IExecution) Config(edu.iu.dsc.tws.api.config.Config) BenchmarkResultsRecorder(edu.iu.dsc.tws.examples.utils.bench.BenchmarkResultsRecorder)

Aggregations

IExecution (edu.iu.dsc.tws.api.compute.executor.IExecution)1 Config (edu.iu.dsc.tws.api.config.Config)1 BenchmarkResultsRecorder (edu.iu.dsc.tws.examples.utils.bench.BenchmarkResultsRecorder)1 ComputeEnvironment (edu.iu.dsc.tws.task.ComputeEnvironment)1