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