source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/DRB044-adi-tile-no.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 100644
File size: 7.7 KB
Line 
1/**
2 * adi.c: This file is part of the PolyBench/C 3.2 test suite.
3 * Alternating Direction Implicit solver with tiling and nested SIMD.
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/* Include polybench common header. */
14#include "polybench/polybench.h"
15/* Include benchmark-specific header. */
16/* Default data type is double, default size is 10x1024x1024. */
17#include "polybench/adi.h"
18/* Array initialization. */
19
20static void init_array(int n,double X[500 + 0][500 + 0],double A[500 + 0][500 + 0],double B[500 + 0][500 + 0])
21{
22 //int i;
23 //int j;
24{
25 int c1;
26 int c3;
27 int c2;
28 int c4;
29 if (n >= 1) {
30#pragma omp parallel for private(c4, c2, c3)
31 for (c1 = 0; c1 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c1++) {
32 for (c2 = 0; c2 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c2++) {
33 for (c3 = 16 * c1; c3 <= ((16 * c1 + 15 < n + -1?16 * c1 + 15 : n + -1)); c3++) {
34#pragma omp simd
35 for (c4 = 16 * c2; c4 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c4++) {
36 X[c3][c4] = (((double )c3) * (c4 + 1) + 1) / n;
37 A[c3][c4] = (((double )c3) * (c4 + 2) + 2) / n;
38 B[c3][c4] = (((double )c3) * (c4 + 3) + 3) / n;
39 }
40 }
41 }
42 }
43 }
44 }
45}
46/* DCE code. Must scan the entire live-out data.
47 Can be used also to check the correctness of the output. */
48
49static void print_array(int n,double X[500 + 0][500 + 0])
50{
51 int i;
52 int j;
53 for (i = 0; i < n; i++)
54 for (j = 0; j < n; j++) {
55 fprintf(stderr,"%0.2lf ",X[i][j]);
56 if ((i * 500 + j) % 20 == 0)
57 fprintf(stderr,"\n");
58 }
59 fprintf(stderr,"\n");
60}
61/* Main computational kernel. The whole function will be timed,
62 including the call and return. */
63
64static void kernel_adi(int tsteps,int n,double X[500 + 0][500 + 0],double A[500 + 0][500 + 0],double B[500 + 0][500 + 0])
65{
66 //int t;
67 //int i1;
68 //int i2;
69
70 //#pragma scop
71{
72 int c0;
73 int c2;
74 int c8;
75 int c9;
76 int c15;
77 if (n >= 1 && tsteps >= 1) {
78 for (c0 = 0; c0 <= tsteps + -1; c0++) {
79 if (n >= 2) {
80#pragma omp parallel for private(c15, c9, c8)
81 for (c2 = 0; c2 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c2++) {
82 for (c8 = 0; c8 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c8++) {
83 for (c9 = (1 > 16 * c8?1 : 16 * c8); c9 <= ((16 * c8 + 15 < n + -1?16 * c8 + 15 : n + -1)); c9++) {
84#pragma omp simd
85 for (c15 = 16 * c2; c15 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c15++) {
86 B[c15][c9] = B[c15][c9] - A[c15][c9] * A[c15][c9] / B[c15][c9 - 1];
87 }
88 }
89 }
90 for (c8 = 0; c8 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c8++) {
91 for (c9 = (1 > 16 * c8?1 : 16 * c8); c9 <= ((16 * c8 + 15 < n + -1?16 * c8 + 15 : n + -1)); c9++) {
92#pragma omp simd
93 for (c15 = 16 * c2; c15 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c15++) {
94 X[c15][c9] = X[c15][c9] - X[c15][c9 - 1] * A[c15][c9] / B[c15][c9 - 1];
95 }
96 }
97 }
98 for (c8 = 0; c8 <= (((n + -3) * 16 < 0?((16 < 0?-((-(n + -3) + 16 + 1) / 16) : -((-(n + -3) + 16 - 1) / 16))) : (n + -3) / 16)); c8++) {
99 for (c9 = 16 * c8; c9 <= ((16 * c8 + 15 < n + -3?16 * c8 + 15 : n + -3)); c9++) {
100#pragma omp simd
101 for (c15 = 16 * c2; c15 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c15++) {
102 X[c15][n - c9 - 2] = (X[c15][n - 2 - c9] - X[c15][n - 2 - c9 - 1] * A[c15][n - c9 - 3]) / B[c15][n - 3 - c9];
103 }
104 }
105 }
106 }
107 }
108#pragma omp parallel for private(c15)
109 for (c2 = 0; c2 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c2++) {
110#pragma omp simd
111 for (c15 = 16 * c2; c15 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c15++) {
112 X[c15][n - 1] = X[c15][n - 1] / B[c15][n - 1];
113 }
114 }
115 if (n >= 2) {
116#pragma omp parallel for private(c15, c9, c8)
117 for (c2 = 0; c2 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c2++) {
118 for (c8 = 0; c8 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c8++) {
119 for (c9 = (1 > 16 * c8?1 : 16 * c8); c9 <= ((16 * c8 + 15 < n + -1?16 * c8 + 15 : n + -1)); c9++) {
120#pragma omp simd
121 for (c15 = 16 * c2; c15 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c15++) {
122 B[c9][c15] = B[c9][c15] - A[c9][c15] * A[c9][c15] / B[c9 - 1][c15];
123 }
124 }
125 }
126 for (c8 = 0; c8 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c8++) {
127 for (c9 = (1 > 16 * c8?1 : 16 * c8); c9 <= ((16 * c8 + 15 < n + -1?16 * c8 + 15 : n + -1)); c9++) {
128#pragma omp simd
129 for (c15 = 16 * c2; c15 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c15++) {
130 X[c9][c15] = X[c9][c15] - X[c9 - 1][c15] * A[c9][c15] / B[c9 - 1][c15];
131 }
132 }
133 }
134 for (c8 = 0; c8 <= (((n + -3) * 16 < 0?((16 < 0?-((-(n + -3) + 16 + 1) / 16) : -((-(n + -3) + 16 - 1) / 16))) : (n + -3) / 16)); c8++) {
135 for (c9 = 16 * c8; c9 <= ((16 * c8 + 15 < n + -3?16 * c8 + 15 : n + -3)); c9++) {
136#pragma omp simd
137 for (c15 = 16 * c2; c15 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c15++) {
138 X[n - 2 - c9][c15] = (X[n - 2 - c9][c15] - X[n - c9 - 3][c15] * A[n - 3 - c9][c15]) / B[n - 2 - c9][c15];
139 }
140 }
141 }
142 }
143 }
144#pragma omp parallel for private(c15)
145 for (c2 = 0; c2 <= (((n + -1) * 16 < 0?((16 < 0?-((-(n + -1) + 16 + 1) / 16) : -((-(n + -1) + 16 - 1) / 16))) : (n + -1) / 16)); c2++) {
146#pragma omp simd
147 for (c15 = 16 * c2; c15 <= ((16 * c2 + 15 < n + -1?16 * c2 + 15 : n + -1)); c15++) {
148 X[n - 1][c15] = X[n - 1][c15] / B[n - 1][c15];
149 }
150 }
151 }
152 }
153 }
154
155//#pragma endscop
156}
157
158int main(int argc,char **argv)
159{
160/* Retrieve problem size. */
161 int n = 500;
162 int tsteps = 10;
163/* Variable declaration/allocation. */
164 double (*X)[500 + 0][500 + 0];
165 X = ((double (*)[500 + 0][500 + 0])(polybench_alloc_data(((500 + 0) * (500 + 0)),(sizeof(double )))));
166 ;
167 double (*A)[500 + 0][500 + 0];
168 A = ((double (*)[500 + 0][500 + 0])(polybench_alloc_data(((500 + 0) * (500 + 0)),(sizeof(double )))));
169 ;
170 double (*B)[500 + 0][500 + 0];
171 B = ((double (*)[500 + 0][500 + 0])(polybench_alloc_data(((500 + 0) * (500 + 0)),(sizeof(double )))));
172 ;
173/* Initialize array(s). */
174 init_array(n, *X, *A, *B);
175/* Start timer. */
176 polybench_timer_start();
177 ;
178/* Run kernel. */
179 kernel_adi(tsteps,n, *X, *A, *B);
180/* Stop and print timer. */
181 polybench_timer_stop();
182 ;
183 polybench_timer_print();
184 ;
185/* Prevent dead-code elimination. All live-out data must be printed
186 by the function call in argument. */
187 if (argc > 42 && !strcmp(argv[0],""))
188 print_array(n, *X);
189/* Be clean. */
190 free(((void *)X));
191 ;
192 free(((void *)A));
193 ;
194 free(((void *)B));
195 ;
196 return 0;
197}
Note: See TracBrowser for help on using the repository browser.