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