1 | /* -------------------- */ |
---|
2 | /* --- ecc_common.h --- */ |
---|
3 | /* -------------------- */ |
---|
4 | |
---|
5 | #ifndef _ECC_COMMON_H_ |
---|
6 | #define _ECC_COMMON_H_ |
---|
7 | |
---|
8 | #ifdef __cplusplus |
---|
9 | #pragma message ("C++") |
---|
10 | extern "C" { |
---|
11 | #endif |
---|
12 | |
---|
13 | //#include <stdio.h> |
---|
14 | //#include <stdlib.h> |
---|
15 | //#include <math.h> |
---|
16 | |
---|
17 | //#include "def.h" |
---|
18 | //#include "nrc.h" |
---|
19 | //#include "util.h" |
---|
20 | //#include "palette.h" |
---|
21 | |
---|
22 | // ------------------------------------------ |
---|
23 | // -- valeur des parametres des benchmarks -- |
---|
24 | // ------------------------------------------ |
---|
25 | //#define ENABLE_GLOBAL_PARAM |
---|
26 | //#ifdef ENABLE_GLOBAL_PARAM |
---|
27 | #define ECC_G0 1 |
---|
28 | #define ECC_G1 16 |
---|
29 | #define ECC_GS 1 |
---|
30 | |
---|
31 | #define ECC_D0 0 |
---|
32 | #define ECC_D1 100 |
---|
33 | #define ECC_DS 1 |
---|
34 | #define ECC_DSCALE 1 |
---|
35 | |
---|
36 | //#define ECC_SIZE 2048 |
---|
37 | #define ECC_SIZE 2048 |
---|
38 | //#endif // ENABLE_GLOBAL_PARAM |
---|
39 | |
---|
40 | |
---|
41 | #define ITER 25 |
---|
42 | #define RUN 10 |
---|
43 | #define HEIGHT 2048 |
---|
44 | #define WIDTH 2048 |
---|
45 | #define NEMAX HEIGHT*WIDTH/4 |
---|
46 | |
---|
47 | #define INTEL |
---|
48 | //#define POWERPC |
---|
49 | |
---|
50 | #define ECC_DEBUG(X) |
---|
51 | //#define ECC_DEBUG(X) X |
---|
52 | |
---|
53 | //#define ECC_VERBOSE(X) |
---|
54 | #define ECC_VERBOSE(X) X |
---|
55 | |
---|
56 | #define ECC_VERBOSE2(X) |
---|
57 | //#define ECC_VERBOSE2(X) X |
---|
58 | |
---|
59 | #define SOLVE(X) X |
---|
60 | #define ECC_SOLVE(X) X |
---|
61 | |
---|
62 | #define LABEL2(X) X |
---|
63 | #define ECC_LABEL2(X) X |
---|
64 | |
---|
65 | //#define FEATURES(X) X |
---|
66 | #define ECC_FEATURES(X) X |
---|
67 | |
---|
68 | #define ECC_CHECK(ne, nemax) |
---|
69 | //#define ECC_CHECK(ne, nemax) if(ne>=nemax) {printf("Error ne >= %d\n", nemax); exit(-1);} |
---|
70 | |
---|
71 | //#define BENCH(X,dc) t0=dcycle();X;t1=dcycle(); dc=(t1-t0)/(double)(height*width) |
---|
72 | |
---|
73 | //#define BENCH(X,dc) t0=dtime();X;t1=dtime(); dc=(t1-t0)*FREQ/(double)(height*width) |
---|
74 | //#define BENCH(X,dc) for(r=0; r<RUN; r++) {tmin = 1e30; t0=dtime(); for(i=0; i<ITER; i++) { X; } t1=dtime(); dt=(t1-t0); if(dt<tmin) tmin = dt;} dc=tmin*FREQ/(double)(ITER*height*width) |
---|
75 | |
---|
76 | #define DUP2(X) X; X; X; X |
---|
77 | #define DUP3(X) X; X; X; X |
---|
78 | #define DUP4(X) X; X; X; X |
---|
79 | #define DUP10(X) X; X; X; X; X; X; X; X; X; X |
---|
80 | |
---|
81 | #define BENCH10_WHILE(X, c) \ |
---|
82 | do { \ |
---|
83 | double t0, t1, dt; \ |
---|
84 | t0 = _rdtsc(); \ |
---|
85 | DUP10(X); \ |
---|
86 | t1 = _rdtsc(); \ |
---|
87 | dt = t1-t0; \ |
---|
88 | c = dt/10.0; \ |
---|
89 | } while(0) |
---|
90 | |
---|
91 | #define BENCH4_WHILE(X, c) \ |
---|
92 | do { \ |
---|
93 | double t0, t1, dt; \ |
---|
94 | t0 = _rdtsc(); \ |
---|
95 | DUP4(X); \ |
---|
96 | t1 = _rdtsc(); \ |
---|
97 | dt = t1-t0; \ |
---|
98 | c = dt/4.0; \ |
---|
99 | } while(0) |
---|
100 | |
---|
101 | #define BENCH1_WHILE(X, c) \ |
---|
102 | do { \ |
---|
103 | double t0, t1, dt; \ |
---|
104 | t0 = _rdtsc(); \ |
---|
105 | X; \ |
---|
106 | t1 = _rdtsc(); \ |
---|
107 | dt = t1-t0; \ |
---|
108 | c = dt/1.0; \ |
---|
109 | } while(0) |
---|
110 | |
---|
111 | |
---|
112 | #define BENCH_VAR(X, c) \ |
---|
113 | t0 = _rdtsc(); \ |
---|
114 | X; \ |
---|
115 | t1 = _rdtsc(); \ |
---|
116 | dt = t1-t0; \ |
---|
117 | c = dt |
---|
118 | |
---|
119 | //#define BENCH(X, c) BENCH10_WHILE(X, c) |
---|
120 | //#define BENCH(X, c) BENCH1_WHILE(X, c) |
---|
121 | #define BENCH(X, c) BENCH4_WHILE(X, c) |
---|
122 | |
---|
123 | #define BENCH_RUN(X, c) \ |
---|
124 | do { \ |
---|
125 | int r, run = 4; \ |
---|
126 | double t, tmin = 1e30; \ |
---|
127 | for(r=0 r<run; r++) { \ |
---|
128 | BENCH4_WHILE(X, t); \ |
---|
129 | if(t<tmin) tmin = t; \ |
---|
130 | } \ |
---|
131 | c = tmin; \ |
---|
132 | } while(0) |
---|
133 | |
---|
134 | // pour simplifier le debug: variables globales pour eviter de changer la liste d'arguments |
---|
135 | |
---|
136 | |
---|
137 | //#define ENABLE_GLOBAL_DEBUG |
---|
138 | #ifdef ENABLE_GLOBAL_DEBUG |
---|
139 | #define GLOBAL_DEBUG(X) X |
---|
140 | #else |
---|
141 | #define GLOBAL_DEBUG(X) |
---|
142 | #endif |
---|
143 | |
---|
144 | #ifdef ENABLE_GLOBAL_DEBUG |
---|
145 | // variables globales externes pour log de configurations particulieres |
---|
146 | extern int g_density; |
---|
147 | extern int g_granularity; |
---|
148 | extern int g_iter; |
---|
149 | extern int g_i; |
---|
150 | extern int g_j; |
---|
151 | |
---|
152 | extern int g_p; |
---|
153 | extern uint32 g_ne; |
---|
154 | extern uint32 g_ne_start; |
---|
155 | extern uint32 g_ne_end; |
---|
156 | #endif |
---|
157 | |
---|
158 | //#define ENABLE_CHECK_DEBUG |
---|
159 | #ifdef ENABLE_CHECK_DEBUG |
---|
160 | #define CHECK_DEBUG(X) X |
---|
161 | #else |
---|
162 | #define CHECK_DEBUG(X) |
---|
163 | #endif |
---|
164 | |
---|
165 | uint32 ui32Max2(uint32 a, uint32 b); |
---|
166 | uint32 ui32Max3(uint32 a, uint32 b, uint32 c); |
---|
167 | uint32 ui32Max4(uint32 a, uint32 b, uint32 c, uint32 d); |
---|
168 | |
---|
169 | uint32 ui32Min2(uint32 a, uint32 b); |
---|
170 | uint32 ui32Min3(uint32 a, uint32 b, uint32 c); |
---|
171 | uint32 ui32Min4(uint32 a, uint32 b, uint32 c, uint32 d); |
---|
172 | |
---|
173 | // retourne le monimum positif d'un ensemble de points |
---|
174 | uint32 ui32MinNonNul2(uint32 a0, uint32 a1); |
---|
175 | uint32 ui32MinNonNul3(uint32 a0, uint32 a1, uint32 a2); |
---|
176 | uint32 ui32MinNonNul4(uint32 a0, uint32 a1, uint32 a2, uint32 a3); |
---|
177 | uint32 ui32MinNonNul5(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4); |
---|
178 | uint32 ui32MinNonNul8(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4, uint32 a5, uint32 a6, uint32 a7); |
---|
179 | uint32 ui32MinNonNul9(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4, uint32 a5, uint32 a6, uint32 a7, uint32 a8); |
---|
180 | |
---|
181 | // retourne le minimum positif, si le point central est non nul |
---|
182 | uint32 ui32MinNonNul3Cond(uint32 a0, uint32 a1, uint32 a2); |
---|
183 | uint32 ui32MinNonNul5Cond(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4); |
---|
184 | uint32 ui32MinNonNul9Cond(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4, uint32 a5, uint32 a6, uint32 a7, uint32 a8); |
---|
185 | |
---|
186 | void initT(uint32 *T, uint32 nemax); // T[i] = i |
---|
187 | //void initA(uint32 *A, uint32 nemax); |
---|
188 | void initZ(uint32 *T, uint32 nemax);// T[i] = 0 |
---|
189 | |
---|
190 | void check_initT(uint32 *T, uint32 nemax); |
---|
191 | void check_initZ(uint32 *T, uint32 nemax); |
---|
192 | |
---|
193 | void check_initT_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1); |
---|
194 | void check_initR_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1); |
---|
195 | void check_initZ_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1); |
---|
196 | |
---|
197 | void applyTable(uint32 **X, int height, int width, uint32 *T, uint32 **Y); |
---|
198 | void binarisation_ui8matrix(uint8 **X, int i0, int i1, int j0, int j1, uint8 seuil, uint8 val, uint8 **Y); |
---|
199 | |
---|
200 | void graphviz_write_ui8vector (uint8 *v, int i0, int i1, char *format, char *filename); |
---|
201 | void graphviz_write_ui16vector(uint16 *v, int i0, int i1, char *format, char *filename); |
---|
202 | void graphviz_write_ui32vector(uint32 *v, int i0, int i1, char *format, char *filename); |
---|
203 | |
---|
204 | void mod_ui32matrix_ui8matrix(uint32 **X, int i0, int i1, int j0, int j1, uint8 **Y); |
---|
205 | void positive_mod_ui32matrix_ui8matrix(uint32 **X, int i0, int i1, int j0, int j1, uint8 **Y); |
---|
206 | |
---|
207 | uint32 mt19937_uint32(uint32 a, uint32 b); |
---|
208 | |
---|
209 | BOOL strto_Bool(char *str); |
---|
210 | |
---|
211 | void check_no_write(uint32 **T, int i0, int i1, int j0, int j1); |
---|
212 | |
---|
213 | #ifdef __cplusplus |
---|
214 | } |
---|
215 | #endif |
---|
216 | |
---|
217 | #endif // _ECC_COMMON_H_ |
---|