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

Last change on this file since 778 was 772, checked in by meunier, 9 years ago
  • Ajout de l'application rosenfeld
  • Changement du nom du flag O_CREATE en O_CREAT
File size: 5.9 KB
Line 
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++")
10extern "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) \
82do {                \
83double t0, t1, dt;  \
84t0 = _rdtsc();      \
85DUP10(X);           \
86t1 = _rdtsc();      \
87dt = t1-t0;         \
88c = dt/10.0;        \
89} while(0)
90
91#define BENCH4_WHILE(X, c) \
92do {                \
93double t0, t1, dt;  \
94t0 = _rdtsc();      \
95DUP4(X);            \
96t1 = _rdtsc();      \
97dt = t1-t0;         \
98c = dt/4.0;         \
99} while(0)
100   
101#define BENCH1_WHILE(X, c) \
102do {                \
103double t0, t1, dt;  \
104t0 = _rdtsc();      \
105X;                  \
106t1 = _rdtsc();      \
107dt = t1-t0;         \
108c = dt/1.0;         \
109} while(0)
110
111
112#define BENCH_VAR(X, c) \
113t0 = _rdtsc();      \
114X;                  \
115t1 = _rdtsc();      \
116dt = t1-t0;         \
117c = 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)      \
124do {                         \
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
146extern int g_density;
147extern int g_granularity;
148extern int g_iter;
149extern int g_i;
150extern int g_j;
151   
152extern int g_p;
153extern uint32 g_ne;
154extern uint32 g_ne_start;
155extern 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   
165uint32 ui32Max2(uint32 a, uint32 b);
166uint32 ui32Max3(uint32 a, uint32 b, uint32 c);
167uint32 ui32Max4(uint32 a, uint32 b, uint32 c, uint32 d);
168   
169uint32 ui32Min2(uint32 a, uint32 b);
170uint32 ui32Min3(uint32 a, uint32 b, uint32 c);
171uint32 ui32Min4(uint32 a, uint32 b, uint32 c, uint32 d);
172
173// retourne le monimum positif d'un ensemble de points
174uint32 ui32MinNonNul2(uint32 a0, uint32 a1);
175uint32 ui32MinNonNul3(uint32 a0, uint32 a1, uint32 a2);
176uint32 ui32MinNonNul4(uint32 a0, uint32 a1, uint32 a2, uint32 a3);
177uint32 ui32MinNonNul5(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4);
178uint32 ui32MinNonNul8(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4, uint32 a5, uint32 a6, uint32 a7);
179uint32 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
182uint32 ui32MinNonNul3Cond(uint32 a0, uint32 a1, uint32 a2);
183uint32 ui32MinNonNul5Cond(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4);
184uint32 ui32MinNonNul9Cond(uint32 a0, uint32 a1, uint32 a2, uint32 a3, uint32 a4, uint32 a5, uint32 a6, uint32 a7, uint32 a8);
185
186void initT(uint32 *T, uint32 nemax); // T[i] = i
187//void initA(uint32 *A, uint32 nemax);
188void initZ(uint32 *T, uint32 nemax);// T[i] = 0
189   
190void check_initT(uint32 *T, uint32 nemax);   
191void check_initZ(uint32 *T, uint32 nemax);
192
193void check_initT_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1);
194void check_initR_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1);
195void check_initZ_range(uint32 *T, uint32 i0, uint32 ii, uint32 i1);
196   
197void applyTable(uint32 **X, int height, int width, uint32 *T, uint32 **Y);
198void binarisation_ui8matrix(uint8 **X, int i0, int i1, int j0, int j1, uint8 seuil, uint8 val, uint8 **Y);
199
200void graphviz_write_ui8vector (uint8  *v, int i0, int i1, char *format, char *filename);
201void graphviz_write_ui16vector(uint16 *v, int i0, int i1, char *format, char *filename);
202void graphviz_write_ui32vector(uint32 *v, int i0, int i1, char *format, char *filename);
203
204void          mod_ui32matrix_ui8matrix(uint32 **X, int i0, int i1, int j0, int j1, uint8 **Y);
205void positive_mod_ui32matrix_ui8matrix(uint32 **X, int i0, int i1, int j0, int j1, uint8 **Y);
206
207uint32 mt19937_uint32(uint32 a, uint32 b);
208   
209BOOL strto_Bool(char *str);
210
211void 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_
Note: See TracBrowser for help on using the repository browser.