aboutsummaryrefslogtreecommitdiffstats
path: root/benchmarks/polybench-syn/linear-algebra/solvers
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-08-13 23:24:40 +0100
committerYann Herklotz <git@yannherklotz.com>2020-08-13 23:24:40 +0100
commit045c0dc29fc31a8d3f15da8b3130dbc4706ea581 (patch)
tree56e9eb2ec6c318648e47c43d6b8abb2458ae236e /benchmarks/polybench-syn/linear-algebra/solvers
parent3971466fbdd9aa1883a4468de3d67fdf90fee02d (diff)
downloadvericert-kvx-045c0dc29fc31a8d3f15da8b3130dbc4706ea581.tar.gz
vericert-kvx-045c0dc29fc31a8d3f15da8b3130dbc4706ea581.zip
Add modified polybench benchmarks
Diffstat (limited to 'benchmarks/polybench-syn/linear-algebra/solvers')
-rw-r--r--benchmarks/polybench-syn/linear-algebra/solvers/cholesky.c125
-rw-r--r--benchmarks/polybench-syn/linear-algebra/solvers/durbin.c102
-rw-r--r--benchmarks/polybench-syn/linear-algebra/solvers/lu.c148
-rw-r--r--benchmarks/polybench-syn/linear-algebra/solvers/ludcmp.c164
-rw-r--r--benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c89
5 files changed, 628 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/cholesky.c b/benchmarks/polybench-syn/linear-algebra/solvers/cholesky.c
new file mode 100644
index 0000000..264251d
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/solvers/cholesky.c
@@ -0,0 +1,125 @@
+/**
+ * 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
+ */
+/* cholesky.c: this file is part of PolyBench/C */
+
+#include <stdio.h>
+
+# define SQRT_FUN(x) sqrtf(x)
+
+#define plus(i) i = i + ONE
+static
+void init_array(int n,
+ int A[40][40])
+{
+ int i, j;
+ int ONE = 1;
+
+ for (i = 0; i < n; plus(i))
+ {
+ for (j = 0; j <= i; plus(j))
+ A[i][j] = (int)(-j % n) / n + ONE;
+ for (j = i + ONE; j < n; plus(j)) {
+ A[i][j] = 0;
+ }
+ A[i][i] = 1;
+ }
+
+
+ int r,s,t;
+ int B[40][40];
+ for (r = 0; r < n; ++r)
+ for (s = 0; s < n; ++s)
+ B[r][s] = 0;
+ for (t = 0; t < n; ++t)
+ for (r = 0; r < n; ++r)
+ for (s = 0; s < n; ++s)
+ B[r][s] += A[r][t] * A[s][t];
+ for (r = 0; r < n; ++r)
+ for (s = 0; s < n; ++s)
+ A[r][s] = B[r][s];
+
+}
+
+
+
+
+static
+int check_array(int n,
+ int A[40][40])
+
+{
+ int res = 0;
+ int ONE = 1;
+ int i, j;
+
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j <= i; plus(j)) {
+ if(A[i][j]!=0) res = 1;
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_cholesky(int n,
+ int A[40][40])
+{
+ int i, j, k;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < n; plus(i)) {
+
+ for (j = 0; j < i; plus(j)) {
+ for (k = 0; k < j; plus(k)) {
+ A[i][j] -= A[i][k] * A[j][k];
+ }
+ A[i][j] /= A[j][j];
+ }
+
+ for (k = 0; k < i; plus(k)) {
+ A[i][i] -= A[i][k] * A[i][k];
+ }
+ int sq = 0; int val = 0; int cmp = A[i][i];
+ printf("cmp %d\n",cmp);
+ while(sq <= cmp) {
+ val = val + ONE;
+ sq = val * val;
+ }
+ printf("val %d\n",val);
+ A[i][i] = val;
+ }
+#pragma endscop
+
+}
+
+
+int main(int argc, char** argv)
+{
+
+ int n = 40;
+
+
+ int A[40][40];
+
+
+ //init_array (n, A);
+
+
+ kernel_cholesky (n, A);
+
+
+ return check_array(n, A);
+
+
+ return 0;
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c b/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c
new file mode 100644
index 0000000..677c23c
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/solvers/durbin.c
@@ -0,0 +1,102 @@
+/**
+ * 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
+ */
+/* durbin.c: this file is part of PolyBench/C */
+
+
+#define plus(i) i = i + ONE
+/* Include polybench common header. */
+static
+void init_array (int n,
+ int r[ 40 + 0])
+{
+ int ONE = 1;
+ int i, j;
+
+ for (i = 0; i < n; plus(i))
+ {
+ r[i] = (n+ONE-i);
+ }
+}
+
+
+
+static
+int print_array(int n,
+ int y[ 40 + 0])
+
+{
+ int ONE = 1;
+ int i;
+ int res = 0;
+
+ for (i = 0; i < n; plus(i)) {
+ res += y[i];
+ }
+ return res;
+}
+
+static
+void kernel_durbin(int n,
+ int r[ 40 + 0],
+ int y[ 40 + 0])
+{
+ int z[40];
+ int alpha;
+ int beta;
+ int sum;
+
+ int ONE = 1;
+ int i,k;
+
+#pragma scop
+ y[0] = -r[0];
+ beta = 1;
+ alpha = -r[0];
+
+ for (k = 1; k < n; plus(k)) {
+ beta = (ONE-alpha*alpha)*beta;
+ sum = 0;
+ for (i=0; i<k; plus(i)) {
+ sum += r[k-i-ONE]*y[i];
+ }
+ alpha = - (r[k] + sum)/beta;
+
+ for (i=0; i<k; plus(i)) {
+ z[i] = y[i] + alpha*y[k-i-ONE];
+ }
+ for (i=0; i<k; plus(i)) {
+ y[i] = z[i];
+ }
+ y[k] = alpha;
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int n = 40;
+
+
+ int r[40 + 0];
+ int y[40 + 0];
+
+
+ init_array (n, r);
+
+ kernel_durbin (n,
+ r,
+ y);
+
+ return print_array(n, y);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/lu.c b/benchmarks/polybench-syn/linear-algebra/solvers/lu.c
new file mode 100644
index 0000000..1cf07ea
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/solvers/lu.c
@@ -0,0 +1,148 @@
+/**
+ * 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
+ */
+/* lu.c: this file is part of PolyBench/C */
+
+//#include <stdio.h>
+//#include <unistd.h>
+//#include <string.h>
+//#include <math.h>
+
+#define plus(i) i = i + ONE
+
+static
+void init_array (int n,
+ int A[40][40])
+{
+ int ONE = 1;
+ int i, j;
+
+ for (i = 0; i < n; plus(i))
+ {
+ for (j = 0; j <= i; plus(j))
+ A[i][j] = (int)(-j % n) / n + ONE;
+ for (j = plus(i); j < n; plus(j)) {
+ A[i][j] = 0;
+ }
+ A[i][i] = 1;
+ }
+
+
+
+ int r,s,t;
+ int B[40][40]; // B = (int(*)[40 + 0][40 + 0])polybench_alloc_data ((40 + 0) * (40 + 0), sizeof(int));;
+ for (r = 0; r < n; plus(r))
+ for (s = 0; s < n; plus(s))
+ B[r][s] = 0;
+ for (t = 0; t < n; plus(t))
+ for (r = 0; r < n; plus(r))
+ for (s = 0; s < n; plus(s))
+ B[r][s] += A[r][t] * A[s][t];
+ for (r = 0; r < n; plus(r))
+ for (s = 0; s < n; plus(s))
+ A[r][s] = B[r][s];
+ //free((void*)B);;
+
+}
+
+
+
+/*
+static
+void print_array(int n,
+ int A[ 40 + 0][40 + 0])
+
+{
+ int i, j;
+
+ fprintf(stderr, "==BEGIN DUMP_ARRAYS==\n");
+ fprintf(stderr, "begin dump: %s", "A");
+ for (i = 0; i < n; i++)
+ for (j = 0; j < n; j++) {
+ if ((i * n + j) % 20 == 0) fprintf (stderr, "\n");
+ fprintf (stderr, "%d ", A[i][j]);
+ }
+ fprintf(stderr, "\nend dump: %s\n", "A");
+ fprintf(stderr, "==END DUMP_ARRAYS==\n");
+}
+*/
+
+
+
+static
+void kernel_lu(int n,
+ int A[ 40][40])
+{
+ int i, j, k;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < n; plus(i)) {
+ for (j = 0; j <i; plus(j)) {
+ for (k = 0; k < j; plus(k)) {
+ A[i][j] -= A[i][k] * A[k][j];
+ }
+ A[i][j] /= A[j][j];
+ }
+ for (j = i; j < n; plus(j)) {
+ for (k = 0; k < i; plus(k)) {
+ A[i][j] -= A[i][k] * A[k][j];
+ }
+ }
+ }
+#pragma endscop
+}
+
+static
+int check_array(int n,
+ int A[40][40])
+{
+ int res = 0;
+ int i, j;
+ int ONE = 1;
+
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j))
+ if(A[i][j] !=0) res = 1;
+
+ return res;
+}
+
+
+int main()
+{
+
+ int n = 40;
+
+
+ int A[40][40]; //A = (int(*)[40 + 0][40 + 0])polybench_alloc_data ((40 + 0) * (40 + 0), sizeof(int));;
+
+
+ init_array (n, A);
+
+
+
+ //print_array(n, A);
+ // polybench_timer_start();;
+
+
+ kernel_lu (n, A);
+
+
+ // polybench_timer_stop();;
+ // polybench_timer_print();;
+
+
+
+ //if (argc > 42 && ! strcmp(argv[0], ""))
+ return check_array(n, A);
+ return 0;
+
+ //free((void*)A);;
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/ludcmp.c b/benchmarks/polybench-syn/linear-algebra/solvers/ludcmp.c
new file mode 100644
index 0000000..e85316a
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/solvers/ludcmp.c
@@ -0,0 +1,164 @@
+/**
+ * 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
+ */
+/* ludcmp.c: this file is part of PolyBench/C */
+
+#define plus(i) i = i + ONE
+
+static
+void init_array (int n,
+ int A[ 40 + 0][40 + 0],
+ int b[ 40 + 0],
+ int x[ 40 + 0],
+ int y[ 40 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int TWO = 2;
+ int FOUR = 4;
+ int fn = (int)n;
+
+ for (i = 0; i < n; plus(i))
+ {
+ x[i] = 0;
+ y[i] = 0;
+ b[i] = (i+ONE)/fn/(TWO) + (FOUR);
+ }
+
+ for (i = 0; i < n; plus(i))
+ {
+ for (j = 0; j <= i; plus(j))
+ A[i][j] = (int)(-j % n) / n + ONE;
+ for (j = i+ONE; j < n; plus(j)) {
+ A[i][j] = 0;
+ }
+ A[i][i] = 1;
+ }
+
+
+
+ int r,s,t;
+ int B[40 + 0][40 + 0];
+ for (r = 0; r < n; plus(r))
+ for (s = 0; s < n; plus(s))
+ B[r][s] = 0;
+ for (t = 0; t < n; plus(t))
+ for (r = 0; r < n; plus(r))
+ for (s = 0; s < n; plus(s))
+ B[r][s] += A[r][t] * A[s][t];
+ for (r = 0; r < n; plus(r))
+ for (s = 0; s < n; plus(s))
+ A[r][s] = B[r][s];
+
+}
+
+
+
+
+static
+int check_array(int n,
+ int x[ 40 + 0])
+
+{
+ int i;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < n; plus(i)) {
+ res += x[i];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_ludcmp(int n,
+ int A[ 40 + 0][40 + 0],
+ int b[ 40 + 0],
+ int x[ 40 + 0],
+ int y[ 40 + 0])
+{
+ int i, j, k;
+ int ONE = 1;
+
+ int w;
+
+#pragma scop
+ for (i = 0; i < n; plus(i)) {
+ for (j = 0; j <i; plus(j)) {
+ w = A[i][j];
+ for (k = 0; k < j; plus(k)) {
+ w -= A[i][k] * A[k][j];
+ }
+ A[i][j] = w / A[j][j];
+ }
+ for (j = i; j < n; plus(j)) {
+ w = A[i][j];
+ for (k = 0; k < i; plus(k)) {
+ w -= A[i][k] * A[k][j];
+ }
+ A[i][j] = w;
+ }
+ }
+
+ for (i = 0; i < n; plus(i)) {
+ w = b[i];
+ for (j = 0; j < i; plus(j))
+ w -= A[i][j] * y[j];
+ y[i] = w;
+ }
+
+ for (i = n-ONE; i >=0; i=i-ONE) {
+ w = y[i];
+ for (j = i+ONE; j < n; plus(j))
+ w -= A[i][j] * x[j];
+ x[i] = w / A[i][i];
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int n = 40;
+ int ONE = 1;
+
+
+ int A[40 + 0][40 + 0];
+ int b[40 + 0];
+ int x[40 + 0];
+ int y[40 + 0];
+
+
+
+ init_array (n,
+ A,
+ b,
+ x,
+ y);
+
+
+ ;
+
+
+ kernel_ludcmp (n,
+ A,
+ b,
+ x,
+ y);
+
+ return check_array(n, x);
+
+
+ return 0;
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c b/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c
new file mode 100644
index 0000000..5e760e6
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/solvers/trisolv.c
@@ -0,0 +1,89 @@
+/**
+ * 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
+ */
+/* trisolv.c: this file is part of PolyBench/C */
+
+#define plus(i) i = i + ONE
+static
+void init_array(int n,
+ int L[ 40 ][40 ],
+ int x[ 40 ],
+ int b[ 40 ])
+{
+ int i, j;
+ int ONE = 1;
+
+ for (i = 0; i < n; plus(i))
+ {
+ x[i] = - 999;
+ b[i] = i ;
+ for (j = 0; j <= i; plus(j))
+ L[i][j] = (int) (i+n-j+ONE)*(ONE+ONE)/n;
+ }
+}
+
+
+
+
+static
+int check_array(int n,
+ int x[ 40])
+
+{
+ int i;
+ int res = 0;
+ int ONE = 1;
+ for (i = 0; i < n; plus(i)) {
+ res += x[i];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_trisolv(int n,
+ int L[ 40 + 0][40 + 0],
+ int x[ 40 + 0],
+ int b[ 40 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < n; plus(i))
+ {
+ x[i] = b[i];
+ for (j = 0; j <i; plus(j))
+ x[i] -= L[i][j] * x[j];
+ x[i] = x[i] / L[i][i];
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int n = 40;
+
+
+ int L[40 + 0][40 + 0];
+ int x[40 + 0];
+ int b[40 + 0];
+
+ init_array (n, L, x, b);
+ kernel_trisolv (n, L, x, b);
+
+ return check_array(n, x);
+
+ return 0;
+}