source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/utilities/template-for-new-benchmark.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100755
File size: 2.0 KB
RevLine 
[a1acb0c5]1/**
2 * template.c: This file is part of the PolyBench/C 3.2 test suite.
3 *
4 *
5 * Contact: Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
6 * Web address: http://polybench.sourceforge.net
7 * License: /LICENSE.OSU.txt
8 */
9#include <stdio.h>
10#include <unistd.h>
11#include <string.h>
12#include <math.h>
13
14/* Include polybench common header. */
15#include <polybench.h>
16
17/* Include benchmark-specific header. */
18/* Default data type is double, default size is N=1024. */
19#include "template-for-new-benchmark.h"
20
21
22/* Array initialization. */
23static
24void init_array(int n, DATA_TYPE POLYBENCH_2D(C,N,N,n,n))
25{
26 int i, j;
27
28 for (i = 0; i < n; i++)
29 for (j = 0; j < n; j++)
30 C[i][j] = 42;
31}
32
33
34/* DCE code. Must scan the entire live-out data.
35 Can be used also to check the correctness of the output. */
36static
37void print_array(int n, DATA_TYPE POLYBENCH_2D(C,N,N,n,n))
38{
39 int i, j;
40
41 for (i = 0; i < n; i++)
42 for (j = 0; j < n; j++) {
43 fprintf (stderr, DATA_PRINTF_MODIFIER, C[i][j]);
44 if (i % 20 == 0) fprintf (stderr, "\n");
45 }
46 fprintf (stderr, "\n");
47}
48
49
50/* Main computational kernel. The whole function will be timed,
51 including the call and return. */
52static
53void kernel_template(int n, DATA_TYPE POLYBENCH_2D(C,N,N,n,n))
54{
55 int i, j;
56
57#pragma scop
58 for (i = 0; i < _PB_N; i++)
59 for (j = 0; j < _PB_N; j++)
60 C[i][j] += 42;
61#pragma endscop
62
63}
64
65
66int main(int argc, char** argv)
67{
68 /* Retrieve problem size. */
69 int n = N;
70
71 /* Variable declaration/allocation. */
72 POLYBENCH_2D_ARRAY_DECL(C,DATA_TYPE,N,N,n,n);
73
74 /* Initialize array(s). */
75 init_array (n, POLYBENCH_ARRAY(C));
76
77 /* Start timer. */
78 polybench_start_instruments;
79
80 /* Run kernel. */
81 kernel_template (n, POLYBENCH_ARRAY(C));
82
83 /* Stop and print timer. */
84 polybench_stop_instruments;
85 polybench_print_instruments;
86
87 /* Prevent dead-code elimination. All live-out data must be printed
88 by the function call in argument. */
89 polybench_prevent_dce(print_array(n, POLYBENCH_ARRAY(C)));
90
91 /* Be clean. */
92 POLYBENCH_FREE_ARRAY(C);
93
94 return 0;
95}
Note: See TracBrowser for help on using the repository browser.