source: soft/giet_vm/applications/rosenfeld/include/ecc_common.h @ 822

Last change on this file since 822 was 821, checked in by meunier, 9 years ago
  • Added several versions of rosenfeld: { SLOW, FAST } x { FEATURES, NO_FEATURES }
  • Added native linux compilation support
  • Added a script to check results natively
  • Started to refactor nrc code
File size: 5.6 KB
Line 
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) \
69do {                \
70double t0, t1, dt;  \
71t0 = _rdtsc();      \
72DUP10(X);           \
73t1 = _rdtsc();      \
74dt = t1-t0;         \
75c = dt/10.0;        \
76} while(0)
77
78#define BENCH4_WHILE(X, c) \
79do {                \
80double t0, t1, dt;  \
81t0 = _rdtsc();      \
82DUP4(X);            \
83t1 = _rdtsc();      \
84dt = t1-t0;         \
85c = dt/4.0;         \
86} while(0)
87   
88#define BENCH1_WHILE(X, c) \
89do {                \
90double t0, t1, dt;  \
91t0 = _rdtsc();      \
92X;                  \
93t1 = _rdtsc();      \
94dt = t1-t0;         \
95c = dt/1.0;         \
96} while(0)
97
98
99#define BENCH_VAR(X, c) \
100t0 = _rdtsc();      \
101X;                  \
102t1 = _rdtsc();      \
103dt = t1-t0;         \
104c = 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)      \
111do {                         \
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
133extern int g_density;
134extern int g_granularity;
135extern int g_iter;
136extern int g_i;
137extern int g_j;
138   
139extern int g_p;
140extern uint32 g_ne;
141extern uint32 g_ne_start;
142extern 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   
152uint32 ui32Max2(uint32 a, uint32 b);
153uint32 ui32Max3(uint32 a, uint32 b, uint32 c);
154uint32 ui32Max4(uint32 a, uint32 b, uint32 c, uint32 d);
155   
156uint32 ui32Min2(uint32 a, uint32 b);
157uint32 ui32Min3(uint32 a, uint32 b, uint32 c);
158uint32 ui32Min4(uint32 a, uint32 b, uint32 c, uint32 d);
159
160// retourne le monimum positif d'un ensemble de points
161uint32 ui32MinNonNul2(uint32 a0, uint32 a1);
162uint32 ui32MinNonNul3(uint32 a0, uint32 a1, uint32 a2);
163uint32 ui32MinNonNul4(uint32 a0, uint32 a1, uint32 a2, uint32 a3);
164uint32 ui32MinNonNul5(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4);
165uint32 ui32MinNonNul8(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4, uint32 a5, uint32 a6, uint32 a7);
166uint32 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
169uint32 ui32MinNonNul3Cond(uint32 a0, uint32 a1, uint32 a2);
170uint32 ui32MinNonNul5Cond(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4);
171uint32 ui32MinNonNul9Cond(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4, uint32 a5, uint32 a6, uint32 a7, uint32 a8);
172
173void initT(uint32 *T, uint32 nemax); // T[i] = i
174//void initA(uint32 *A, uint32 nemax);
175void initZ(uint32 *T, uint32 nemax);// T[i] = 0
176   
177void check_initT(uint32 *T, uint32 nemax);   
178void check_initZ(uint32 *T, uint32 nemax);
179
180void check_initT_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1);
181void check_initR_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1);
182void check_initZ_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1);
183   
184void applyTable(uint32 **X, int height, int width, uint32 *T, uint32 **Y);
185void binarisation_ui8matrix(uint8 **X, int i0, int i1, int j0, int j1, uint8 seuil, uint8 val, uint8 **Y);
186
187void graphviz_write_ui8vector (uint8  *v, int i0, int i1, char *format, char *filename);
188void graphviz_write_ui16vector(uint16 *v, int i0, int i1, char *format, char *filename);
189void graphviz_write_ui32vector(uint32 *v, int i0, int i1, char *format, char *filename);
190
191void          mod_ui32matrix_ui8matrix(uint32 **X, int i0, int i1, int j0, int j1, uint8 **Y);
192void positive_mod_ui32matrix_ui8matrix(uint32 **X, int i0, int i1, int j0, int j1, uint8 **Y);
193
194uint32 mt19937_uint32(uint32 a, uint32 b);
195   
196bool strto_Bool(char *str);
197
198void 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_
Note: See TracBrowser for help on using the repository browser.