source: CIVL/examples/omp/DataRaceBench/micro-benchmarks/3mm-parallel-no.c@ af3b8e4

1.23 2.0 main test-branch
Last change on this file since af3b8e4 was 36a61f3, checked in by Ziqing Luo <ziqing@…>, 9 years ago

Commit DataRaceBench into CIVL examples

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

  • Property mode set to 100644
File size: 24.1 KB
RevLine 
[36a61f3]1/**
2 * 3mm.c: This file is part of the PolyBench/C 3.2 test suite.
3 * three steps of matrix multiplication to multiply four matrices.
4 *
5 * Contact: Louis-Noel Pouchet <pouchet@cse.ohio-state.edu>
6 * Web address: http://polybench.sourceforge.net
7 */
8#include <stdio.h>
9#include <unistd.h>
10#include <string.h>
11#include <math.h>
12/* Include polybench common header. */
13#include <polybench.h>
14/* Include benchmark-specific header. */
15/* Default data type is double, default size is 4000. */
16#include "3mm.h"
17/* Array initialization. */
18
19static void init_array(int ni,int nj,int nk,int nl,int nm,double A[128 + 0][128 + 0],double B[128 + 0][128 + 0],double C[128 + 0][128 + 0],double D[128 + 0][128 + 0])
20{
21 int i;
22 int j;
23{
24 int c2;
25 int c1;
26 if (nl >= 1) {
27#pragma omp parallel for private(c2)
28 for (c1 = 0; c1 <= ((((((ni + -1 < nj + -1?ni + -1 : nj + -1)) < nk + -1?((ni + -1 < nj + -1?ni + -1 : nj + -1)) : nk + -1)) < nm + -1?((((ni + -1 < nj + -1?ni + -1 : nj + -1)) < nk + -1?((ni + -1 < nj + -1?ni + -1 : nj + -1)) : nk + -1)) : nm + -1)); c1++) {
29 for (c2 = 0; c2 <= ((((((nj + -1 < nk + -1?nj + -1 : nk + -1)) < nl + -1?((nj + -1 < nk + -1?nj + -1 : nk + -1)) : nl + -1)) < nm + -1?((((nj + -1 < nk + -1?nj + -1 : nk + -1)) < nl + -1?((nj + -1 < nk + -1?nj + -1 : nk + -1)) : nl + -1)) : nm + -1)); c2++) {
30 A[c1][c2] = ((double )c1) * c2 / ni;
31 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
32 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
33 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
34 }
35 for (c2 = nl; c2 <= ((((nj + -1 < nk + -1?nj + -1 : nk + -1)) < nm + -1?((nj + -1 < nk + -1?nj + -1 : nk + -1)) : nm + -1)); c2++) {
36 A[c1][c2] = ((double )c1) * c2 / ni;
37 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
38 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
39 }
40 for (c2 = nm; c2 <= ((((nj + -1 < nk + -1?nj + -1 : nk + -1)) < nl + -1?((nj + -1 < nk + -1?nj + -1 : nk + -1)) : nl + -1)); c2++) {
41 A[c1][c2] = ((double )c1) * c2 / ni;
42 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
43 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
44 }
45 for (c2 = (nl > nm?nl : nm); c2 <= ((nj + -1 < nk + -1?nj + -1 : nk + -1)); c2++) {
46 A[c1][c2] = ((double )c1) * c2 / ni;
47 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
48 }
49 for (c2 = nj; c2 <= ((((nk + -1 < nl + -1?nk + -1 : nl + -1)) < nm + -1?((nk + -1 < nl + -1?nk + -1 : nl + -1)) : nm + -1)); c2++) {
50 A[c1][c2] = ((double )c1) * c2 / ni;
51 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
52 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
53 }
54 for (c2 = (nj > nl?nj : nl); c2 <= ((nk + -1 < nm + -1?nk + -1 : nm + -1)); c2++) {
55 A[c1][c2] = ((double )c1) * c2 / ni;
56 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
57 }
58 for (c2 = (nj > nm?nj : nm); c2 <= ((nk + -1 < nl + -1?nk + -1 : nl + -1)); c2++) {
59 A[c1][c2] = ((double )c1) * c2 / ni;
60 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
61 }
62 for (c2 = (((nj > nl?nj : nl)) > nm?((nj > nl?nj : nl)) : nm); c2 <= nk + -1; c2++) {
63 A[c1][c2] = ((double )c1) * c2 / ni;
64 }
65 for (c2 = nk; c2 <= ((((nj + -1 < nl + -1?nj + -1 : nl + -1)) < nm + -1?((nj + -1 < nl + -1?nj + -1 : nl + -1)) : nm + -1)); c2++) {
66 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
67 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
68 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
69 }
70 for (c2 = (nk > nl?nk : nl); c2 <= ((nj + -1 < nm + -1?nj + -1 : nm + -1)); c2++) {
71 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
72 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
73 }
74 for (c2 = (nk > nm?nk : nm); c2 <= ((nj + -1 < nl + -1?nj + -1 : nl + -1)); c2++) {
75 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
76 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
77 }
78 for (c2 = (((nk > nl?nk : nl)) > nm?((nk > nl?nk : nl)) : nm); c2 <= nj + -1; c2++) {
79 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
80 }
81 for (c2 = (nj > nk?nj : nk); c2 <= ((nl + -1 < nm + -1?nl + -1 : nm + -1)); c2++) {
82 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
83 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
84 }
85 for (c2 = (((nj > nk?nj : nk)) > nl?((nj > nk?nj : nk)) : nl); c2 <= nm + -1; c2++) {
86 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
87 }
88 for (c2 = (((nj > nk?nj : nk)) > nm?((nj > nk?nj : nk)) : nm); c2 <= nl + -1; c2++) {
89 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
90 }
91 }
92 }
93 if (nl <= 0) {
94#pragma omp parallel for private(c2)
95 for (c1 = 0; c1 <= ((((((ni + -1 < nj + -1?ni + -1 : nj + -1)) < nk + -1?((ni + -1 < nj + -1?ni + -1 : nj + -1)) : nk + -1)) < nm + -1?((((ni + -1 < nj + -1?ni + -1 : nj + -1)) < nk + -1?((ni + -1 < nj + -1?ni + -1 : nj + -1)) : nk + -1)) : nm + -1)); c1++) {
96 for (c2 = 0; c2 <= ((((nj + -1 < nk + -1?nj + -1 : nk + -1)) < nm + -1?((nj + -1 < nk + -1?nj + -1 : nk + -1)) : nm + -1)); c2++) {
97 A[c1][c2] = ((double )c1) * c2 / ni;
98 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
99 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
100 }
101 for (c2 = nm; c2 <= ((nj + -1 < nk + -1?nj + -1 : nk + -1)); c2++) {
102 A[c1][c2] = ((double )c1) * c2 / ni;
103 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
104 }
105 for (c2 = nj; c2 <= ((nk + -1 < nm + -1?nk + -1 : nm + -1)); c2++) {
106 A[c1][c2] = ((double )c1) * c2 / ni;
107 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
108 }
109 for (c2 = (nj > nm?nj : nm); c2 <= nk + -1; c2++) {
110 A[c1][c2] = ((double )c1) * c2 / ni;
111 }
112 for (c2 = nk; c2 <= ((nj + -1 < nm + -1?nj + -1 : nm + -1)); c2++) {
113 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
114 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
115 }
116 for (c2 = (nk > nm?nk : nm); c2 <= nj + -1; c2++) {
117 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
118 }
119 for (c2 = (nj > nk?nj : nk); c2 <= nm + -1; c2++) {
120 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
121 }
122 }
123 }
124 if (nm >= 1) {
125#pragma omp parallel for private(c2)
126 for (c1 = nm; c1 <= ((((ni + -1 < nj + -1?ni + -1 : nj + -1)) < nk + -1?((ni + -1 < nj + -1?ni + -1 : nj + -1)) : nk + -1)); c1++) {
127 for (c2 = 0; c2 <= nm + -1; c2++) {
128 A[c1][c2] = ((double )c1) * c2 / ni;
129 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
130 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
131 }
132 for (c2 = nm; c2 <= ((nj + -1 < nk + -1?nj + -1 : nk + -1)); c2++) {
133 A[c1][c2] = ((double )c1) * c2 / ni;
134 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
135 }
136 for (c2 = nj; c2 <= nk + -1; c2++) {
137 A[c1][c2] = ((double )c1) * c2 / ni;
138 }
139 for (c2 = nk; c2 <= nj + -1; c2++) {
140 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
141 }
142 }
143 }
144 if (nm <= 0) {
145#pragma omp parallel for private(c2)
146 for (c1 = 0; c1 <= ((((ni + -1 < nj + -1?ni + -1 : nj + -1)) < nk + -1?((ni + -1 < nj + -1?ni + -1 : nj + -1)) : nk + -1)); c1++) {
147 for (c2 = 0; c2 <= ((nj + -1 < nk + -1?nj + -1 : nk + -1)); c2++) {
148 A[c1][c2] = ((double )c1) * c2 / ni;
149 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
150 }
151 for (c2 = nj; c2 <= nk + -1; c2++) {
152 A[c1][c2] = ((double )c1) * c2 / ni;
153 }
154 for (c2 = nk; c2 <= nj + -1; c2++) {
155 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
156 }
157 }
158 }
159 if (nj >= 1 && nl >= 1) {
160#pragma omp parallel for private(c2)
161 for (c1 = nj; c1 <= ((((ni + -1 < nk + -1?ni + -1 : nk + -1)) < nm + -1?((ni + -1 < nk + -1?ni + -1 : nk + -1)) : nm + -1)); c1++) {
162 for (c2 = 0; c2 <= ((nj + -1 < nl + -1?nj + -1 : nl + -1)); c2++) {
163 A[c1][c2] = ((double )c1) * c2 / ni;
164 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
165 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
166 }
167 for (c2 = nl; c2 <= nj + -1; c2++) {
168 A[c1][c2] = ((double )c1) * c2 / ni;
169 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
170 }
171 for (c2 = nj; c2 <= ((nk + -1 < nl + -1?nk + -1 : nl + -1)); c2++) {
172 A[c1][c2] = ((double )c1) * c2 / ni;
173 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
174 }
175 for (c2 = (nj > nl?nj : nl); c2 <= nk + -1; c2++) {
176 A[c1][c2] = ((double )c1) * c2 / ni;
177 }
178 for (c2 = nk; c2 <= nl + -1; c2++) {
179 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
180 }
181 }
182 }
183 if (nj >= 1 && nl <= 0) {
184#pragma omp parallel for private(c2)
185 for (c1 = nj; c1 <= ((((ni + -1 < nk + -1?ni + -1 : nk + -1)) < nm + -1?((ni + -1 < nk + -1?ni + -1 : nk + -1)) : nm + -1)); c1++) {
186 for (c2 = 0; c2 <= nj + -1; c2++) {
187 A[c1][c2] = ((double )c1) * c2 / ni;
188 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
189 }
190 for (c2 = nj; c2 <= nk + -1; c2++) {
191 A[c1][c2] = ((double )c1) * c2 / ni;
192 }
193 }
194 }
195 if (nj >= 1) {
196#pragma omp parallel for private(c2)
197 for (c1 = (nj > nm?nj : nm); c1 <= ((ni + -1 < nk + -1?ni + -1 : nk + -1)); c1++) {
198 for (c2 = 0; c2 <= nj + -1; c2++) {
199 A[c1][c2] = ((double )c1) * c2 / ni;
200 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
201 }
202 for (c2 = nj; c2 <= nk + -1; c2++) {
203 A[c1][c2] = ((double )c1) * c2 / ni;
204 }
205 }
206 }
207 if (nj <= 0 && nl >= 1) {
208#pragma omp parallel for private(c2)
209 for (c1 = 0; c1 <= ((((ni + -1 < nk + -1?ni + -1 : nk + -1)) < nm + -1?((ni + -1 < nk + -1?ni + -1 : nk + -1)) : nm + -1)); c1++) {
210 for (c2 = 0; c2 <= ((nk + -1 < nl + -1?nk + -1 : nl + -1)); c2++) {
211 A[c1][c2] = ((double )c1) * c2 / ni;
212 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
213 }
214 for (c2 = nl; c2 <= nk + -1; c2++) {
215 A[c1][c2] = ((double )c1) * c2 / ni;
216 }
217 for (c2 = nk; c2 <= nl + -1; c2++) {
218 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
219 }
220 }
221 }
222 if (nj <= 0 && nl <= 0) {
223#pragma omp parallel for private(c2)
224 for (c1 = 0; c1 <= ((((ni + -1 < nk + -1?ni + -1 : nk + -1)) < nm + -1?((ni + -1 < nk + -1?ni + -1 : nk + -1)) : nm + -1)); c1++) {
225 for (c2 = 0; c2 <= nk + -1; c2++) {
226 A[c1][c2] = ((double )c1) * c2 / ni;
227 }
228 }
229 }
230 if (nj <= 0) {
231#pragma omp parallel for private(c2)
232 for (c1 = (0 > nm?0 : nm); c1 <= ((ni + -1 < nk + -1?ni + -1 : nk + -1)); c1++) {
233 for (c2 = 0; c2 <= nk + -1; c2++) {
234 A[c1][c2] = ((double )c1) * c2 / ni;
235 }
236 }
237 }
238 if (nk >= 1 && nl >= 1) {
239#pragma omp parallel for private(c2)
240 for (c1 = nk; c1 <= ((((ni + -1 < nj + -1?ni + -1 : nj + -1)) < nm + -1?((ni + -1 < nj + -1?ni + -1 : nj + -1)) : nm + -1)); c1++) {
241 for (c2 = 0; c2 <= ((nk + -1 < nl + -1?nk + -1 : nl + -1)); c2++) {
242 A[c1][c2] = ((double )c1) * c2 / ni;
243 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
244 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
245 }
246 for (c2 = nl; c2 <= nk + -1; c2++) {
247 A[c1][c2] = ((double )c1) * c2 / ni;
248 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
249 }
250 for (c2 = nk; c2 <= ((nl + -1 < nm + -1?nl + -1 : nm + -1)); c2++) {
251 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
252 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
253 }
254 for (c2 = (nk > nl?nk : nl); c2 <= nm + -1; c2++) {
255 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
256 }
257 for (c2 = nm; c2 <= nl + -1; c2++) {
258 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
259 }
260 }
261 }
262 if (nk >= 1 && nl <= 0) {
263#pragma omp parallel for private(c2)
264 for (c1 = nk; c1 <= ((((ni + -1 < nj + -1?ni + -1 : nj + -1)) < nm + -1?((ni + -1 < nj + -1?ni + -1 : nj + -1)) : nm + -1)); c1++) {
265 for (c2 = 0; c2 <= nk + -1; c2++) {
266 A[c1][c2] = ((double )c1) * c2 / ni;
267 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
268 }
269 for (c2 = nk; c2 <= nm + -1; c2++) {
270 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
271 }
272 }
273 }
274 if (nk >= 1 && nm >= 1) {
275#pragma omp parallel for private(c2)
276 for (c1 = (nk > nm?nk : nm); c1 <= ((ni + -1 < nj + -1?ni + -1 : nj + -1)); c1++) {
277 for (c2 = 0; c2 <= ((nk + -1 < nm + -1?nk + -1 : nm + -1)); c2++) {
278 A[c1][c2] = ((double )c1) * c2 / ni;
279 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
280 }
281 for (c2 = nm; c2 <= nk + -1; c2++) {
282 A[c1][c2] = ((double )c1) * c2 / ni;
283 }
284 for (c2 = nk; c2 <= nm + -1; c2++) {
285 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
286 }
287 }
288 }
289 if (nk >= 1 && nm <= 0) {
290#pragma omp parallel for private(c2)
291 for (c1 = nk; c1 <= ((ni + -1 < nj + -1?ni + -1 : nj + -1)); c1++) {
292 for (c2 = 0; c2 <= nk + -1; c2++) {
293 A[c1][c2] = ((double )c1) * c2 / ni;
294 }
295 }
296 }
297 if (nk >= 1 && nl >= 1) {
298#pragma omp parallel for private(c2)
299 for (c1 = (nj > nk?nj : nk); c1 <= ((ni + -1 < nm + -1?ni + -1 : nm + -1)); c1++) {
300 for (c2 = 0; c2 <= ((nk + -1 < nl + -1?nk + -1 : nl + -1)); c2++) {
301 A[c1][c2] = ((double )c1) * c2 / ni;
302 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
303 }
304 for (c2 = nl; c2 <= nk + -1; c2++) {
305 A[c1][c2] = ((double )c1) * c2 / ni;
306 }
307 for (c2 = nk; c2 <= nl + -1; c2++) {
308 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
309 }
310 }
311 }
312 if (nk >= 1 && nl <= 0) {
313#pragma omp parallel for private(c2)
314 for (c1 = (nj > nk?nj : nk); c1 <= ((ni + -1 < nm + -1?ni + -1 : nm + -1)); c1++) {
315 for (c2 = 0; c2 <= nk + -1; c2++) {
316 A[c1][c2] = ((double )c1) * c2 / ni;
317 }
318 }
319 }
320 if (nk >= 1) {
321#pragma omp parallel for private(c2)
322 for (c1 = (((nj > nk?nj : nk)) > nm?((nj > nk?nj : nk)) : nm); c1 <= ni + -1; c1++) {
323 for (c2 = 0; c2 <= nk + -1; c2++) {
324 A[c1][c2] = ((double )c1) * c2 / ni;
325 }
326 }
327 }
328 if (nl >= 1) {
329#pragma omp parallel for private(c2)
330 for (c1 = (0 > ni?0 : ni); c1 <= ((((nj + -1 < nk + -1?nj + -1 : nk + -1)) < nm + -1?((nj + -1 < nk + -1?nj + -1 : nk + -1)) : nm + -1)); c1++) {
331 for (c2 = 0; c2 <= ((((nj + -1 < nl + -1?nj + -1 : nl + -1)) < nm + -1?((nj + -1 < nl + -1?nj + -1 : nl + -1)) : nm + -1)); c2++) {
332 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
333 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
334 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
335 }
336 for (c2 = nl; c2 <= ((nj + -1 < nm + -1?nj + -1 : nm + -1)); c2++) {
337 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
338 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
339 }
340 for (c2 = nm; c2 <= ((nj + -1 < nl + -1?nj + -1 : nl + -1)); c2++) {
341 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
342 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
343 }
344 for (c2 = (nl > nm?nl : nm); c2 <= nj + -1; c2++) {
345 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
346 }
347 for (c2 = nj; c2 <= ((nl + -1 < nm + -1?nl + -1 : nm + -1)); c2++) {
348 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
349 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
350 }
351 for (c2 = (nj > nl?nj : nl); c2 <= nm + -1; c2++) {
352 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
353 }
354 for (c2 = (nj > nm?nj : nm); c2 <= nl + -1; c2++) {
355 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
356 }
357 }
358 }
359 if (nl <= 0) {
360#pragma omp parallel for private(c2)
361 for (c1 = (0 > ni?0 : ni); c1 <= ((((nj + -1 < nk + -1?nj + -1 : nk + -1)) < nm + -1?((nj + -1 < nk + -1?nj + -1 : nk + -1)) : nm + -1)); c1++) {
362 for (c2 = 0; c2 <= ((nj + -1 < nm + -1?nj + -1 : nm + -1)); c2++) {
363 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
364 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
365 }
366 for (c2 = nm; c2 <= nj + -1; c2++) {
367 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
368 }
369 for (c2 = nj; c2 <= nm + -1; c2++) {
370 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
371 }
372 }
373 }
374 if (nm >= 1) {
375#pragma omp parallel for private(c2)
376 for (c1 = (ni > nm?ni : nm); c1 <= ((nj + -1 < nk + -1?nj + -1 : nk + -1)); c1++) {
377 for (c2 = 0; c2 <= nm + -1; c2++) {
378 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
379 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
380 }
381 for (c2 = nm; c2 <= nj + -1; c2++) {
382 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
383 }
384 }
385 }
386 if (nm <= 0) {
387#pragma omp parallel for private(c2)
388 for (c1 = (0 > ni?0 : ni); c1 <= ((nj + -1 < nk + -1?nj + -1 : nk + -1)); c1++) {
389 for (c2 = 0; c2 <= nj + -1; c2++) {
390 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
391 }
392 }
393 }
394 if (nj >= 1 && nl >= 1) {
395#pragma omp parallel for private(c2)
396 for (c1 = (ni > nj?ni : nj); c1 <= ((nk + -1 < nm + -1?nk + -1 : nm + -1)); c1++) {
397 for (c2 = 0; c2 <= ((nj + -1 < nl + -1?nj + -1 : nl + -1)); c2++) {
398 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
399 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
400 }
401 for (c2 = nl; c2 <= nj + -1; c2++) {
402 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
403 }
404 for (c2 = nj; c2 <= nl + -1; c2++) {
405 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
406 }
407 }
408 }
409 if (nj >= 1 && nl <= 0) {
410#pragma omp parallel for private(c2)
411 for (c1 = (ni > nj?ni : nj); c1 <= ((nk + -1 < nm + -1?nk + -1 : nm + -1)); c1++) {
412 for (c2 = 0; c2 <= nj + -1; c2++) {
413 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
414 }
415 }
416 }
417 if (nj >= 1) {
418#pragma omp parallel for private(c2)
419 for (c1 = (((ni > nj?ni : nj)) > nm?((ni > nj?ni : nj)) : nm); c1 <= nk + -1; c1++) {
420 for (c2 = 0; c2 <= nj + -1; c2++) {
421 B[c1][c2] = ((double )c1) * (c2 + 1) / nj;
422 }
423 }
424 }
425 if (nk >= 1 && nl >= 1) {
426#pragma omp parallel for private(c2)
427 for (c1 = (ni > nk?ni : nk); c1 <= ((nj + -1 < nm + -1?nj + -1 : nm + -1)); c1++) {
428 for (c2 = 0; c2 <= ((nl + -1 < nm + -1?nl + -1 : nm + -1)); c2++) {
429 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
430 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
431 }
432 for (c2 = nl; c2 <= nm + -1; c2++) {
433 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
434 }
435 for (c2 = nm; c2 <= nl + -1; c2++) {
436 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
437 }
438 }
439 }
440 if (nk >= 1 && nl <= 0) {
441#pragma omp parallel for private(c2)
442 for (c1 = (ni > nk?ni : nk); c1 <= ((nj + -1 < nm + -1?nj + -1 : nm + -1)); c1++) {
443 for (c2 = 0; c2 <= nm + -1; c2++) {
444 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
445 }
446 }
447 }
448 if (nk >= 1 && nm >= 1) {
449#pragma omp parallel for private(c2)
450 for (c1 = (((ni > nk?ni : nk)) > nm?((ni > nk?ni : nk)) : nm); c1 <= nj + -1; c1++) {
451 for (c2 = 0; c2 <= nm + -1; c2++) {
452 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
453 }
454 }
455 }
456 if (nk <= 0 && nl >= 1) {
457#pragma omp parallel for private(c2)
458 for (c1 = 0; c1 <= ((nj + -1 < nm + -1?nj + -1 : nm + -1)); c1++) {
459 for (c2 = 0; c2 <= ((nl + -1 < nm + -1?nl + -1 : nm + -1)); c2++) {
460 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
461 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
462 }
463 for (c2 = nl; c2 <= nm + -1; c2++) {
464 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
465 }
466 for (c2 = nm; c2 <= nl + -1; c2++) {
467 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
468 }
469 }
470 }
471 if (nk <= 0 && nl <= 0) {
472#pragma omp parallel for private(c2)
473 for (c1 = 0; c1 <= ((nj + -1 < nm + -1?nj + -1 : nm + -1)); c1++) {
474 for (c2 = 0; c2 <= nm + -1; c2++) {
475 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
476 }
477 }
478 }
479 if (nk <= 0 && nm >= 1) {
480#pragma omp parallel for private(c2)
481 for (c1 = nm; c1 <= nj + -1; c1++) {
482 for (c2 = 0; c2 <= nm + -1; c2++) {
483 C[c1][c2] = ((double )c1) * (c2 + 3) / nl;
484 }
485 }
486 }
487 if (nj <= 0 && nl >= 1) {
488#pragma omp parallel for private(c2)
489 for (c1 = (0 > ni?0 : ni); c1 <= ((nk + -1 < nm + -1?nk + -1 : nm + -1)); c1++) {
490 for (c2 = 0; c2 <= nl + -1; c2++) {
491 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
492 }
493 }
494 }
495 if (nk >= 1 && nl >= 1) {
496#pragma omp parallel for private(c2)
497 for (c1 = (((ni > nj?ni : nj)) > nk?((ni > nj?ni : nj)) : nk); c1 <= nm + -1; c1++) {
498 for (c2 = 0; c2 <= nl + -1; c2++) {
499 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
500 }
501 }
502 }
503 if (nk <= 0 && nl >= 1) {
504#pragma omp parallel for private(c2)
505 for (c1 = (0 > nj?0 : nj); c1 <= nm + -1; c1++) {
506 for (c2 = 0; c2 <= nl + -1; c2++) {
507 D[c1][c2] = ((double )c1) * (c2 + 2) / nk;
508 }
509 }
510 }
511 }
512}
513/* DCE code. Must scan the entire live-out data.
514 Can be used also to check the correctness of the output. */
515
516static void print_array(int ni,int nl,double G[128 + 0][128 + 0])
517{
518 int i;
519 int j;
520 for (i = 0; i < ni; i++)
521 for (j = 0; j < nl; j++) {
522 fprintf(stderr,"%0.2lf ",G[i][j]);
523 if ((i * ni + j) % 20 == 0)
524 fprintf(stderr,"\n");
525 }
526 fprintf(stderr,"\n");
527}
528/* Main computational kernel. The whole function will be timed,
529 including the call and return. */
530
531static void kernel_3mm(int ni,int nj,int nk,int nl,int nm,double E[128 + 0][128 + 0],double A[128 + 0][128 + 0],double B[128 + 0][128 + 0],double F[128 + 0][128 + 0],double C[128 + 0][128 + 0],double D[128 + 0][128 + 0],double G[128 + 0][128 + 0])
532{
533 int i;
534 int j;
535 int k;
536
537#pragma scop
538{
539 int c1;
540 int c2;
541 int c5;
542#pragma omp parallel for private(c2)
543 for (c1 = 0; c1 <= 127; c1++) {
544 for (c2 = 0; c2 <= 127; c2++) {
545 G[c1][c2] = 0;
546 F[c1][c2] = 0;
547 }
548 }
549#pragma omp parallel for private(c5, c2)
550 for (c1 = 0; c1 <= 127; c1++) {
551 for (c2 = 0; c2 <= 127; c2++) {
552 for (c5 = 0; c5 <= 127; c5++) {
553 F[c1][c2] += C[c1][c5] * D[c5][c2];
554 }
555 }
556 }
557#pragma omp parallel for private(c2)
558 for (c1 = 0; c1 <= 127; c1++) {
559 for (c2 = 0; c2 <= 127; c2++) {
560 E[c1][c2] = 0;
561 }
562 }
563#pragma omp parallel for private(c5, c2)
564 for (c1 = 0; c1 <= 127; c1++) {
565 for (c2 = 0; c2 <= 127; c2++) {
566 for (c5 = 0; c5 <= 127; c5++) {
567 E[c1][c2] += A[c1][c5] * B[c5][c2];
568 }
569 for (c5 = 0; c5 <= 127; c5++) {
570 G[c1][c5] += E[c1][c2] * F[c2][c5];
571 }
572 }
573 }
574 }
575
576#pragma endscop
577}
578
579int main(int argc,char **argv)
580{
581/* Retrieve problem size. */
582 int ni = 128;
583 int nj = 128;
584 int nk = 128;
585 int nl = 128;
586 int nm = 128;
587/* Variable declaration/allocation. */
588 double (*E)[128 + 0][128 + 0];
589 E = ((double (*)[128 + 0][128 + 0])(polybench_alloc_data(((128 + 0) * (128 + 0)),(sizeof(double )))));
590 ;
591 double (*A)[128 + 0][128 + 0];
592 A = ((double (*)[128 + 0][128 + 0])(polybench_alloc_data(((128 + 0) * (128 + 0)),(sizeof(double )))));
593 ;
594 double (*B)[128 + 0][128 + 0];
595 B = ((double (*)[128 + 0][128 + 0])(polybench_alloc_data(((128 + 0) * (128 + 0)),(sizeof(double )))));
596 ;
597 double (*F)[128 + 0][128 + 0];
598 F = ((double (*)[128 + 0][128 + 0])(polybench_alloc_data(((128 + 0) * (128 + 0)),(sizeof(double )))));
599 ;
600 double (*C)[128 + 0][128 + 0];
601 C = ((double (*)[128 + 0][128 + 0])(polybench_alloc_data(((128 + 0) * (128 + 0)),(sizeof(double )))));
602 ;
603 double (*D)[128 + 0][128 + 0];
604 D = ((double (*)[128 + 0][128 + 0])(polybench_alloc_data(((128 + 0) * (128 + 0)),(sizeof(double )))));
605 ;
606 double (*G)[128 + 0][128 + 0];
607 G = ((double (*)[128 + 0][128 + 0])(polybench_alloc_data(((128 + 0) * (128 + 0)),(sizeof(double )))));
608 ;
609/* Initialize array(s). */
610 init_array(ni,nj,nk,nl,nm, *A, *B, *C, *D);
611/* Start timer. */
612 polybench_timer_start();
613 ;
614/* Run kernel. */
615 kernel_3mm(ni,nj,nk,nl,nm, *E, *A, *B, *F, *C, *D, *G);
616/* Stop and print timer. */
617 polybench_timer_stop();
618 ;
619 polybench_timer_print();
620 ;
621/* Prevent dead-code elimination. All live-out data must be printed
622 by the function call in argument. */
623 if (argc > 42 && !strcmp(argv[0],""))
624 print_array(ni,nl, *G);
625/* Be clean. */
626 free(((void *)E));
627 ;
628 free(((void *)A));
629 ;
630 free(((void *)B));
631 ;
632 free(((void *)F));
633 ;
634 free(((void *)C));
635 ;
636 free(((void *)D));
637 ;
638 free(((void *)G));
639 ;
640 return 0;
641}
Note: See TracBrowser for help on using the repository browser.