PandA-2024.02
template-for-new-benchmark.c
Go to the documentation of this file.
1 
10 #include <stdio.h>
11 #include <unistd.h>
12 #include <string.h>
13 #include <math.h>
14 
15 /* Include polybench common header. */
16 #include <polybench.h>
17 
18 /* Include benchmark-specific header. */
19 /* Default data type is double, default size is N=1024. */
20 #include "template-for-new-benchmark.h"
21 
22 
23 /* Array initialization. */
24 static
25 void init_array(int n, DATA_TYPE POLYBENCH_2D(C,N,N,n,n))
26 {
27  int i, j;
28 
29  for (i = 0; i < n; i++)
30  for (j = 0; j < n; j++)
31  C[i][j] = 42;
32 }
33 
34 
35 /* DCE code. Must scan the entire live-out data.
36  Can be used also to check the correctness of the output. */
37 static
39 {
40  int i, j;
41 
42  for (i = 0; i < n; i++)
43  for (j = 0; j < n; j++) {
44  fprintf (stderr, DATA_PRINTF_MODIFIER, C[i][j]);
45  if (i % 20 == 0) fprintf (stderr, "\n");
46  }
47  fprintf (stderr, "\n");
48 }
49 
50 
51 /* Main computational kernel. The whole function will be timed,
52  including the call and return. */
53 static
55 {
56  int i, j;
57 
58 #pragma scop
59  for (i = 0; i < _PB_N; i++)
60  for (j = 0; j < _PB_N; j++)
61  C[i][j] += 42;
62 #pragma endscop
63 
64 }
65 
66 
67 int main(int argc, char** argv)
68 {
69  /* Retrieve problem size. */
70  int n = N;
71 
72  /* Variable declaration/allocation. */
74 
75  /* Initialize array(s). */
77 
78  /* Start timer. */
80 
81  /* Run kernel. */
83 
84  /* Stop and print timer. */
87 
88  /* Prevent dead-code elimination. All live-out data must be printed
89  by the function call in argument. */
91 
92  /* Be clean. */
94 
95  return 0;
96 }
#define POLYBENCH_ARRAY(x)
Definition: polybench.h:84
static void kernel_template(int n, DATA_TYPE POLYBENCH_2D(C, N, N, n, n))
int main(int argc, char **argv)
#define C
Definition: generate.c:15
#define POLYBENCH_FREE_ARRAY(x)
Definition: polybench.h:88
#define POLYBENCH_2D(var, dim1, dim2, ddim1, ddim2)
Definition: polybench.h:98
static void print_array(int n, DATA_TYPE POLYBENCH_2D(C, N, N, n, n))
#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 _PB_N
Definition: correlation.h:49
static void init_array(int n, DATA_TYPE POLYBENCH_2D(C, N, N, n, n))
This version is stamped on May 10, 2016.
#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