PandA-2024.02
trmm.c
Go to the documentation of this file.
1 
10 /* trmm.c: this file is part of PolyBench/C */
11 
12 #include <stdio.h>
13 #include <unistd.h>
14 #include <string.h>
15 #include <math.h>
16 
17 /* Include polybench common header. */
18 #include <polybench.h>
19 
20 /* Include benchmark-specific header. */
21 #include "trmm.h"
22 
23 
24 /* Array initialization. */
25 static
26 void init_array(int m, int n,
27  DATA_TYPE *alpha,
28  DATA_TYPE POLYBENCH_2D(A,M,M,m,m),
29  DATA_TYPE POLYBENCH_2D(B,M,N,m,n))
30 {
31  int i, j;
32 
33  *alpha = 1.5;
34  for (i = 0; i < m; i++) {
35  for (j = 0; j < i; j++) {
36  A[i][j] = (DATA_TYPE)((i+j) % m)/m;
37  }
38  A[i][i] = 1.0;
39  for (j = 0; j < n; j++) {
40  B[i][j] = (DATA_TYPE)((n+(i-j)) % n)/n;
41  }
42  }
43 
44 }
45 
46 
47 /* DCE code. Must scan the entire live-out data.
48  Can be used also to check the correctness of the output. */
49 static
50 void print_array(int m, int n,
51  DATA_TYPE POLYBENCH_2D(B,M,N,m,n))
52 {
53  int i, j;
54 
57  for (i = 0; i < m; i++)
58  for (j = 0; j < n; j++) {
59  if ((i * m + j) % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n");
61  }
62  POLYBENCH_DUMP_END("B");
64 }
65 
66 
67 /* Main computational kernel. The whole function will be timed,
68  including the call and return. */
69 __attribute__((noinline))
70 void kernel_trmm(int m, int n,
71  DATA_TYPE alpha,
72  DATA_TYPE POLYBENCH_2D(A,M,M,m,m),
73  DATA_TYPE POLYBENCH_2D(B,M,N,m,n))
74 {
75  int i, j, k;
76 
77 //BLAS parameters
78 //SIDE = 'L'
79 //UPLO = 'L'
80 //TRANSA = 'T'
81 //DIAG = 'U'
82 // => Form B := alpha*A**T*B.
83 // A is MxM
84 // B is MxN
85 #pragma scop
86  for (i = 0; i < _PB_M; i++)
87  for (j = 0; j < _PB_N; j++) {
88  for (k = i+1; k < _PB_M; k++)
89  B[i][j] += A[k][i] * B[k][j];
90  B[i][j] = alpha * B[i][j];
91  }
92 #pragma endscop
93 
94 }
95 
96 
97 int main(int argc, char** argv)
98 {
99  /* Retrieve problem size. */
100  int m = M;
101  int n = N;
102 
103  /* Variable declaration/allocation. */
104  DATA_TYPE alpha;
107 
108  /* Initialize array(s). */
109  init_array (m, n, &alpha, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B));
110 
111  /* Start timer. */
113 
114  /* Run kernel. */
115  kernel_trmm (m, n, alpha, POLYBENCH_ARRAY(A), POLYBENCH_ARRAY(B));
116 
117  /* Stop and print timer. */
120 
121  /* Prevent dead-code elimination. All live-out data must be printed
122  by the function call in argument. */
124 
125  /* Be clean. */
128 
129  return 0;
130 }
int main(int argc, char **argv)
Definition: trmm.c:97
#define POLYBENCH_ARRAY(x)
Definition: polybench.h:84
#define POLYBENCH_DUMP_BEGIN(s)
Definition: polybench.h:167
#define POLYBENCH_FREE_ARRAY(x)
Definition: polybench.h:88
__attribute__((noinline))
Convert the given fixedpt number to a decimal string.
Definition: trmm.c:69
static void print_array(int m, int n, DATA_TYPE POLYBENCH_2D(B, M, N, m, n))
Definition: trmm.c:50
#define POLYBENCH_2D(var, dim1, dim2, ddim1, ddim2)
Definition: polybench.h:98
static void init_array(int m, int n, DATA_TYPE *alpha, DATA_TYPE POLYBENCH_2D(A, M, M, m, m), DATA_TYPE POLYBENCH_2D(B, M, N, m, n))
This version is stamped on May 10, 2016.
Definition: trmm.c:26
#define A
Definition: generate.c:13
static const uint32_t k[]
Definition: sha-256.c:22
#define POLYBENCH_DUMP_START
Definition: polybench.h:165
#define _PB_M
Definition: correlation.h:48
#define N
Definition: dfdiv.c:60
#define POLYBENCH_2D_ARRAY_DECL(var, type, dim1, dim2, ddim1, ddim2)
Definition: polybench.h:131
#define DATA_PRINTF_MODIFIER
Definition: correlation.h:73
#define polybench_prevent_dce(func)
Definition: polybench.h:170
#define POLYBENCH_DUMP_TARGET
Definition: polybench.h:164
#define POLYBENCH_DUMP_END(s)
Definition: polybench.h:168
#define M
Definition: gsm.c:30
#define POLYBENCH_DUMP_FINISH
Definition: polybench.h:166
#define _PB_N
Definition: correlation.h:49
#define B
Definition: generate.c:14
#define polybench_stop_instruments
Definition: polybench.h:177
#define polybench_print_instruments
Definition: polybench.h:178
#define polybench_start_instruments
Definition: polybench.h:176
#define DATA_TYPE
Definition: correlation.h:72

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13