Fix Haddock errors.
[ghc-hetmet.git] / includes / RtsFlags.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1998-1999
4  *
5  * Datatypes that holds the command-line flag settings.
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef RTSFLAGS_H
10 #define RTSFLAGS_H
11
12 #include <stdio.h>
13
14 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
15
16 struct GC_FLAGS {
17     FILE   *statsFile;
18     nat     giveStats;
19 #define NO_GC_STATS      0
20 #define COLLECT_GC_STATS 1
21 #define ONELINE_GC_STATS 2
22 #define SUMMARY_GC_STATS 3
23 #define VERBOSE_GC_STATS 4
24
25     nat     maxStkSize;         /* in *words* */
26     nat     initialStkSize;     /* in *words* */
27
28     nat     maxHeapSize;        /* in *blocks* */
29     nat     minAllocAreaSize;   /* in *blocks* */
30     nat     minOldGenSize;      /* in *blocks* */
31     nat     heapSizeSuggestion; /* in *blocks* */
32     double  oldGenFactor;
33     double  pcFreeHeap;
34
35     nat     generations;
36     nat     steps;
37     rtsBool squeezeUpdFrames;
38
39     rtsBool compact;            /* True <=> "compact all the time" */
40     double  compactThreshold;
41
42     rtsBool sweep;              /* use "mostly mark-sweep" instead of copying
43                                  * for the oldest generation */
44     rtsBool ringBell;
45     rtsBool frontpanel;
46
47     int idleGCDelayTime;        /* in milliseconds */
48
49     StgWord heapBase;           /* address to ask the OS for memory */
50 };
51
52 struct DEBUG_FLAGS {  
53     /* flags to control debugging output & extra checking in various subsystems */
54     rtsBool scheduler;      /* 's' */
55     rtsBool interpreter;    /* 'i' */
56     rtsBool weak;           /* 'w' */
57     rtsBool gccafs;         /* 'G' */
58     rtsBool gc;             /* 'g' */
59     rtsBool block_alloc;    /* 'b' */
60     rtsBool sanity;         /* 'S'   warning: might be expensive! */
61     rtsBool stable;         /* 't' */
62     rtsBool prof;           /* 'p' */
63     rtsBool gran;           /* 'r' */
64     rtsBool par;            /* 'P' */
65     rtsBool linker;         /* 'l'   the object linker */
66     rtsBool apply;          /* 'a' */
67     rtsBool stm;            /* 'm' */
68     rtsBool squeeze;        /* 'z'  stack squeezing & lazy blackholing */
69     rtsBool hpc;            /* 'c' coverage */
70 };
71
72 struct COST_CENTRE_FLAGS {
73     unsigned int            doCostCentres;
74 # define COST_CENTRES_SUMMARY   1
75 # define COST_CENTRES_VERBOSE   2 /* incl. serial time profile */
76 # define COST_CENTRES_ALL       3
77 # define COST_CENTRES_XML       4
78
79     int     profilerTicks;   /* derived */
80     int     msecsPerTick;    /* derived */
81 };
82
83 struct PROFILING_FLAGS {
84     unsigned int        doHeapProfile;
85 # define NO_HEAP_PROFILING      0       /* N.B. Used as indexes into arrays */
86 # define HEAP_BY_CCS            1
87 # define HEAP_BY_MOD            2
88 # define HEAP_BY_DESCR          4
89 # define HEAP_BY_TYPE           5
90 # define HEAP_BY_RETAINER       6
91 # define HEAP_BY_LDV            7
92
93 # define HEAP_BY_CLOSURE_TYPE   8
94
95     nat                 profileInterval;      /* delta between samples (in ms) */
96     nat                 profileIntervalTicks; /* delta between samples (in 'ticks') */
97     rtsBool             includeTSOs;
98
99
100     rtsBool             showCCSOnException;
101
102     nat                 maxRetainerSetSize;
103
104     nat                 ccsLength;
105
106     char*               modSelector;
107     char*               descrSelector;
108     char*               typeSelector;
109     char*               ccSelector;
110     char*               ccsSelector;
111     char*               retainerSelector;
112     char*               bioSelector;
113
114 };
115
116 struct CONCURRENT_FLAGS {
117     int ctxtSwitchTime;         /* in milliseconds */
118     int ctxtSwitchTicks;        /* derived */
119 };
120
121 struct MISC_FLAGS {
122     int tickInterval;     /* in milliseconds */
123     rtsBool install_signal_handlers;
124 };
125
126 #ifdef PAR
127 /* currently the same as GRAN_STATS_FLAGS */
128 struct PAR_STATS_FLAGS {
129   rtsBool Full;       /* Full .gr profile (rtsTrue) or only END events? */
130   rtsBool Suppressed; /* No .gr profile at all */
131   rtsBool Binary;     /* Binary profile? (not yet implemented) */
132   rtsBool Sparks;     /* Info on sparks in profile? */
133   rtsBool Heap;       /* Info on heap allocs in profile? */ 
134   rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
135   rtsBool Global;     /* Global statistics? (printed on shutdown; no log file) */
136 };
137
138 struct PAR_DEBUG_FLAGS {  
139   /* flags to control debugging output in various subsystems */
140   rtsBool verbose    : 1; /*    1 */
141   rtsBool bq         : 1; /*    2 */
142   rtsBool schedule   : 1; /*    4 */
143   rtsBool free       : 1; /*    8 */
144   rtsBool resume     : 1; /*   16 */
145   rtsBool weight     : 1; /*   32 */
146   rtsBool fetch      : 1; /*   64 */
147   rtsBool fish       : 1; /*  128 */
148   rtsBool tables     : 1; /*  256 */
149   rtsBool packet     : 1; /*  512 */
150   rtsBool pack       : 1; /* 1024 */
151   rtsBool paranoia   : 1; /* 2048 */
152 };
153
154 #define MAX_PAR_DEBUG_OPTION     11
155 #define PAR_DEBUG_MASK(n)        ((nat)(ldexp(1,n)))
156 #define MAX_PAR_DEBUG_MASK       ((nat)(ldexp(1,(MAX_PAR_DEBUG_OPTION+1))-1))
157
158 struct PAR_FLAGS {
159   struct PAR_STATS_FLAGS ParStats;  /* profile and stats output */
160   struct PAR_DEBUG_FLAGS Debug;         /* debugging options */
161   rtsBool  outputDisabled;        /* Disable output for performance purposes */
162   rtsBool  doFairScheduling;      /* Fair-ish scheduling (round robin; no time-slices) */
163   nat      packBufferSize;
164   nat      thunksToPack;          /* number of thunks in packet + 1 */ 
165   nat      globalising;           /* globalisation scheme */
166   nat      maxLocalSparks;        /* spark pool size */
167   nat      maxThreads;            /* thread pool size */
168   nat      maxFishes;             /* max number of active fishes */
169   rtsTime  fishDelay;             /* delay before sending a new fish */
170   long   wait;
171 };
172 #endif /* PAR */
173
174 #ifdef THREADED_RTS
175 struct PAR_FLAGS {
176   nat            nNodes;         /* number of threads to run simultaneously */
177   rtsBool        migrate;        /* migrate threads between capabilities */
178   rtsBool        wakeupMigrate;  /* migrate a thread on wakeup */
179   unsigned int   maxLocalSparks;
180   nat            gcThreads;      /* number of threads for parallel GC */
181 };
182 #endif /* THREADED_RTS */
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 THREADED_RTS 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 struct TICKY_FLAGS {
300     rtsBool showTickyStats;
301     FILE   *tickyFile;
302 };
303
304 struct TRACE_FLAGS {
305     rtsBool sched;              /* trace scheduler events for profiling */
306     rtsBool gc;                 /* trace GC events */
307     rtsBool timestamp;          /* add timestamps to traces */
308 };
309
310 #ifdef USE_PAPI
311 #define MAX_PAPI_USER_EVENTS 8
312
313 struct PAPI_FLAGS {
314     nat     eventType;          /* The type of events to count */
315     nat     numUserEvents;
316     char *  userEvents[MAX_PAPI_USER_EVENTS];
317 };
318
319 #define PAPI_FLAG_CACHE_L1 1
320 #define PAPI_FLAG_CACHE_L2 2
321 #define PAPI_FLAG_BRANCH 3
322 #define PAPI_FLAG_STALLS 4
323 #define PAPI_FLAG_CB_EVENTS 5
324 #define PAPI_USER_EVENTS 6
325
326 #endif
327
328 /* Put them together: */
329
330 typedef struct _RTS_FLAGS {
331     /* The first portion of RTS_FLAGS is invariant. */
332     struct GC_FLAGS          GcFlags;
333     struct CONCURRENT_FLAGS  ConcFlags;
334     struct MISC_FLAGS        MiscFlags;
335     struct DEBUG_FLAGS       DebugFlags;
336     struct COST_CENTRE_FLAGS CcFlags;
337     struct PROFILING_FLAGS   ProfFlags;
338     struct TICKY_FLAGS       TickyFlags;
339     struct TRACE_FLAGS       TraceFlags;
340
341 #if defined(THREADED_RTS) || defined(PAR)
342     struct PAR_FLAGS    ParFlags;
343 #endif
344 #ifdef GRAN
345     struct GRAN_FLAGS   GranFlags;
346 #endif
347 #ifdef USE_PAPI
348     struct PAPI_FLAGS   PapiFlags;
349 #endif
350 } RTS_FLAGS;
351
352 #ifdef COMPILING_RTS_MAIN
353 extern DLLIMPORT RTS_FLAGS RtsFlags;
354 #elif IN_STG_CODE
355 /* Hack because the C code generator can't generate '&label'. */
356 extern RTS_FLAGS RtsFlags[];
357 #else
358 extern RTS_FLAGS RtsFlags;
359 #endif
360
361 /* Routines that operate-on/to-do-with RTS flags: */
362
363 extern void initRtsFlagsDefaults(void);
364 extern void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
365 extern void setProgName(char *argv[]);
366
367
368 /*
369  * The printf formats are here, so we are less likely to make
370  * overly-long filenames (with disastrous results).  No more than 128
371  * chars, please!  
372  */
373
374 #define STATS_FILENAME_MAXLEN   128
375
376 #define GR_FILENAME_FMT         "%0.124s.gr"
377 #define GR_FILENAME_FMT_GUM     "%0.120s.%03d.%s"
378 #define HP_FILENAME_FMT         "%0.124s.hp"
379 #define LIFE_FILENAME_FMT       "%0.122s.life"
380 #define PROF_FILENAME_FMT       "%0.122s.prof"
381 #define PROF_FILENAME_FMT_GUM   "%0.118s.%03d.prof"
382 #define QP_FILENAME_FMT         "%0.124s.qp"
383 #define STAT_FILENAME_FMT       "%0.122s.stat"
384 #define TICKY_FILENAME_FMT      "%0.121s.ticky"
385 #define TIME_FILENAME_FMT       "%0.122s.time"
386 #define TIME_FILENAME_FMT_GUM   "%0.118s.%03d.time"
387
388 /* an "int" so as to match normal "argc" */
389 /* Now defined in Stg.h (lib/std/cbits need these too.)
390 extern int     prog_argc;
391 extern char  **prog_argv;
392 */
393 extern int     rts_argc;  /* ditto */
394 extern char   *rts_argv[];
395
396 #endif  /* RTSFLAGS_H */