aboutsummaryrefslogtreecommitdiffstats
path: root/benchmarks/polybench-syn/linear-algebra/kernels
diff options
context:
space:
mode:
Diffstat (limited to 'benchmarks/polybench-syn/linear-algebra/kernels')
-rw-r--r--benchmarks/polybench-syn/linear-algebra/kernels/2mm.c128
-rw-r--r--benchmarks/polybench-syn/linear-algebra/kernels/3mm.c141
-rw-r--r--benchmarks/polybench-syn/linear-algebra/kernels/atas.c100
-rw-r--r--benchmarks/polybench-syn/linear-algebra/kernels/bicg.c115
-rw-r--r--benchmarks/polybench-syn/linear-algebra/kernels/doitgen.c100
-rw-r--r--benchmarks/polybench-syn/linear-algebra/kernels/mvt.c117
6 files changed, 701 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn/linear-algebra/kernels/2mm.c b/benchmarks/polybench-syn/linear-algebra/kernels/2mm.c
new file mode 100644
index 0000000..391e9ac
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/kernels/2mm.c
@@ -0,0 +1,128 @@
+/**
+ * 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
+ */
+/* 2mm.c: this file is part of PolyBench/C */
+
+
+#define plus(i) i = i + ONE
+static
+void init_array(int ni, int nj, int nk, int nl,
+ int *alpha,
+ int *beta,
+ int A[ 16 + 0][22 + 0],
+ int B[ 22 + 0][18 + 0],
+ int C[ 18 + 0][24 + 0],
+ int D[ 16 + 0][24 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+ *alpha = 2;
+ *beta = 2;
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nk; plus(j))
+ A[i][j] = (int) ((i*j+ONE) % ni) / ni;
+ for (i = 0; i < nk; plus(i))
+ for (j = 0; j < nj; plus(j))
+ B[i][j] = (int) (i*(j+ONE) % nj) / nj;
+ for (i = 0; i < nj; plus(i))
+ for (j = 0; j < nl; plus(j))
+ C[i][j] = (int) ((i*(j+ONE+ONE+ONE)+ONE) % nl) / nl;
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nl; plus(j))
+ D[i][j] = (int) (i*(j+ONE+ONE) % nk) / nk;
+}
+
+static
+int print_array(int ni, int nl,
+ int D[ 16 + 0][24 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int res = 0;
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nl; plus(j)) {
+ res ^= D[i][j];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_2mm(int ni, int nj, int nk, int nl,
+ int alpha,
+ int beta,
+ int tmp[ 16 + 0][18 + 0],
+ int A[ 16 + 0][22 + 0],
+ int B[ 22 + 0][18 + 0],
+ int C[ 18 + 0][24 + 0],
+ int D[ 16 + 0][24 + 0])
+{
+ int ONE = 1;
+ int i, j, k;
+
+#pragma scop
+
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nj; plus(j))
+ {
+ tmp[i][j] = 0;
+ for (k = 0; k < nk; plus(k))
+ tmp[i][j] += alpha * A[i][k] * B[k][j];
+ }
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nl; plus(j))
+ {
+ D[i][j] *= beta;
+ for (k = 0; k < nj; plus(k))
+ D[i][j] += tmp[i][k] * C[k][j];
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int ni = 16;
+ int nj = 18;
+ int nk = 22;
+ int nl = 24;
+
+ int alpha;
+ int beta;
+ int tmp[16 + 0][18 + 0];
+ int A[16 + 0][22 + 0];
+ int B[22 + 0][18 + 0];
+ int C[18 + 0][24 + 0];
+ int D[16 + 0][24 + 0];
+
+
+ init_array (ni, nj, nk, nl, &alpha, &beta,
+ A,
+ B,
+ C,
+ D);
+
+
+ kernel_2mm (ni, nj, nk, nl,
+ alpha, beta,
+ tmp,
+ A,
+ B,
+ C,
+ D);
+
+
+ return print_array(ni, nl, D);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/kernels/3mm.c b/benchmarks/polybench-syn/linear-algebra/kernels/3mm.c
new file mode 100644
index 0000000..e565fb5
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/kernels/3mm.c
@@ -0,0 +1,141 @@
+/**
+ * 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
+ */
+/* 3mm.c: this file is part of PolyBench/C */
+
+#define plus(i) i = i + ONE
+static
+void init_array(int ni, int nj, int nk, int nl, int nm,
+ int A[ 16 + 0][20 + 0],
+ int B[ 20 + 0][18 + 0],
+ int C[ 18 + 0][24 + 0],
+ int D[ 24 + 0][22 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int TWO = 2;
+ int THREE = 3;
+ int FIVE = 5;
+
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nk; plus(j))
+ A[i][j] = (int) ((i*j+ONE) % ni) / (5*ni);
+ for (i = 0; i < nk; plus(i))
+ for (j = 0; j < nj; plus(j))
+ B[i][j] = (int) ((i*(j+ONE)+TWO) % nj) / (5*nj);
+ for (i = 0; i < nj; plus(i))
+ for (j = 0; j < nm; plus(j))
+ C[i][j] = (int) (i*(j+THREE) % nl) / (5*nl);
+ for (i = 0; i < nm; plus(i))
+ for (j = 0; j < nl; plus(j))
+ D[i][j] = (int) ((i*(j+TWO)+TWO) % nk) / (5*nk);
+}
+
+
+
+
+static
+int print_array(int ni, int nl,
+ int G[ 16 + 0][22 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nl; plus(j)) {
+ res ^= G[i][j];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_3mm(int ni, int nj, int nk, int nl, int nm,
+ int E[ 16 + 0][18 + 0],
+ int A[ 16 + 0][20 + 0],
+ int B[ 20 + 0][18 + 0],
+ int F[ 18 + 0][22 + 0],
+ int C[ 18 + 0][24 + 0],
+ int D[ 24 + 0][22 + 0],
+ int G[ 16 + 0][22 + 0])
+{
+ int ONE = 1;
+ int i, j, k;
+
+#pragma scop
+
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nj; plus(j))
+ {
+ E[i][j] = 0;
+ for (k = 0; k < nk; plus(k))
+ E[i][j] += A[i][k] * B[k][j];
+ }
+
+ for (i = 0; i < nj; plus(i))
+ for (j = 0; j < nl; plus(j))
+ {
+ F[i][j] = 0;
+ for (k = 0; k < nm; plus(k))
+ F[i][j] += C[i][k] * D[k][j];
+ }
+
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nl; plus(j))
+ {
+ G[i][j] = 0;
+ for (k = 0; k < nj; plus(k))
+ G[i][j] += E[i][k] * F[k][j];
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int ni = 16;
+ int nj = 18;
+ int nk = 20;
+ int nl = 22;
+ int nm = 24;
+
+
+ int E[16 + 0][18 + 0];
+ int A[16 + 0][20 + 0];
+ int B[20 + 0][18 + 0];
+ int F[18 + 0][22 + 0];
+ int C[18 + 0][24 + 0];
+ int D[24 + 0][22 + 0];
+ int G[16 + 0][22 + 0];
+
+
+ init_array (ni, nj, nk, nl, nm,
+ A,
+ B,
+ C,
+ D);
+
+ kernel_3mm (ni, nj, nk, nl, nm,
+ E,
+ A,
+ B,
+ F,
+ C,
+ D,
+ G);
+
+
+ return print_array(ni, nl, G);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/kernels/atas.c b/benchmarks/polybench-syn/linear-algebra/kernels/atas.c
new file mode 100644
index 0000000..a051046
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/kernels/atas.c
@@ -0,0 +1,100 @@
+/**
+ * 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
+ */
+/* atax.c: this file is part of PolyBench/C */
+
+#define plus(i) i = i + ONE
+static
+void init_array (int m, int n,
+ int A[ 38 + 0][42 + 0],
+ int x[ 42 + 0])
+{
+ int ONE = 1;
+ int i, j;
+ int fn;
+ fn = (int)n;
+
+ for (i = 0; i < n; plus(i))
+ x[i] = ONE + (i / fn);
+ for (i = 0; i < m; plus(i))
+ for (j = 0; j < n; plus(j))
+ A[i][j] = (int) ((i+j) % n) / (5*m);
+}
+
+
+
+
+static
+int print_array(int n,
+ int y[ 42 + 0])
+
+{
+ int i;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < n; plus(i)) {
+ res ^= y[i];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_atax(int m, int n,
+ int A[ 38 + 0][42 + 0],
+ int x[ 42 + 0],
+ int y[ 42 + 0],
+ int tmp[ 38 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < n; plus(i))
+ y[i] = 0;
+ for (i = 0; i < m; plus(i))
+ {
+ tmp[i] = 0;
+ for (j = 0; j < n; plus(j))
+ tmp[i] = tmp[i] + A[i][j] * x[j];
+ for (j = 0; j < n; plus(j))
+ y[j] = y[j] + A[i][j] * tmp[i];
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int m = 38;
+ int n = 42;
+
+
+ int A[38 + 0][42 + 0];
+ int x[42 + 0];
+ int y[42 + 0];
+ int tmp[38 + 0];
+
+ init_array (m, n, A, x);
+
+ kernel_atax (m, n,
+ A,
+ x,
+ y,
+ tmp);
+
+
+ return print_array(n, y);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/kernels/bicg.c b/benchmarks/polybench-syn/linear-algebra/kernels/bicg.c
new file mode 100644
index 0000000..48b7658
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/kernels/bicg.c
@@ -0,0 +1,115 @@
+/**
+ * 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
+ */
+/* bicg.c: this file is part of PolyBench/C */
+
+
+#define plus(i) i = i + ONE
+static
+void init_array (int m, int n,
+ int A[ 42 + 0][38 + 0],
+ int r[ 42 + 0],
+ int p[ 38 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+ for (i = 0; i < m; plus(i))
+ p[i] = (int)(i % m) / m;
+ for (i = 0; i < n; plus(i)) {
+ r[i] = (int)(i % n) / n;
+ for (j = 0; j < m; plus(j))
+ A[i][j] = (int) (i*(j+ONE) % n)/n;
+ }
+}
+
+
+
+
+static
+int print_array(int m, int n,
+ int s[ 38 + 0],
+ int q[ 42 + 0])
+
+{
+ int i;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < m; plus(i)) {
+ res ^= s[i];
+ }
+ for (i = 0; i < n; plus(i)) {
+ res ^= q[i];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_bicg(int m, int n,
+ int A[ 42 + 0][38 + 0],
+ int s[ 38 + 0],
+ int q[ 42 + 0],
+ int p[ 38 + 0],
+ int r[ 42 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < m; plus(i))
+ s[i] = 0;
+ for (i = 0; i < n; plus(i))
+ {
+ q[i] = 0;
+ for (j = 0; j < m; plus(j))
+ {
+ s[j] = s[j] + r[i] * A[i][j];
+ q[i] = q[i] + A[i][j] * p[j];
+ }
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int n = 42;
+ int m = 38;
+
+
+ int A[42 + 0][38 + 0];
+ int s[38 + 0];
+ int q[42 + 0];
+ int p[38 + 0];
+ int r[42 + 0];
+
+
+ init_array (m, n,
+ A,
+ r,
+ p);
+
+ kernel_bicg (m, n,
+ A,
+ s,
+ q,
+ p,
+ r);
+
+
+ return print_array(m, n, s, q);
+
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/kernels/doitgen.c b/benchmarks/polybench-syn/linear-algebra/kernels/doitgen.c
new file mode 100644
index 0000000..20de1df
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/kernels/doitgen.c
@@ -0,0 +1,100 @@
+/**
+ * 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
+ */
+/* doitgen.c: this file is part of PolyBench/C */
+
+#define plus(i) i = i + ONE
+static
+void init_array(int nr, int nq, int np,
+ int A[ 10 + 0][8 + 0][12 + 0],
+ int C4[ 12 + 0][12 + 0])
+{
+ int i, j, k;
+ int ONE = 1;
+
+ for (i = 0; i < nr; plus(i))
+ for (j = 0; j < nq; plus(j))
+ for (k = 0; k < np; plus(k))
+ A[i][j][k] = (int) ((i*j + k)%np) / np;
+ for (i = 0; i < np; plus(i))
+ for (j = 0; j < np; plus(j))
+ C4[i][j] = (int) (i*j % np) / np;
+}
+
+
+static
+int print_array(int nr, int nq, int np,
+ int A[ 10 + 0][8 + 0][12 + 0])
+{
+ int i, j, k;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < nr; plus(i))
+ for (j = 0; j < nq; plus(j))
+ for (k = 0; k < np; plus(k)) {
+ res ^= A[i][j][k];
+ }
+ return res;
+}
+
+
+
+
+void kernel_doitgen(int nr, int nq, int np,
+ int A[ 10 + 0][8 + 0][12 + 0],
+ int C4[ 12 + 0][12 + 0],
+ int sum[ 12 + 0])
+{
+ int r, q, p, s;
+ int ONE = 1;
+
+#pragma scop
+ for (r = 0; r < nr; plus(r))
+ for (q = 0; q < nq; plus(q)) {
+ for (p = 0; p < np; plus(p)) {
+ sum[p] = 0;
+ for (s = 0; s < np; plus(s))
+ sum[p] += A[r][q][s] * C4[s][p];
+ }
+ for (p = 0; p < np; plus(p))
+ A[r][q][p] = sum[p];
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int nr = 10;
+ int nq = 8;
+ int np = 12;
+
+
+ int A[10 + 0][8 + 0][12 + 0];
+ int sum[12 + 0];
+ int C4[12 + 0][12 + 0];
+
+
+ init_array (nr, nq, np,
+ A,
+ C4);
+
+
+ kernel_doitgen (nr, nq, np,
+ A,
+ C4,
+ sum);
+
+
+
+ return print_array(nr, nq, np, A);
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/kernels/mvt.c b/benchmarks/polybench-syn/linear-algebra/kernels/mvt.c
new file mode 100644
index 0000000..aa68b1c
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/kernels/mvt.c
@@ -0,0 +1,117 @@
+/**
+ * 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
+ */
+/* mvt.c: this file is part of PolyBench/C */
+
+#define plus(i) i = i + ONE
+
+static
+void init_array(int n,
+ int x1[ 40 + 0],
+ int x2[ 40 + 0],
+ int y_1[ 40 + 0],
+ int y_2[ 40 + 0],
+ int A[ 40 + 0][40 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int THREE = 3;
+
+ for (i = 0; i < n; plus(i))
+ {
+ x1[i] = (int) (i % n) / n;
+ x2[i] = (int) ((i + ONE) % n) / n;
+ y_1[i] = (int) ((i + THREE) % n) / n;
+ y_2[i] = (int) ((i + 4) % n) / n;
+ for (j = 0; j < n; plus(j))
+ A[i][j] = (int) (i*j % n) / n;
+ }
+}
+
+
+
+
+static
+int print_array(int n,
+ int x1[ 40 + 0],
+ int x2[ 40 + 0])
+
+{
+ int i;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < n; plus(i)) {
+ res ^= x1[i];
+ }
+
+ for (i = 0; i < n; plus(i)) {
+ res ^= x2[i];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_mvt(int n,
+ int x1[ 40 + 0],
+ int x2[ 40 + 0],
+ int y_1[ 40 + 0],
+ int y_2[ 40 + 0],
+ int A[ 40 + 0][40 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j))
+ x1[i] = x1[i] + A[i][j] * y_1[j];
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j))
+ x2[i] = x2[i] + A[j][i] * y_2[j];
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int n = 40;
+
+
+ int A[40 + 0][40 + 0];
+ int x1[40 + 0];
+ int x2[40 + 0];
+ int y_1[40 + 0];
+ int y_2[40 + 0];
+
+
+
+ init_array (n,
+ x1,
+ x2,
+ y_1,
+ y_2,
+ A);
+
+
+ kernel_mvt (n,
+ x1,
+ x2,
+ y_1,
+ y_2,
+ A);
+
+ return print_array(n, x1, x2);
+
+}