aboutsummaryrefslogtreecommitdiffstats
path: root/benchmarks/polybench-syn/linear-algebra/blas
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/blas
parent3971466fbdd9aa1883a4468de3d67fdf90fee02d (diff)
downloadvericert-kvx-045c0dc29fc31a8d3f15da8b3130dbc4706ea581.tar.gz
vericert-kvx-045c0dc29fc31a8d3f15da8b3130dbc4706ea581.zip
Add modified polybench benchmarks
Diffstat (limited to 'benchmarks/polybench-syn/linear-algebra/blas')
-rw-r--r--benchmarks/polybench-syn/linear-algebra/blas/gemm.c111
-rw-r--r--benchmarks/polybench-syn/linear-algebra/blas/gemver.c152
-rw-r--r--benchmarks/polybench-syn/linear-algebra/blas/gesummv.c115
-rw-r--r--benchmarks/polybench-syn/linear-algebra/blas/symm.c110
-rw-r--r--benchmarks/polybench-syn/linear-algebra/blas/syr2k.c120
-rw-r--r--benchmarks/polybench-syn/linear-algebra/blas/syrk.c106
-rw-r--r--benchmarks/polybench-syn/linear-algebra/blas/trmm.c96
-rw-r--r--benchmarks/polybench-syn/linear-algebra/blas/trmm.preproc.c144
8 files changed, 954 insertions, 0 deletions
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/gemm.c b/benchmarks/polybench-syn/linear-algebra/blas/gemm.c
new file mode 100644
index 0000000..5a28f08
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/blas/gemm.c
@@ -0,0 +1,111 @@
+/**
+ * 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
+ */
+/* gemm.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 *alpha,
+ int *beta,
+ int C[ 20 + 0][25 + 0],
+ int A[ 20 + 0][30 + 0],
+ int B[ 30 + 0][25 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+ *alpha = 2;
+ *beta = 2;
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nj; plus(j))
+ C[i][j] = (int) ((i*j+ONE) % ni) / ni;
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nk; plus(j))
+ A[i][j] = (int) (i*(j+ONE) % nk) / nk;
+ for (i = 0; i < nk; plus(i))
+ for (j = 0; j < nj; plus(j))
+ B[i][j] = (int) (i*(j+ONE+ONE) % nj) / nj;
+}
+
+
+
+
+static
+int print_array(int ni, int nj,
+ int C[ 20 + 0][25 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int res = 0;
+ for (i = 0; i < ni; plus(i))
+ for (j = 0; j < nj; plus(j)) {
+ res ^= C[i][j];
+ }
+ return res;
+}
+
+static
+void kernel_gemm(int ni, int nj, int nk,
+ int alpha,
+ int beta,
+ int C[ 20 + 0][25 + 0],
+ int A[ 20 + 0][30 + 0],
+ int B[ 30 + 0][25 + 0])
+{
+ int i, j, k;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < ni; plus(i)) {
+ for (j = 0; j < nj; plus(j))
+ C[i][j] *= beta;
+ for (k = 0; k < nk; plus(k)) {
+ for (j = 0; j < nj; plus(j))
+ C[i][j] += alpha * A[i][k] * B[k][j];
+ }
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int ni = 20;
+ int nj = 25;
+ int nk = 30;
+
+
+ int alpha;
+ int beta;
+ int C[20 + 0][25 + 0];
+ int A[20 + 0][30 + 0];
+ int B[30 + 0][25 + 0];
+
+
+ init_array (ni, nj, nk, &alpha, &beta,
+ C,
+ A,
+ B);
+
+
+ kernel_gemm (ni, nj, nk,
+ alpha, beta,
+ C,
+ A,
+ B);
+
+
+ return
+ print_array(ni, nj, C);
+
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/gemver.c b/benchmarks/polybench-syn/linear-algebra/blas/gemver.c
new file mode 100644
index 0000000..a2711cb
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/blas/gemver.c
@@ -0,0 +1,152 @@
+/**
+ * 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
+ */
+/* gemver.c: this file is part of PolyBench/C */
+
+#define plus(i) i = i + ONE
+static
+void init_array (int n,
+ int *alpha,
+ int *beta,
+ int A[ 40 + 0][40 + 0],
+ int u1[ 40 + 0],
+ int v1[ 40 + 0],
+ int u2[ 40 + 0],
+ int v2[ 40 + 0],
+ int w[ 40 + 0],
+ int x[ 40 + 0],
+ int y[ 40 + 0],
+ int z[ 40 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+ *alpha = 3;
+ *beta = 2;
+
+ int fn = (int)n;
+
+ for (i = 0; i < n; plus(i))
+ {
+ u1[i] = i;
+ u2[i] = ((i+ONE)/fn)/2;
+ v1[i] = ((i+ONE)/fn)/4;
+ v2[i] = ((i+ONE)/fn)/6;
+ y[i] = ((i+ONE)/fn)/8;
+ z[i] = ((i+ONE)/fn)/9;
+ x[i] = 0;
+ w[i] = 0;
+ for (j = 0; j < n; plus(j))
+ A[i][j] = (int) (i*j % n) / n;
+ }
+}
+
+
+
+
+static
+int print_array(int n,
+ int w[ 40 + 0])
+{
+ int i;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < n; plus(i)) {
+ res ^= w[i];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_gemver(int n,
+ int alpha,
+ int beta,
+ int A[ 40 + 0][40 + 0],
+ int u1[ 40 + 0],
+ int v1[ 40 + 0],
+ int u2[ 40 + 0],
+ int v2[ 40 + 0],
+ int w[ 40 + 0],
+ int x[ 40 + 0],
+ int y[ 40 + 0],
+ int z[ 40 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+#pragma scop
+
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j))
+ A[i][j] = A[i][j] + u1[i] * v1[j] + u2[i] * v2[j];
+
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j))
+ x[i] = x[i] + beta * A[j][i] * y[j];
+
+ for (i = 0; i < n; plus(i))
+ x[i] = x[i] + z[i];
+
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j))
+ w[i] = w[i] + alpha * A[i][j] * x[j];
+
+#pragma endscop
+}
+
+
+int main()
+{
+
+ int n = 40;
+
+
+ int alpha;
+ int beta;
+ int A[40 + 0][40 + 0];
+ int u1[40 + 0];
+ int v1[40 + 0];
+ int u2[40 + 0];
+ int v2[40 + 0];
+ int w[40 + 0];
+ int x[40 + 0];
+ int y[40 + 0];
+ int z[40 + 0];
+
+
+
+ init_array (n, &alpha, &beta,
+ A,
+ u1,
+ v1,
+ u2,
+ v2,
+ w,
+ x,
+ y,
+ z);
+
+ kernel_gemver (n, alpha, beta,
+ A,
+ u1,
+ v1,
+ u2,
+ v2,
+ w,
+ x,
+ y,
+ z);
+
+ return print_array(n, w);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/gesummv.c b/benchmarks/polybench-syn/linear-algebra/blas/gesummv.c
new file mode 100644
index 0000000..606a581
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/blas/gesummv.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
+ */
+/* gesummv.c: this file is part of PolyBench/C */
+
+
+#define plus(i) i = i + ONE
+
+static
+void init_array(int n,
+ int *alpha,
+ int *beta,
+ int A[ 30 + 0][30 + 0],
+ int B[ 30 + 0][30 + 0],
+ int x[ 30 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+ *alpha = 3;
+ *beta = 2;
+ for (i = 0; i < n; plus(i))
+ {
+ x[i] = (int)( i % n) / n;
+ for (j = 0; j < n; plus(j)) {
+ A[i][j] = (int) ((i*j+ONE) % n) / n;
+ B[i][j] = (int) ((i*j+ONE+ONE) % n) / n;
+ }
+ }
+}
+
+
+
+
+static
+int print_array(int n,
+ int y[ 30 + 0])
+
+{
+ int i;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < n; plus(i)) {
+ res ^= y[i];
+ }
+ return res;
+}
+
+static
+void kernel_gesummv(int n,
+ int alpha,
+ int beta,
+ int A[ 30 + 0][30 + 0],
+ int B[ 30 + 0][30 + 0],
+ int tmp[ 30 + 0],
+ int x[ 30 + 0],
+ int y[ 30 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < n; plus(i))
+ {
+ tmp[i] = 0;
+ y[i] = 0;
+ for (j = 0; j < n; plus(j))
+ {
+ tmp[i] = A[i][j] * x[j] + tmp[i];
+ y[i] = B[i][j] * x[j] + y[i];
+ }
+ y[i] = alpha * tmp[i] + beta * y[i];
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int n = 30;
+
+
+ int alpha;
+ int beta;
+ int A[30 + 0][30 + 0];
+ int B[30 + 0][30 + 0];
+ int tmp[30 + 0];
+ int x[30 + 0];
+ int y[30 + 0];
+
+ init_array (n, &alpha, &beta,
+ A,
+ B,
+ x);
+
+ kernel_gesummv (n, alpha, beta,
+ A,
+ B,
+ tmp,
+ x,
+ y);
+
+
+ return print_array(n, y);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/symm.c b/benchmarks/polybench-syn/linear-algebra/blas/symm.c
new file mode 100644
index 0000000..a5e8539
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/blas/symm.c
@@ -0,0 +1,110 @@
+/**
+ * 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
+ */
+/* symm.c: this file is part of PolyBench/C */
+
+#define plus(i) i = i + ONE
+static
+void init_array(int m, int n,
+ int *alpha,
+ int *beta,
+ int C[ 20 + 0][30 + 0],
+ int A[ 20 + 0][20 + 0],
+ int B[ 20 + 0][30 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int HUND = 100;
+
+ *alpha = 3;
+ *beta = 2;
+ for (i = 0; i < m; plus(i))
+ for (j = 0; j < n; plus(j)) {
+ C[i][j] = (int) ((i+j) % HUND) / m;
+ B[i][j] = (int) ((n+i-j) % HUND) / m;
+ }
+ for (i = 0; i < m; plus(i)) {
+ for (j = 0; j <=i; plus(j))
+ A[i][j] = (int) ((i+j) % HUND) / m;
+ for (j = i+ONE; j < m; plus(j))
+ A[i][j] = -999;
+ }
+}
+
+static
+int print_array(int m, int n,
+ int C[ 20 + 0][30 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < m; plus(i))
+ for (j = 0; j < n; plus(j)) {
+ res ^= C[i][j];
+ }
+ return res;
+}
+
+
+static
+void kernel_symm(int m, int n,
+ int alpha,
+ int beta,
+ int C[ 20 + 0][30 + 0],
+ int A[ 20 + 0][20 + 0],
+ int B[ 20 + 0][30 + 0])
+{
+ int ONE = 1;
+ int i, j, k;
+ int temp2;
+#pragma scop
+ for (i = 0; i < m; plus(i))
+ for (j = 0; j < n; plus(j) )
+ {
+ temp2 = 0;
+ for (k = 0; k < i; plus(k)) {
+ C[k][j] += alpha*B[i][j] * A[i][k];
+ temp2 += B[k][j] * A[i][k];
+ }
+ C[i][j] = beta * C[i][j] + alpha*B[i][j] * A[i][i] + alpha * temp2;
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int m = 20;
+ int n = 30;
+
+ int alpha;
+ int beta;
+ int C[20 + 0][30 + 0];
+ int A[20 + 0][20 + 0];
+ int B[20 + 0][30 + 0];
+
+
+ init_array (m, n, &alpha, &beta,
+ C,
+ A,
+ B);
+
+ kernel_symm (m, n,
+ alpha, beta,
+ C,
+ A,
+ B);
+
+ return
+ print_array(m, n, C);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/syr2k.c b/benchmarks/polybench-syn/linear-algebra/blas/syr2k.c
new file mode 100644
index 0000000..82b4d3b
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/blas/syr2k.c
@@ -0,0 +1,120 @@
+/**
+ * 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
+ */
+/* syr2k.c: this file is part of PolyBench/C */
+
+
+#define plus(i) i = i + ONE
+static
+void init_array(int n, int m,
+ int *alpha,
+ int *beta,
+ int C[ 30 + 0][30 + 0],
+ int A[ 30 + 0][20 + 0],
+ int B[ 30 + 0][20 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+ *alpha = 3;
+ *beta = 2;
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < m; plus(j)) {
+ A[i][j] = (int) ((i*j+ONE)%n) / n;
+ B[i][j] = (int) ((i*j+ONE+ONE)%m) / m;
+ }
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j)) {
+ C[i][j] = (int) ((i*j+4-ONE)%n) / m;
+ }
+}
+
+
+
+
+static
+int print_array(int n,
+ int C[ 30 + 0][30 + 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 ^= C[i][j];
+ }
+ return res;
+}
+
+
+static
+void kernel_syr2k(int n, int m,
+ int alpha,
+ int beta,
+ int C[ 30 + 0][30 + 0],
+ int A[ 30 + 0][20 + 0],
+ int B[ 30 + 0][20 + 0])
+{
+ int i, j, k;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < n; plus(i)) {
+ for (j = 0; j <= i; plus(j))
+ C[i][j] *= beta;
+ for (k = 0; k < m; plus(k))
+ for (j = 0; j <= i; plus(j))
+ {
+ C[i][j] += A[j][k]*alpha*B[i][k] + B[j][k]*alpha*A[i][k];
+ }
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int n = 30;
+ int m = 20;
+
+
+ int alpha;
+ int beta;
+ int C[30 + 0][30 + 0];
+ int A[30 + 0][20 + 0];
+ int B[30 + 0][20 + 0];
+
+
+ init_array (n, m, &alpha, &beta,
+ C,
+ A,
+ B);
+
+
+ ;
+
+
+ kernel_syr2k (n, m,
+ alpha, beta,
+ C,
+ A,
+ B);
+
+
+ ;
+ ;
+
+
+
+ return print_array(n, C);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/syrk.c b/benchmarks/polybench-syn/linear-algebra/blas/syrk.c
new file mode 100644
index 0000000..dbf2e6b
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/blas/syrk.c
@@ -0,0 +1,106 @@
+/**
+ * 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
+ */
+/* syrk.c: this file is part of PolyBench/C */
+
+
+#define plus(i) i = i + ONE
+static
+void init_array(int n, int m,
+ int *alpha,
+ int *beta,
+ int C[ 30 + 0][30 + 0],
+ int A[ 30 + 0][20 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+ *alpha = 3;
+ *beta = 2;
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < m; plus(j))
+ A[i][j] = (int) ((i*j+ONE)%n) / n;
+ for (i = 0; i < n; plus(i))
+ for (j = 0; j < n; plus(j))
+ C[i][j] = (int) ((i*j+ONE+ONE)%m) / m;
+}
+
+
+static
+int print_array(int n,
+ int C[ 30 + 0][30 + 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 ^= C[i][j];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_syrk(int n, int m,
+ int alpha,
+ int beta,
+ int C[ 30 + 0][30 + 0],
+ int A[ 30 + 0][20 + 0])
+{
+ int i, j, k;
+ int ONE = 1;
+
+#pragma scop
+ for (i = 0; i < n; plus(i)) {
+ for (j = 0; j <= i; plus(j))
+ C[i][j] *= beta;
+ for (k = 0; k < m; plus(k)) {
+ for (j = 0; j <= i; plus(j))
+ C[i][j] += alpha * A[i][k] * A[j][k];
+ }
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int n = 30;
+ int m = 20;
+
+
+ int alpha;
+ int beta;
+ int C[30 + 0][30 + 0];
+ int A[30 + 0][20 + 0];
+
+
+ init_array (n, m, &alpha, &beta, C, A);
+
+
+ ;
+
+
+ kernel_syrk (n, m, alpha, beta, C, A);
+
+
+ ;
+ ;
+
+
+
+ return print_array(n, C);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/trmm.c b/benchmarks/polybench-syn/linear-algebra/blas/trmm.c
new file mode 100644
index 0000000..79b384d
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/blas/trmm.c
@@ -0,0 +1,96 @@
+/**
+ * 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
+ */
+/* trmm.c: this file is part of PolyBench/C */
+
+
+#define plus(i) i = i + ONE
+static
+void init_array(int m, int n,
+ int *alpha,
+ int A[ 20 + 0][20 + 0],
+ int B[ 20 + 0][30 + 0])
+{
+ int i, j;
+ int ONE = 1;
+
+ *alpha = 3;
+ for (i = 0; i < m; plus(i)) {
+ for (j = 0; j < i; plus(j)) {
+ A[i][j] = (int)((i+j) % m)/m;
+ }
+ A[i][i] = 1;
+ for (j = 0; j < n; plus(j)) {
+ B[i][j] = (int)((n+(i-j)) % n)/n;
+ }
+ }
+
+}
+
+
+
+
+static
+int print_array(int m, int n,
+ int B[ 20 + 0][30 + 0])
+{
+ int i, j;
+ int ONE = 1;
+ int res = 0;
+
+ for (i = 0; i < m; plus(i))
+ for (j = 0; j < n; plus(j)) {
+ res ^= B[i][j];
+ }
+ return res;
+}
+
+
+
+
+static
+void kernel_trmm(int m, int n,
+ int alpha,
+ int A[ 20 + 0][20 + 0],
+ int B[ 20 + 0][30 + 0])
+{
+ int i, j, k;
+ int ONE = 1;
+#pragma scop
+ for (i = 0; i < m; plus(i))
+ for (j = 0; j < n; plus(j)) {
+ for (k = i+ONE; k < m; plus(k))
+ B[i][j] += A[k][i] * B[k][j];
+ B[i][j] = alpha * B[i][j];
+ }
+#pragma endscop
+
+}
+
+
+int main()
+{
+
+ int m = 20;
+ int n = 30;
+
+
+ int alpha;
+ int A[20 + 0][20 + 0];
+ int B[20 + 0][30 + 0];
+
+
+ init_array (m, n, &alpha, A, B);
+
+
+ kernel_trmm (m, n, alpha, A, B);
+
+ return print_array(m, n, B);
+
+}
diff --git a/benchmarks/polybench-syn/linear-algebra/blas/trmm.preproc.c b/benchmarks/polybench-syn/linear-algebra/blas/trmm.preproc.c
new file mode 100644
index 0000000..9b8edfe
--- /dev/null
+++ b/benchmarks/polybench-syn/linear-algebra/blas/trmm.preproc.c
@@ -0,0 +1,144 @@
+/**
+ * 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
+ */
+/* trmm.c: this file is part of PolyBench/C */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <math.h>
+
+/* Include polybench common header. */
+#include<polybench.h>
+# 1 "trmm.c"
+# 1 "<built-in>" 1
+# 1 "<built-in>" 3
+# 362 "<built-in>" 3
+# 1 "<command line>" 1
+# 1 "<built-in>" 2
+# 1 "trmm.c" 2
+# 1 "utilities/polybench.h" 1
+# 30 "utilities/polybench.h"
+# 1 "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdlib.h" 1 3 4
+# 31 "utilities/polybench.h" 2
+# 231 "utilities/polybench.h"
+extern void* polybench_alloc_data(unsigned long long int n, int elt_size);
+extern void polybench_free_data(void* ptr);
+
+
+
+
+extern void polybench_flush_cache();
+extern void polybench_prepare_instruments();
+# 2 "trmm.c" 2
+
+
+# 1 "./linear-algebra/blas/trmm/trmm.h" 1
+# 5 "trmm.c" 2
+
+
+
+static
+void init_array(int m, int n,
+ int *alpha,
+ int A[ 20 + 0][20 + 0],
+ int B[ 20 + 0][30 + 0])
+{
+ int i, j;
+
+ *alpha = 1.5;
+ for (i = 0; i < m; i++) {
+ for (j = 0; j < i; j++) {
+ A[i][j] = (int)((i+j) % m)/m;
+ }
+ A[i][i] = 1.0;
+ for (j = 0; j < n; j++) {
+ B[i][j] = (int)((n+(i-j)) % n)/n;
+ }
+ }
+
+}
+
+
+
+
+static
+void print_array(int m, int n,
+ int B[ 20 + 0][30 + 0])
+{
+ int i, j;
+
+ fprintf(stderr, "==BEGIN DUMP_ARRAYS==\n");
+ fprintf(stderr, "begin dump: %s", "B");
+ for (i = 0; i < m; i++)
+ for (j = 0; j < n; j++) {
+ if ((i * m + j) % 20 == 0) fprintf (stderr, "\n");
+ fprintf (stderr, "%d ", B[i][j]);
+ }
+ fprintf(stderr, "\nend dump: %s\n", "B");
+ fprintf(stderr, "==END DUMP_ARRAYS==\n");
+}
+
+
+
+
+static
+void kernel_trmm(int m, int n,
+ int alpha,
+ int A[ 20 + 0][20 + 0],
+ int B[ 20 + 0][30 + 0])
+{
+ int i, j, k;
+# 68 "trmm.c"
+#pragma scop
+ for (i = 0; i < m; i++)
+ for (j = 0; j < n; j++) {
+ for (k = i+1; k < m; k++)
+ B[i][j] += A[k][i] * B[k][j];
+ B[i][j] = alpha * B[i][j];
+ }
+#pragma endscop
+
+}
+
+
+int main(int argc, char** argv)
+{
+
+ int m = 20;
+ int n = 30;
+
+
+ int alpha;
+ int (*A)[20 + 0][20 + 0]; A = (int(*)[20 + 0][20 + 0])polybench_alloc_data ((20 + 0) * (20 + 0), sizeof(int));;
+ int (*B)[20 + 0][30 + 0]; B = (int(*)[20 + 0][30 + 0])polybench_alloc_data ((20 + 0) * (30 + 0), sizeof(int));;
+
+
+ init_array (m, n, &alpha, *A, *B);
+
+
+ ;
+
+
+ kernel_trmm (m, n, alpha, *A, *B);
+
+
+ ;
+ ;
+
+
+
+ if (argc > 42 && ! strcmp(argv[0], "")) print_array(m, n, *B);
+
+
+ free((void*)A);;
+ free((void*)B);;
+
+ return 0;
+}