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();
}
Aggregations