aboutsummaryrefslogtreecommitdiffstats
path: root/benchmarks/polybench-syn-div/stencils/seidel-2d.c
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-09-18 14:40:45 +0100
committerYann Herklotz <git@yannherklotz.com>2021-09-18 14:40:45 +0100
commitb666f88219893c82361606f8652297ecc7fb7a9f (patch)
tree946c2ddb5ce21b7af24ce6945fe5f83cbb274061 /benchmarks/polybench-syn-div/stencils/seidel-2d.c
parentc4d44af5f3135aba4d4878f8f41c80d1f0b9e9a2 (diff)
parentc4436c02648502c4cb327d2018229e62a2c0d1c0 (diff)
downloadvericert-b666f88219893c82361606f8652297ecc7fb7a9f.tar.gz
vericert-b666f88219893c82361606f8652297ecc7fb7a9f.zip
Merge branch 'master' into develop
Diffstat (limited to 'benchmarks/polybench-syn-div/stencils/seidel-2d.c')
-rw-r--r--benchmarks/polybench-syn-div/stencils/seidel-2d.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn-div/stencils/seidel-2d.c b/benchmarks/polybench-syn-div/stencils/seidel-2d.c
new file mode 100644
index 0000000..4a3b1ac
--- /dev/null
+++ b/benchmarks/polybench-syn-div/stencils/seidel-2d.c
@@ -0,0 +1,92 @@
+/**
+ * This version is stamped on May 10, 2016
+ *
+ * Contact:
+ * Louis-Noel Pouchet <pouchet.ohio-state.edu>
+ * Tomofumi Yuki <tomofumi.yuki.fr>
+ *
+ * Web address: http://polybench.sourceforge.net
+ */
+/* seidel-2d.c: this file is part of PolyBench/C */
+
+#include "../include/misc.h"
+
+#ifndef SYNTHESIS
+#include <stdio.h>
+#endif
+
+#define plus(i) i = i + ONE
+static
+void init_array (int n,
+ int A[ 40 + 0][40 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int TWO = 2;
+
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j))
+ A[i][j] = (((int) i*(j+TWO) + TWO) / n);
+}
+
+
+
+
+static
+int print_array(int n,
+ int A[ 40 + 0][40 + 0])
+
+{
+ int i, j;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j)) {
+ res ^= A[i][j];
+ }
+#ifndef SYNTHESIS
+ printf("finished %u\n", res);
+#endif
+ return res;
+}
+
+
+
+
+static
+void kernel_seidel_2d(int tsteps,
+ int n,
+ int A[ 40 + 0][40 + 0])
+{
+ int t, i, j;
+ int ONE = 1;
+ int TWO = 2;
+ int NINE = 9;
+
+ for (t = 0; t <= tsteps - ONE; plus(t))
+ for (i = ONE; i<= n - TWO; plus(i))
+ for (j = ONE; j <= n - TWO; plus(j))
+ A[i][j] = ((A[i-ONE][j-ONE] + A[i-ONE][j] + A[i-ONE][j+ONE]
+ + A[i][j-ONE] + A[i][j] + A[i][j+ONE]
+ + A[i+ONE][j-ONE] + A[i+ONE][j] + A[i+ONE][j+ONE]) / NINE);
+
+}
+
+
+int main()
+{
+
+ int n = 40;
+ int tsteps = 5;
+
+
+ int A[40 + 0][40 + 0];
+
+ init_array (n, A);
+
+ kernel_seidel_2d (tsteps, n, A);
+
+ return print_array(n, A);
+
+}