FPGA check example
@@ -22,20 +22,23 @@ import java.util.Arrays;
import uk.ac.manchester.tornado.api.TaskSchedule;
import uk.ac.manchester.tornado.api.annotations.Parallel;
+/**
+ * Simple test to run on the FPGA to check for correctness.
+ *
+ */
public class VectorAddInt {
private static void vectorAdd(int[] a, int[] b, int[] c) {
-
for (@Parallel int i = 0; i < c.length; i++) {
c[i] = a[i] + b[i];
}
-
}
public static void main(String[] args) {
- int size = Integer.parseInt(args[0]);
-
- // final int size = 8192;
+ int size = 8192;
+ if (args.length > 0) {
+ size = Integer.parseInt(args[0]);
+ }
int[] a = new int[size];
int[] b = new int[size];
@@ -53,20 +56,9 @@ public class VectorAddInt {
for (int idx = 0; idx < 10; idx++) {
graph.execute();
- long t1 = System.nanoTime();
vectorAdd(a, b, result);
- long t2 = System.nanoTime();
-
- long seqTimeKernel = t2 - t1;
- // System.out.println("Sequential kernel time: " + seqTimeKernel +
- // "ns" + "\n");
- // System.out.printf("result: %d\n", c.toString());
- // System.out.println(Arrays.toString(c));
-
- System.out.println("Checking result");
boolean wrongResult = false;
-
for (int i = 0; i < c.length; i++) {
if (c[i] != 30) {
wrongResult = true;
