[project @ 2002-09-05 08:58:55 by simonmar]
[ghc-hetmet.git] / ghc / includes / RtsFlags.h
1 /* -----------------------------------------------------------------------------
2  * $Id: RtsFlags.h,v 1.43 2002/08/05 10:11:03 simonmar Exp $
3  *
4  * (c) The GHC Team, 1998-1999
5  *
6  * Datatypes that holds the command-line flag settings.
7  *
8  * ---------------------------------------------------------------------------*/
9
10 #ifndef RTSFLAGS_H
11 #define RTSFLAGS_H
12
13 #include <stdio.h>
14
15 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
16
17 struct GC_FLAGS {
18     FILE   *statsFile;
19     nat     giveStats;
20 #define NO_GC_STATS      0
21 #define COLLECT_GC_STATS 1
22 #define ONELINE_GC_STATS 2
23 #define SUMMARY_GC_STATS 3
24 #define VERBOSE_GC_STATS 4
25
26     nat     maxStkSize;         /* in *words* */
27     nat     initialStkSize;     /* in *words* */
28
29     nat     maxHeapSize;        /* in *blocks* */
30     nat     minAllocAreaSize;   /* in *blocks* */
31     nat     minOldGenSize;      /* in *blocks* */
32     nat     heapSizeSuggestion; /* in *blocks* */
33     double  oldGenFactor;
34     double  pcFreeHeap;
35
36     nat     generations;
37     nat     steps;
38     rtsBool squeezeUpdFrames;
39
40     rtsBool compact;            /* True <=> "compact all the time" */
41     double  compactThreshold;
42
43     rtsBool ringBell;
44     rtsBool frontpanel;
45 };
46
47 struct DEBUG_FLAGS {  
48     // flags to control debugging output & extra checking in various subsystems
49     rtsBool scheduler;      // 's'
50     rtsBool evaluator;      // 'e'
51     rtsBool codegen;        // 'c'
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 };
63
64 struct COST_CENTRE_FLAGS {
65     unsigned int            doCostCentres;
66 # define COST_CENTRES_SUMMARY   1
67 # define COST_CENTRES_VERBOSE   2 /* incl. serial time profile */
68 # define COST_CENTRES_ALL       3
69 # define COST_CENTRES_XML       4
70
71     int     profilerTicks;   /* derived */
72     int     msecsPerTick;    /* derived */
73 };
74
75 #ifdef PROFILING
76 struct PROFILING_FLAGS {
77     unsigned int        doHeapProfile;
78
79     nat                 profileInterval;      /* delta between samples (in ms) */
80     nat                 profileIntervalTicks; /* delta between samples (in 'ticks') */
81
82
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     rtsBool             showCCSOnException;
92   
93     nat                 maxRetainerSetSize;
94
95     char*               modSelector;
96     char*               descrSelector;
97     char*               typeSelector;
98     char*               ccSelector;
99     char*               ccsSelector;
100     char*               retainerSelector;
101     char*               bioSelector;
102
103 };
104 #elif defined(DEBUG)
105 # define NO_HEAP_PROFILING      0
106 # define HEAP_BY_INFOPTR        1
107 # define HEAP_BY_CLOSURE_TYPE   2
108 struct PROFILING_FLAGS {
109     unsigned int  doHeapProfile;     /* heap profile using symbol table */
110
111 };
112 #endif /* DEBUG || PROFILING */
113
114 struct CONCURRENT_FLAGS {
115     int ctxtSwitchTime;         /* in milliseconds */
116     int ctxtSwitchTicks;        /* derived */
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 SMP
168 struct PAR_FLAGS {
169   nat            nNodes;         /* number of threads to run simultaneously */
170   unsigned int   maxLocalSparks;
171 };
172 #endif /* SMP */
173
174 #ifdef GRAN
175 struct GRAN_STATS_FLAGS {
176   rtsBool Full;       /* Full .gr profile (rtsTrue) or only END events? */
177   rtsBool Suppressed; /* No .gr profile at all */
178   rtsBool Binary;     /* Binary profile? (not yet implemented) */
179   rtsBool Sparks;     /* Info on sparks in profile? */
180   rtsBool Heap;       /* Info on heap allocs in profile? */ 
181   rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
182   rtsBool Global;     /* Global statistics? (printed on shutdown; no log file) */
183 };
184
185 struct GRAN_COST_FLAGS {
186   /* Communication Cost Variables -- set in main program */
187   nat latency;              /* Latency for single packet */
188   nat additional_latency;   /* Latency for additional packets */
189   nat fetchtime;            
190   nat lunblocktime;         /* Time for local unblock */
191   nat gunblocktime;         /* Time for global unblock */
192   nat mpacktime;            /* Cost of creating a packet */     
193   nat munpacktime;          /* Cost of receiving a packet */    
194   nat mtidytime;            /* Cost of cleaning up after send */
195   
196   nat threadcreatetime;     /* Thread creation costs */
197   nat threadqueuetime;      /* Cost of adding a thread to the running/runnable queue */
198   nat threaddescheduletime; /* Cost of descheduling a thread */
199   nat threadscheduletime;   /* Cost of scheduling a thread */
200   nat threadcontextswitchtime;  /* Cost of context switch  */
201   
202   /* Instruction Costs */
203   nat arith_cost;        /* arithmetic instructions (+,i,< etc) */
204   nat branch_cost;       /* branch instructions */ 
205   nat load_cost;         /* load into register */
206   nat store_cost;        /* store into memory */
207   nat float_cost;        /* floating point operations */
208   
209   nat heapalloc_cost;    /* heap allocation costs */
210   
211   /* Overhead for granularity control mechanisms */
212   /* overhead per elem of spark queue */
213   nat pri_spark_overhead;
214   /* overhead per elem of thread queue */
215   nat pri_sched_overhead;
216 };
217
218 struct GRAN_DEBUG_FLAGS {  
219   /* flags to control debugging output in various subsystems */
220   rtsBool event_trace    : 1; /*    1 */
221   rtsBool event_stats    : 1; /*    2 */
222   rtsBool bq             : 1; /*    4 */
223   rtsBool pack           : 1; /*    8 */
224   rtsBool checkSparkQ    : 1; /*   16 */
225   rtsBool thunkStealing  : 1; /*   32 */
226   rtsBool randomSteal    : 1; /*   64 */
227   rtsBool findWork       : 1; /*  128 */
228   rtsBool unused         : 1; /*  256 */
229   rtsBool pri            : 1; /*  512 */
230   rtsBool checkLight     : 1; /* 1024 */
231   rtsBool sortedQ        : 1; /* 2048 */
232   rtsBool blockOnFetch   : 1; /* 4096 */
233   rtsBool packBuffer     : 1; /* 8192 */
234   rtsBool blockOnFetch_sanity : 1; /*  16384 */
235 };
236
237 #define MAX_GRAN_DEBUG_OPTION     14
238 #define GRAN_DEBUG_MASK(n)        ((nat)(ldexp(1,n)))
239 #define MAX_GRAN_DEBUG_MASK       ((nat)(ldexp(1,(MAX_GRAN_DEBUG_OPTION+1))-1))
240
241 struct GRAN_FLAGS {
242   struct GRAN_STATS_FLAGS GranSimStats;  /* profile and stats output */
243   struct GRAN_COST_FLAGS Costs;          /* cost metric for simulation */
244   struct GRAN_DEBUG_FLAGS Debug;         /* debugging options */
245
246   nat  maxThreads;              // ToDo: share with SMP and GUM
247   // rtsBool labelling;
248   nat  packBufferSize;
249   nat  packBufferSize_internal;
250
251   PEs proc;                     /* number of processors */
252   rtsBool Fishing;              /* Simulate GUM style fishing mechanism? */
253   nat maxFishes;                /* max number of spark or thread steals */
254   rtsTime time_slice;           /* max time slice of one reduction thread */
255
256     /* GrAnSim-Light: This version puts no bound on the number of
257          processors but in exchange doesn't model communication costs
258          (all communication is 0 cost). Mainly intended to show maximal
259          degree of parallelism in the program (*not* to simulate the
260          execution on a real machine). */
261    
262     rtsBool Light;
263
264     rtsBool DoFairSchedule ;        /* fair scheduling alg? default: unfair */
265     rtsBool DoAsyncFetch;           /* async. communication? */
266     rtsBool DoStealThreadsFirst;    /* prefer threads over sparks when stealing */
267   rtsBool DoAlwaysCreateThreads;  /* eager thread creation */
268   rtsBool DoBulkFetching;         /* bulk fetching */
269   rtsBool DoThreadMigration;      /* allow to move threads */
270   nat     FetchStrategy;         /* what to do when waiting for data */
271   rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
272   rtsBool DoPrioritySparking;     /* sparks sorted by priorities */
273   rtsBool DoPriorityScheduling;   /* threads sorted by priorities */
274   nat     SparkPriority;         /* threshold for cut-off mechanism */
275   nat     SparkPriority2;
276   rtsBool RandomPriorities;
277   rtsBool InversePriorities;
278   rtsBool IgnorePriorities;
279   nat     ThunksToPack;      /* number of thunks in packet + 1 */ 
280   rtsBool RandomSteal;        /* steal spark/thread from random proc */
281   rtsBool NoForward;        /* no forwarding of fetch messages */
282
283   // unsigned int           debug;
284   //  rtsBool event_trace;
285   //  rtsBool event_trace_all;
286 };
287 #endif /* GRAN */
288
289 #ifdef TICKY_TICKY
290 struct TICKY_FLAGS {
291     rtsBool showTickyStats;
292     FILE   *tickyFile;
293 };
294 #endif /* TICKY_TICKY */
295
296
297 /* Put them together: */
298
299 struct RTS_FLAGS {
300     struct GC_FLAGS     GcFlags;
301     struct CONCURRENT_FLAGS ConcFlags;
302
303 #ifdef DEBUG
304     struct DEBUG_FLAGS  DebugFlags;
305 #endif
306 #if defined(PROFILING) || defined(PAR)
307     struct COST_CENTRE_FLAGS CcFlags;
308 #endif
309 #if defined(PROFILING) || defined(DEBUG)
310     struct PROFILING_FLAGS ProfFlags;
311 #endif
312 #if defined(SMP) || defined(PAR)
313     struct PAR_FLAGS    ParFlags;
314 #endif
315 #ifdef GRAN
316     struct GRAN_FLAGS   GranFlags;
317 #endif
318 #ifdef TICKY_TICKY
319     struct TICKY_FLAGS  TickyFlags;
320 #endif
321 };
322
323 #ifdef COMPILING_RTS_MAIN
324 extern DLLIMPORT struct RTS_FLAGS RtsFlags;
325 #else
326 extern struct RTS_FLAGS RtsFlags;
327 #endif
328
329 /* Routines that operate-on/to-do-with RTS flags: */
330
331 void initRtsFlagsDefaults(void);
332 void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
333
334 /*
335  * The printf formats are here, so we are less likely to make
336  * overly-long filenames (with disastrous results).  No more than 128
337  * chars, please!  
338  */
339
340 #define STATS_FILENAME_MAXLEN   128
341
342 #define GR_FILENAME_FMT         "%0.124s.gr"
343 #define GR_FILENAME_FMT_GUM     "%0.120s.%03d.%s"
344 #define HP_FILENAME_FMT         "%0.124s.hp"
345 #define LIFE_FILENAME_FMT       "%0.122s.life"
346 #define PROF_FILENAME_FMT       "%0.122s.prof"
347 #define PROF_FILENAME_FMT_GUM   "%0.118s.%03d.prof"
348 #define QP_FILENAME_FMT         "%0.124s.qp"
349 #define STAT_FILENAME_FMT       "%0.122s.stat"
350 #define TICKY_FILENAME_FMT      "%0.121s.ticky"
351 #define TIME_FILENAME_FMT       "%0.122s.time"
352 #define TIME_FILENAME_FMT_GUM   "%0.118s.%03d.time"
353
354 /* an "int" so as to match normal "argc" */
355 /* Now defined in Stg.h (lib/std/cbits need these too.)
356 extern int     prog_argc;
357 extern char  **prog_argv;
358 */
359 extern int     rts_argc;  /* ditto */
360 extern char   *rts_argv[];
361
362 #endif  /* RTSFLAGS_H */