301743aae777786c032fa29a1abf6caae483e194
[ghc-hetmet.git] / ghc / includes / RtsFlags.h
1 /* -----------------------------------------------------------------------------
2  * $Id: RtsFlags.h,v 1.39 2001/11/25 16:57:38 sof Exp $
3  *
4  * (c) The GHC Team, 1998-1999
5  *
6  * Datatypes that holds the command-line flag settings.
7  *
8  * ---------------------------------------------------------------------------*/
9
10 #ifndef RTSFLAGS_H
11 #define RTSFLAGS_H
12
13 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
14
15 struct GC_FLAGS {
16     FILE   *statsFile;
17     nat     giveStats;
18 #define NO_GC_STATS      0
19 #define COLLECT_GC_STATS 1
20 #define ONELINE_GC_STATS 2
21 #define SUMMARY_GC_STATS 3
22 #define VERBOSE_GC_STATS 4
23
24     nat     maxStkSize;         /* in *words* */
25     nat     initialStkSize;     /* in *words* */
26
27     nat     maxHeapSize;        /* in *blocks* */
28     nat     minAllocAreaSize;   /* in *blocks* */
29     nat     minOldGenSize;      /* in *blocks* */
30     nat     heapSizeSuggestion; /* in *blocks* */
31     double  oldGenFactor;
32     double  pcFreeHeap;
33
34     nat     generations;
35     nat     steps;
36     rtsBool squeezeUpdFrames;
37
38     rtsBool compact;            /* True <=> "compact all the time" */
39     double  compactThreshold;
40
41     rtsBool ringBell;
42     rtsBool frontpanel;
43 };
44
45 /* Hack: this struct uses bitfields so that we can use a binary arg
46  * with the -D flag.
47  * Remember to update the corresponding bit of RtsFlags.c if you
48  * change/extend this struct.
49  */
50 struct DEBUG_FLAGS {  
51   /* flags to control debugging output in various subsystems */
52   rtsBool scheduler   : 1; /*  1 */
53   rtsBool evaluator   : 1; /*  2 */
54   rtsBool codegen     : 1; /*  4 */
55   rtsBool weak        : 1; /*  8 */
56   rtsBool gccafs      : 1; /* 16 */
57   rtsBool gc          : 1; /* 32 */
58   rtsBool block_alloc : 1; /* 64 */
59
60   /* flags to control consistency checking (often very expensive!) */
61   rtsBool sanity      : 1; /* 128 */
62
63   rtsBool stable      : 1; /* 256 */
64   rtsBool prof        : 1; /* 512 */
65   rtsBool gran        : 1; /* 1024 */
66   rtsBool par         : 1; /* 2048 */
67
68   /* The object linker */
69   rtsBool linker      : 1; /* 4096 */
70 };
71
72 #define MAX_DEBUG_OPTION     13
73 #define DEBUG_MASK(n)        ((nat)(ldexp(1,n)))
74 #define MAX_DEBUG_MASK       ((nat)(ldexp(1,(MAX_DEBUG_OPTION+1))-1))
75
76 struct COST_CENTRE_FLAGS {
77     unsigned int            doCostCentres;
78 # define COST_CENTRES_SUMMARY   1
79 # define COST_CENTRES_VERBOSE   2 /* incl. serial time profile */
80 # define COST_CENTRES_ALL       3
81 # define COST_CENTRES_XML       4
82
83     int     profilerTicks;   /* derived */
84     int     msecsPerTick;    /* derived */
85 };
86
87 #ifdef PROFILING
88 struct PROFILING_FLAGS {
89     unsigned int        doHeapProfile;
90
91     nat                 profileInterval;      /* delta between samples (in ms) */
92     nat                 profileIntervalTicks; /* delta between samples (in 'ticks') */
93
94
95 # define NO_HEAP_PROFILING      0       /* N.B. Used as indexes into arrays */
96 # define HEAP_BY_CCS            1
97 # define HEAP_BY_MOD            2
98 # define HEAP_BY_DESCR          4
99 # define HEAP_BY_TYPE           5
100 /* Flags for retainer and lag-drag-void profiling */
101 # define HEAP_BY_RETAINER       6
102 # define HEAP_BY_LDV            7
103
104     rtsBool             showCCSOnException;
105   
106 # define CCchar    'C'
107 # define MODchar   'M'
108 # define DESCRchar 'D'
109 # define TYPEchar  'Y'
110
111     char*               modSelector;
112     char*               descrSelector;
113     char*               typeSelector;
114     char*               ccSelector;
115
116
117 };
118 #elif defined(DEBUG)
119 # define NO_HEAP_PROFILING      0
120 # define HEAP_BY_INFOPTR        1
121 # define HEAP_BY_CLOSURE_TYPE   2
122 struct PROFILING_FLAGS {
123     unsigned int  doHeapProfile;     /* heap profile using symbol table */
124
125 };
126 #endif /* DEBUG || PROFILING */
127
128 struct CONCURRENT_FLAGS {
129     int ctxtSwitchTime;         /* in milliseconds */
130     int ctxtSwitchTicks;        /* derived */
131 };
132
133 #ifdef PAR
134 /* currently the same as GRAN_STATS_FLAGS */
135 struct PAR_STATS_FLAGS {
136   rtsBool Full;       /* Full .gr profile (rtsTrue) or only END events? */
137   rtsBool Suppressed; /* No .gr profile at all */
138   rtsBool Binary;     /* Binary profile? (not yet implemented) */
139   rtsBool Sparks;     /* Info on sparks in profile? */
140   rtsBool Heap;       /* Info on heap allocs in profile? */ 
141   rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
142   rtsBool Global;     /* Global statistics? (printed on shutdown; no log file) */
143 };
144
145 struct PAR_DEBUG_FLAGS {  
146   /* flags to control debugging output in various subsystems */
147   rtsBool verbose    : 1; /*    1 */
148   rtsBool bq         : 1; /*    2 */
149   rtsBool schedule   : 1; /*    4 */
150   rtsBool free       : 1; /*    8 */
151   rtsBool resume     : 1; /*   16 */
152   rtsBool weight     : 1; /*   32 */
153   rtsBool fetch      : 1; /*   64 */
154   rtsBool fish       : 1; /*  128 */
155   rtsBool tables     : 1; /*  256 */
156   rtsBool packet     : 1; /*  512 */
157   rtsBool pack       : 1; /* 1024 */
158   rtsBool paranoia   : 1; /* 2048 */
159 };
160
161 #define MAX_PAR_DEBUG_OPTION     11
162 #define PAR_DEBUG_MASK(n)        ((nat)(ldexp(1,n)))
163 #define MAX_PAR_DEBUG_MASK       ((nat)(ldexp(1,(MAX_PAR_DEBUG_OPTION+1))-1))
164
165 struct PAR_FLAGS {
166   struct PAR_STATS_FLAGS ParStats;  /* profile and stats output */
167   struct PAR_DEBUG_FLAGS Debug;         /* debugging options */
168   rtsBool  outputDisabled;        /* Disable output for performance purposes */
169   rtsBool  doFairScheduling;      /* Fair-ish scheduling (round robin; no time-slices) */
170   nat      packBufferSize;
171   nat      thunksToPack;          /* number of thunks in packet + 1 */ 
172   nat      globalising;           /* globalisation scheme */
173   nat      maxLocalSparks;        /* spark pool size */
174   nat      maxThreads;            /* thread pool size */
175   nat      maxFishes;             /* max number of active fishes */
176   rtsTime  fishDelay;             /* delay before sending a new fish */
177   long   wait;
178 };
179 #endif /* PAR */
180
181 #ifdef SMP
182 struct PAR_FLAGS {
183   nat            nNodes;         /* number of threads to run simultaneously */
184   unsigned int   maxLocalSparks;
185 };
186 #endif /* SMP */
187
188 #ifdef GRAN
189 struct GRAN_STATS_FLAGS {
190   rtsBool Full;       /* Full .gr profile (rtsTrue) or only END events? */
191   rtsBool Suppressed; /* No .gr profile at all */
192   rtsBool Binary;     /* Binary profile? (not yet implemented) */
193   rtsBool Sparks;     /* Info on sparks in profile? */
194   rtsBool Heap;       /* Info on heap allocs in profile? */ 
195   rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
196   rtsBool Global;     /* Global statistics? (printed on shutdown; no log file) */
197 };
198
199 struct GRAN_COST_FLAGS {
200   /* Communication Cost Variables -- set in main program */
201   nat latency;              /* Latency for single packet */
202   nat additional_latency;   /* Latency for additional packets */
203   nat fetchtime;            
204   nat lunblocktime;         /* Time for local unblock */
205   nat gunblocktime;         /* Time for global unblock */
206   nat mpacktime;            /* Cost of creating a packet */     
207   nat munpacktime;          /* Cost of receiving a packet */    
208   nat mtidytime;            /* Cost of cleaning up after send */
209   
210   nat threadcreatetime;     /* Thread creation costs */
211   nat threadqueuetime;      /* Cost of adding a thread to the running/runnable queue */
212   nat threaddescheduletime; /* Cost of descheduling a thread */
213   nat threadscheduletime;   /* Cost of scheduling a thread */
214   nat threadcontextswitchtime;  /* Cost of context switch  */
215   
216   /* Instruction Costs */
217   nat arith_cost;        /* arithmetic instructions (+,i,< etc) */
218   nat branch_cost;       /* branch instructions */ 
219   nat load_cost;         /* load into register */
220   nat store_cost;        /* store into memory */
221   nat float_cost;        /* floating point operations */
222   
223   nat heapalloc_cost;    /* heap allocation costs */
224   
225   /* Overhead for granularity control mechanisms */
226   /* overhead per elem of spark queue */
227   nat pri_spark_overhead;
228   /* overhead per elem of thread queue */
229   nat pri_sched_overhead;
230 };
231
232 struct GRAN_DEBUG_FLAGS {  
233   /* flags to control debugging output in various subsystems */
234   rtsBool event_trace    : 1; /*    1 */
235   rtsBool event_stats    : 1; /*    2 */
236   rtsBool bq             : 1; /*    4 */
237   rtsBool pack           : 1; /*    8 */
238   rtsBool checkSparkQ    : 1; /*   16 */
239   rtsBool thunkStealing  : 1; /*   32 */
240   rtsBool randomSteal    : 1; /*   64 */
241   rtsBool findWork       : 1; /*  128 */
242   rtsBool unused         : 1; /*  256 */
243   rtsBool pri            : 1; /*  512 */
244   rtsBool checkLight     : 1; /* 1024 */
245   rtsBool sortedQ        : 1; /* 2048 */
246   rtsBool blockOnFetch   : 1; /* 4096 */
247   rtsBool packBuffer     : 1; /* 8192 */
248   rtsBool blockOnFetch_sanity : 1; /*  16384 */
249 };
250
251 #define MAX_GRAN_DEBUG_OPTION     14
252 #define GRAN_DEBUG_MASK(n)        ((nat)(ldexp(1,n)))
253 #define MAX_GRAN_DEBUG_MASK       ((nat)(ldexp(1,(MAX_GRAN_DEBUG_OPTION+1))-1))
254
255 struct GRAN_FLAGS {
256   struct GRAN_STATS_FLAGS GranSimStats;  /* profile and stats output */
257   struct GRAN_COST_FLAGS Costs;          /* cost metric for simulation */
258   struct GRAN_DEBUG_FLAGS Debug;         /* debugging options */
259
260   nat  maxThreads;              // ToDo: share with SMP and GUM
261   // rtsBool labelling;
262   nat  packBufferSize;
263   nat  packBufferSize_internal;
264
265   PEs proc;                     /* number of processors */
266   rtsBool Fishing;              /* Simulate GUM style fishing mechanism? */
267   nat maxFishes;                /* max number of spark or thread steals */
268   rtsTime time_slice;           /* max time slice of one reduction thread */
269
270     /* GrAnSim-Light: This version puts no bound on the number of
271          processors but in exchange doesn't model communication costs
272          (all communication is 0 cost). Mainly intended to show maximal
273          degree of parallelism in the program (*not* to simulate the
274          execution on a real machine). */
275    
276     rtsBool Light;
277
278     rtsBool DoFairSchedule ;        /* fair scheduling alg? default: unfair */
279     rtsBool DoAsyncFetch;           /* async. communication? */
280     rtsBool DoStealThreadsFirst;    /* prefer threads over sparks when stealing */
281   rtsBool DoAlwaysCreateThreads;  /* eager thread creation */
282   rtsBool DoBulkFetching;         /* bulk fetching */
283   rtsBool DoThreadMigration;      /* allow to move threads */
284   nat     FetchStrategy;         /* what to do when waiting for data */
285   rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
286   rtsBool DoPrioritySparking;     /* sparks sorted by priorities */
287   rtsBool DoPriorityScheduling;   /* threads sorted by priorities */
288   nat     SparkPriority;         /* threshold for cut-off mechanism */
289   nat     SparkPriority2;
290   rtsBool RandomPriorities;
291   rtsBool InversePriorities;
292   rtsBool IgnorePriorities;
293   nat     ThunksToPack;      /* number of thunks in packet + 1 */ 
294   rtsBool RandomSteal;        /* steal spark/thread from random proc */
295   rtsBool NoForward;        /* no forwarding of fetch messages */
296
297   // unsigned int           debug;
298   //  rtsBool event_trace;
299   //  rtsBool event_trace_all;
300 };
301 #endif /* GRAN */
302
303 #ifdef TICKY_TICKY
304 struct TICKY_FLAGS {
305     rtsBool showTickyStats;
306     FILE   *tickyFile;
307 };
308 #endif /* TICKY_TICKY */
309
310
311 /* Put them together: */
312
313 struct RTS_FLAGS {
314     struct GC_FLAGS     GcFlags;
315     struct DEBUG_FLAGS  DebugFlags;
316     struct CONCURRENT_FLAGS ConcFlags;
317
318 #if defined(PROFILING) || defined(PAR)
319     struct COST_CENTRE_FLAGS CcFlags;
320 #endif
321 #if defined(PROFILING) || defined(DEBUG)
322     struct PROFILING_FLAGS ProfFlags;
323 #endif
324 #if defined(SMP) || defined(PAR)
325     struct PAR_FLAGS    ParFlags;
326 #endif
327 #ifdef GRAN
328     struct GRAN_FLAGS   GranFlags;
329 #endif
330 #ifdef TICKY_TICKY
331     struct TICKY_FLAGS  TickyFlags;
332 #endif
333 };
334
335 #ifdef COMPILING_RTS_MAIN
336 extern DLLIMPORT struct RTS_FLAGS RtsFlags;
337 #else
338 extern struct RTS_FLAGS RtsFlags;
339 #endif
340
341 /* Routines that operate-on/to-do-with RTS flags: */
342
343 void initRtsFlagsDefaults(void);
344 void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
345
346 /*
347  * The printf formats are here, so we are less likely to make
348  * overly-long filenames (with disastrous results).  No more than 128
349  * chars, please!  
350  */
351
352 #define STATS_FILENAME_MAXLEN   128
353
354 #define GR_FILENAME_FMT         "%0.124s.gr"
355 #define GR_FILENAME_FMT_GUM     "%0.120s.%03d.%s"
356 #define HP_FILENAME_FMT         "%0.124s.hp"
357 #define LIFE_FILENAME_FMT       "%0.122s.life"
358 #define PROF_FILENAME_FMT       "%0.122s.prof"
359 #define PROF_FILENAME_FMT_GUM   "%0.118s.%03d.prof"
360 #define QP_FILENAME_FMT         "%0.124s.qp"
361 #define STAT_FILENAME_FMT       "%0.122s.stat"
362 #define TICKY_FILENAME_FMT      "%0.121s.ticky"
363 #define TIME_FILENAME_FMT       "%0.122s.time"
364 #define TIME_FILENAME_FMT_GUM   "%0.118s.%03d.time"
365
366 /* an "int" so as to match normal "argc" */
367 /* Now defined in Stg.h (lib/std/cbits need these too.)
368 extern int     prog_argc;
369 extern char  **prog_argv;
370 */
371 extern int     rts_argc;  /* ditto */
372 extern char   *rts_argv[];
373
374 #endif  /* RTSFLAGS_H */