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