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