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