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