aboutsummaryrefslogtreecommitdiffstats
path: root/benchmarks/polybench-syn-div/linear-algebra/blas/symm.c
blob: 6c20b5be389a2c88118e6465035ecbfdaf256bff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
 * 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 */

#ifndef SYNTHESIS
  #include <stdio.h>
#endif
#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];
    }
#ifndef SYNTHESIS
  printf("finished %u\n", res);
#endif
    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;
 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;
     }

}


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);

}