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