[feat] Add GridScheduler for BlurFilter
@@ -30,7 +30,10 @@ import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
+import uk.ac.manchester.tornado.api.GridScheduler;
import uk.ac.manchester.tornado.api.TaskSchedule;
+import uk.ac.manchester.tornado.api.WorkerGrid;
+import uk.ac.manchester.tornado.api.WorkerGrid2D;
import uk.ac.manchester.tornado.api.annotations.Parallel;
import uk.ac.manchester.tornado.api.common.TornadoDevice;
import uk.ac.manchester.tornado.api.runtime.TornadoRuntime;
@@ -46,7 +49,7 @@ import uk.ac.manchester.tornado.api.runtime.TornadoRuntime;
* How to run?
*
* <code>
- * $ tornado uk.ac.manchester.tornado.examples.compute.BlurFilter
+ * $ tornado --threadInfo -m tornado.examples/uk.ac.manchester.tornado.examples.compute.BlurFilter
* </code>
*
*
@@ -157,8 +160,10 @@ public class BlurFilter {
}
long start = System.nanoTime();
- TornadoDevice device = TornadoRuntime.getTornadoRuntime().getDriver(0).getDevice(0);
-
+ WorkerGrid workerGrid = new WorkerGrid2D(w, h);
+ GridScheduler gridScheduler = new GridScheduler("blur.red", workerGrid);
+ gridScheduler.setWorkerGrid("blur.green", workerGrid);
+ gridScheduler.setWorkerGrid("blur.blue", workerGrid);
TaskSchedule parallelFilter = new TaskSchedule("blur") //
.task("red", BlurFilterImage::compute, redChannel, redFilter, w, h, filter, FILTER_WIDTH) //
.task("green", BlurFilterImage::compute, greenChannel, greenFilter, w, h, filter, FILTER_WIDTH) //
@@ -166,8 +171,9 @@ public class BlurFilter {
.streamOut(redFilter, greenFilter, blueFilter) //
.useDefaultThreadScheduler(true);
- parallelFilter.mapAllTo(device);
- parallelFilter.execute();
+ workerGrid.setGlobalWork(w, h, 1);
+ workerGrid.setLocalWorkToNull();
+ parallelFilter.execute(gridScheduler);
// now recombine into the output image - Alpha is 255 for no
// transparency
