PandA-2024.02
durbin.c
Go to the documentation of this file.
1 
10 /* durbin.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 "durbin.h"
22 
23 
24 /* Array initialization. */
25 static
26 void init_array (int n,
28 {
29  int i, j;
30 
31  for (i = 0; i < n; i++)
32  {
33  r[i] = (n+1-i);
34  }
35 }
36 
37 
38 /* DCE code. Must scan the entire live-out data.
39  Can be used also to check the correctness of the output. */
40 static
41 void print_array(int n,
43 
44 {
45  int i;
46 
49  for (i = 0; i < n; i++) {
50  if (i % 20 == 0) fprintf (POLYBENCH_DUMP_TARGET, "\n");
52  }
53  POLYBENCH_DUMP_END("y");
55 }
56 
57 
58 /* Main computational kernel. The whole function will be timed,
59  including the call and return. */
60 __attribute__((noinline))
61 void kernel_durbin(int n,
64 {
65  DATA_TYPE z[N];
66  DATA_TYPE alpha;
67  DATA_TYPE beta;
68  DATA_TYPE sum;
69 
70  int i,k;
71 
72 #pragma scop
73  y[0] = -r[0];
74  beta = SCALAR_VAL(1.0);
75  alpha = -r[0];
76 
77  for (k = 1; k < _PB_N; k++) {
78  beta = (1-alpha*alpha)*beta;
79  sum = SCALAR_VAL(0.0);
80  for (i=0; i<k; i++) {
81  sum += r[k-i-1]*y[i];
82  }
83  alpha = - (r[k] + sum)/beta;
84 
85  for (i=0; i<k; i++) {
86  z[i] = y[i] + alpha*y[k-i-1];
87  }
88  for (i=0; i<k; i++) {
89  y[i] = z[i];
90  }
91  y[k] = alpha;
92  }
93 #pragma endscop
94 
95 }
96 
97 
98 int main(int argc, char** argv)
99 {
100  /* Retrieve problem size. */
101  int n = N;
102 
103  /* Variable declaration/allocation. */
106 
107 
108  /* Initialize array(s). */
109  init_array (n, POLYBENCH_ARRAY(r));
110 
111  /* Start timer. */
113 
114  /* Run kernel. */
115  kernel_durbin (n,
116  POLYBENCH_ARRAY(r),
117  POLYBENCH_ARRAY(y));
118 
119  /* Stop and print timer. */
122 
123  /* Prevent dead-code elimination. All live-out data must be printed
124  by the function call in argument. */
126 
127  /* Be clean. */
130 
131  return 0;
132 }
#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
static void init_array(int n, DATA_TYPE POLYBENCH_1D(r, N, n))
This version is stamped on May 10, 2016.
Definition: durbin.c:26
int sum
Definition: dotproduct.h:3
int main(int argc, char **argv)
Definition: durbin.c:98
static const uint32_t k[]
Definition: sha-256.c:22
#define POLYBENCH_DUMP_START
Definition: polybench.h:165
#define N
Definition: dfdiv.c:60
#define DATA_PRINTF_MODIFIER
Definition: correlation.h:73
#define polybench_prevent_dce(func)
Definition: polybench.h:170
#define SCALAR_VAL(x)
Definition: correlation.h:74
__attribute__((noinline))
Convert the given fixedpt number to a decimal string.
Definition: durbin.c:60
#define POLYBENCH_DUMP_TARGET
Definition: polybench.h:164
#define POLYBENCH_DUMP_END(s)
Definition: polybench.h:168
#define POLYBENCH_1D(var, dim1, ddim1)
Definition: polybench.h:97
#define POLYBENCH_DUMP_FINISH
Definition: polybench.h:166
#define POLYBENCH_1D_ARRAY_DECL(var, type, dim1, ddim1)
Definition: polybench.h:128
#define _PB_N
Definition: correlation.h:49
#define polybench_stop_instruments
Definition: polybench.h:177
#define polybench_print_instruments
Definition: polybench.h:178
static void print_array(int n, DATA_TYPE POLYBENCH_1D(y, N, n))
Definition: durbin.c:41
#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