use of edu.iu.dsc.tws.task.impl.ComputeConnection in project twister2 by DSC-SPIDAL.
the class BatchTaskSchedulerTest method createGraphWithComputeTaskAndConstraints.
private ComputeGraph createGraphWithComputeTaskAndConstraints(int parallel, String graphName) {
TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
TaskSchedulerClassTest.TestCompute testCompute = new TaskSchedulerClassTest.TestCompute();
TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
ComputeGraphBuilder builder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
builder.addSource("source", testSource, parallel);
ComputeConnection computeConnection = builder.addCompute("compute", testCompute, parallel);
ComputeConnection sinkConnection = builder.addCompute("sink", testSink, parallel);
computeConnection.direct("source").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
sinkConnection.direct("compute").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
builder.setMode(OperationMode.BATCH);
builder.addGraphConstraints(Context.TWISTER2_MAX_TASK_INSTANCES_PER_WORKER, "8");
ComputeGraph graph = builder.build();
graph.setGraphName(graphName);
return graph;
}
use of edu.iu.dsc.tws.task.impl.ComputeConnection in project twister2 by DSC-SPIDAL.
the class RoundRobinBatchTaskSchedulerTest method createGraph.
private ComputeGraph createGraph(int parallel) {
TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
ComputeGraphBuilder builder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
builder.addSource("source", testSource, parallel);
ComputeConnection sinkConnection = builder.addCompute("sink", testSink, parallel);
sinkConnection.direct("source").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
builder.setMode(OperationMode.BATCH);
ComputeGraph graph = builder.build();
return graph;
}
use of edu.iu.dsc.tws.task.impl.ComputeConnection in project twister2 by DSC-SPIDAL.
the class BatchTaskSchedulerExample method buildSecondGraph.
private static ComputeGraph buildSecondGraph(int parallelism, Config conf) {
// Add source, compute, and sink tasks to the task graph builder for the third task graph
SecondSourceTask sourceTask = new SecondSourceTask();
SecondComputeTask computeTask = new SecondComputeTask();
SecondSinkTask sinkTask = new SecondSinkTask("secondgraphpoints");
ComputeGraphBuilder secondGraphBuilder = ComputeGraphBuilder.newBuilder(conf);
secondGraphBuilder.addSource("secondsource", sourceTask, parallelism);
ComputeConnection computeConnection = secondGraphBuilder.addCompute("secondcompute", computeTask, parallelism);
ComputeConnection sinkConnection = secondGraphBuilder.addCompute("secondsink", sinkTask, parallelism);
// Creating the communication edges between the tasks for the second task graph
computeConnection.direct("secondsource").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
sinkConnection.direct("secondcompute").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
secondGraphBuilder.setMode(OperationMode.BATCH);
secondGraphBuilder.setTaskGraphName("secondTG");
return secondGraphBuilder.build();
}
use of edu.iu.dsc.tws.task.impl.ComputeConnection in project twister2 by DSC-SPIDAL.
the class BatchTaskSchedulerExample method buildThirdGraph.
private static ComputeGraph buildThirdGraph(int parallelism, Config conf) {
// Add source, compute, and sink tasks to the task graph builder for the third task graph
ThirdSourceTask sourceTask = new ThirdSourceTask();
ThirdSinkTask sinkTask = new ThirdSinkTask("thirdgraphpoints");
ComputeGraphBuilder thirdGraphBuilder = ComputeGraphBuilder.newBuilder(conf);
thirdGraphBuilder.addSource("thirdsource", sourceTask, parallelism);
ComputeConnection sinkConnection = thirdGraphBuilder.addCompute("thirdsink", sinkTask, parallelism);
// Creating the communication edges between the tasks for the third task graph
sinkConnection.allreduce("thirdsource").viaEdge("all-reduce").withReductionFunction(new Aggregator()).withDataType(MessageTypes.OBJECT);
thirdGraphBuilder.setMode(OperationMode.BATCH);
thirdGraphBuilder.setTaskGraphName("thirdTG");
return thirdGraphBuilder.build();
}
use of edu.iu.dsc.tws.task.impl.ComputeConnection in project twister2 by DSC-SPIDAL.
the class ConstraintTaskExample method buildSecondGraph.
private ComputeGraph buildSecondGraph(int parallelism, Config conf, int dimension, String inputKey, String constraint) {
SecondSourceTask sourceTask = new SecondSourceTask(inputKey);
SecondSinkTask sinkTask = new SecondSinkTask(dimension);
ComputeGraphBuilder secondGraphBuilder = ComputeGraphBuilder.newBuilder(conf);
secondGraphBuilder.addSource("secondsource", sourceTask, parallelism);
ComputeConnection computeConnection = secondGraphBuilder.addCompute("secondsink", sinkTask, parallelism);
computeConnection.direct("secondsource").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
secondGraphBuilder.setMode(OperationMode.BATCH);
secondGraphBuilder.setTaskGraphName("secondTG");
secondGraphBuilder.addGraphConstraints(Context.TWISTER2_MAX_TASK_INSTANCES_PER_WORKER, constraint);
return secondGraphBuilder.build();
}
Aggregations