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