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