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