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