1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-1999
5 * Datatypes that holds the command-line flag settings.
7 * ---------------------------------------------------------------------------*/
14 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
20 #define COLLECT_GC_STATS 1
21 #define ONELINE_GC_STATS 2
22 #define SUMMARY_GC_STATS 3
23 #define VERBOSE_GC_STATS 4
25 nat maxStkSize; /* in *words* */
26 nat initialStkSize; /* in *words* */
28 nat maxHeapSize; /* in *blocks* */
29 nat minAllocAreaSize; /* in *blocks* */
30 nat minOldGenSize; /* in *blocks* */
31 nat heapSizeSuggestion; /* in *blocks* */
37 rtsBool squeezeUpdFrames;
39 rtsBool compact; /* True <=> "compact all the time" */
40 double compactThreshold;
45 int idleGCDelayTime; /* in milliseconds */
47 StgWord heapBase; /* address to ask the OS for memory */
51 /* flags to control debugging output & extra checking in various subsystems */
52 rtsBool scheduler; /* 's' */
53 rtsBool interpreter; /* 'i' */
54 rtsBool weak; /* 'w' */
55 rtsBool gccafs; /* 'G' */
57 rtsBool block_alloc; /* 'b' */
58 rtsBool sanity; /* 'S' warning: might be expensive! */
59 rtsBool stable; /* 't' */
60 rtsBool prof; /* 'p' */
61 rtsBool gran; /* 'r' */
62 rtsBool par; /* 'P' */
63 rtsBool linker; /* 'l' the object linker */
64 rtsBool apply; /* 'a' */
65 rtsBool stm; /* 'm' */
66 rtsBool squeeze; /* 'z' stack squeezing & lazy blackholing */
67 rtsBool hpc; /* 'c' coverage */
70 struct COST_CENTRE_FLAGS {
71 unsigned int doCostCentres;
72 # define COST_CENTRES_SUMMARY 1
73 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
74 # define COST_CENTRES_ALL 3
75 # define COST_CENTRES_XML 4
77 int profilerTicks; /* derived */
78 int msecsPerTick; /* derived */
81 struct PROFILING_FLAGS {
82 unsigned int doHeapProfile;
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
91 # define HEAP_BY_CLOSURE_TYPE 8
93 nat profileInterval; /* delta between samples (in ms) */
94 nat profileIntervalTicks; /* delta between samples (in 'ticks') */
98 rtsBool showCCSOnException;
100 nat maxRetainerSetSize;
109 char* retainerSelector;
114 struct CONCURRENT_FLAGS {
115 int ctxtSwitchTime; /* in milliseconds */
116 int ctxtSwitchTicks; /* derived */
120 int tickInterval; /* in milliseconds */
121 rtsBool install_signal_handlers;
125 /* currently the same as GRAN_STATS_FLAGS */
126 struct PAR_STATS_FLAGS {
127 rtsBool Full; /* Full .gr profile (rtsTrue) or only END events? */
128 rtsBool Suppressed; /* No .gr profile at all */
129 rtsBool Binary; /* Binary profile? (not yet implemented) */
130 rtsBool Sparks; /* Info on sparks in profile? */
131 rtsBool Heap; /* Info on heap allocs in profile? */
132 rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
133 rtsBool Global; /* Global statistics? (printed on shutdown; no log file) */
136 struct PAR_DEBUG_FLAGS {
137 /* flags to control debugging output in various subsystems */
138 rtsBool verbose : 1; /* 1 */
139 rtsBool bq : 1; /* 2 */
140 rtsBool schedule : 1; /* 4 */
141 rtsBool free : 1; /* 8 */
142 rtsBool resume : 1; /* 16 */
143 rtsBool weight : 1; /* 32 */
144 rtsBool fetch : 1; /* 64 */
145 rtsBool fish : 1; /* 128 */
146 rtsBool tables : 1; /* 256 */
147 rtsBool packet : 1; /* 512 */
148 rtsBool pack : 1; /* 1024 */
149 rtsBool paranoia : 1; /* 2048 */
152 #define MAX_PAR_DEBUG_OPTION 11
153 #define PAR_DEBUG_MASK(n) ((nat)(ldexp(1,n)))
154 #define MAX_PAR_DEBUG_MASK ((nat)(ldexp(1,(MAX_PAR_DEBUG_OPTION+1))-1))
157 struct PAR_STATS_FLAGS ParStats; /* profile and stats output */
158 struct PAR_DEBUG_FLAGS Debug; /* debugging options */
159 rtsBool outputDisabled; /* Disable output for performance purposes */
160 rtsBool doFairScheduling; /* Fair-ish scheduling (round robin; no time-slices) */
162 nat thunksToPack; /* number of thunks in packet + 1 */
163 nat globalising; /* globalisation scheme */
164 nat maxLocalSparks; /* spark pool size */
165 nat maxThreads; /* thread pool size */
166 nat maxFishes; /* max number of active fishes */
167 rtsTime fishDelay; /* delay before sending a new fish */
174 nat nNodes; /* number of threads to run simultaneously */
175 rtsBool migrate; /* migrate threads between capabilities */
176 rtsBool wakeupMigrate; /* migrate a thread on wakeup */
177 unsigned int maxLocalSparks;
178 nat gcThreads; /* number of threads for parallel GC */
180 #endif /* THREADED_RTS */
183 struct GRAN_STATS_FLAGS {
184 rtsBool Full; /* Full .gr profile (rtsTrue) or only END events? */
185 rtsBool Suppressed; /* No .gr profile at all */
186 rtsBool Binary; /* Binary profile? (not yet implemented) */
187 rtsBool Sparks; /* Info on sparks in profile? */
188 rtsBool Heap; /* Info on heap allocs in profile? */
189 rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
190 rtsBool Global; /* Global statistics? (printed on shutdown; no log file) */
193 struct GRAN_COST_FLAGS {
194 /* Communication Cost Variables -- set in main program */
195 nat latency; /* Latency for single packet */
196 nat additional_latency; /* Latency for additional packets */
198 nat lunblocktime; /* Time for local unblock */
199 nat gunblocktime; /* Time for global unblock */
200 nat mpacktime; /* Cost of creating a packet */
201 nat munpacktime; /* Cost of receiving a packet */
202 nat mtidytime; /* Cost of cleaning up after send */
204 nat threadcreatetime; /* Thread creation costs */
205 nat threadqueuetime; /* Cost of adding a thread to the running/runnable queue */
206 nat threaddescheduletime; /* Cost of descheduling a thread */
207 nat threadscheduletime; /* Cost of scheduling a thread */
208 nat threadcontextswitchtime; /* Cost of context switch */
210 /* Instruction Costs */
211 nat arith_cost; /* arithmetic instructions (+,i,< etc) */
212 nat branch_cost; /* branch instructions */
213 nat load_cost; /* load into register */
214 nat store_cost; /* store into memory */
215 nat float_cost; /* floating point operations */
217 nat heapalloc_cost; /* heap allocation costs */
219 /* Overhead for granularity control mechanisms */
220 /* overhead per elem of spark queue */
221 nat pri_spark_overhead;
222 /* overhead per elem of thread queue */
223 nat pri_sched_overhead;
226 struct GRAN_DEBUG_FLAGS {
227 /* flags to control debugging output in various subsystems */
228 rtsBool event_trace : 1; /* 1 */
229 rtsBool event_stats : 1; /* 2 */
230 rtsBool bq : 1; /* 4 */
231 rtsBool pack : 1; /* 8 */
232 rtsBool checkSparkQ : 1; /* 16 */
233 rtsBool thunkStealing : 1; /* 32 */
234 rtsBool randomSteal : 1; /* 64 */
235 rtsBool findWork : 1; /* 128 */
236 rtsBool unused : 1; /* 256 */
237 rtsBool pri : 1; /* 512 */
238 rtsBool checkLight : 1; /* 1024 */
239 rtsBool sortedQ : 1; /* 2048 */
240 rtsBool blockOnFetch : 1; /* 4096 */
241 rtsBool packBuffer : 1; /* 8192 */
242 rtsBool blockOnFetch_sanity : 1; /* 16384 */
245 #define MAX_GRAN_DEBUG_OPTION 14
246 #define GRAN_DEBUG_MASK(n) ((nat)(ldexp(1,n)))
247 #define MAX_GRAN_DEBUG_MASK ((nat)(ldexp(1,(MAX_GRAN_DEBUG_OPTION+1))-1))
250 struct GRAN_STATS_FLAGS GranSimStats; /* profile and stats output */
251 struct GRAN_COST_FLAGS Costs; /* cost metric for simulation */
252 struct GRAN_DEBUG_FLAGS Debug; /* debugging options */
254 nat maxThreads; /* ToDo: share with THREADED_RTS and GUM */
255 /* rtsBool labelling; */
257 nat packBufferSize_internal;
259 PEs proc; /* number of processors */
260 rtsBool Fishing; /* Simulate GUM style fishing mechanism? */
261 nat maxFishes; /* max number of spark or thread steals */
262 rtsTime time_slice; /* max time slice of one reduction thread */
264 /* GrAnSim-Light: This version puts no bound on the number of
265 processors but in exchange doesn't model communication costs
266 (all communication is 0 cost). Mainly intended to show maximal
267 degree of parallelism in the program (*not* to simulate the
268 execution on a real machine). */
272 rtsBool DoFairSchedule ; /* fair scheduling alg? default: unfair */
273 rtsBool DoAsyncFetch; /* async. communication? */
274 rtsBool DoStealThreadsFirst; /* prefer threads over sparks when stealing */
275 rtsBool DoAlwaysCreateThreads; /* eager thread creation */
276 rtsBool DoBulkFetching; /* bulk fetching */
277 rtsBool DoThreadMigration; /* allow to move threads */
278 nat FetchStrategy; /* what to do when waiting for data */
279 rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
280 rtsBool DoPrioritySparking; /* sparks sorted by priorities */
281 rtsBool DoPriorityScheduling; /* threads sorted by priorities */
282 nat SparkPriority; /* threshold for cut-off mechanism */
284 rtsBool RandomPriorities;
285 rtsBool InversePriorities;
286 rtsBool IgnorePriorities;
287 nat ThunksToPack; /* number of thunks in packet + 1 */
288 rtsBool RandomSteal; /* steal spark/thread from random proc */
289 rtsBool NoForward; /* no forwarding of fetch messages */
291 /* unsigned int debug; */
292 /* rtsBool event_trace; */
293 /* rtsBool event_trace_all; */
298 rtsBool showTickyStats;
303 rtsBool sched; /* trace scheduler events for profiling */
304 rtsBool gc; /* trace GC events */
305 rtsBool timestamp; /* add timestamps to traces */
309 #define MAX_PAPI_USER_EVENTS 8
312 nat eventType; /* The type of events to count */
314 char * userEvents[MAX_PAPI_USER_EVENTS];
317 #define PAPI_FLAG_CACHE_L1 1
318 #define PAPI_FLAG_CACHE_L2 2
319 #define PAPI_FLAG_BRANCH 3
320 #define PAPI_FLAG_STALLS 4
321 #define PAPI_FLAG_CB_EVENTS 5
322 #define PAPI_USER_EVENTS 6
326 /* Put them together: */
328 typedef struct _RTS_FLAGS {
329 /* The first portion of RTS_FLAGS is invariant. */
330 struct GC_FLAGS GcFlags;
331 struct CONCURRENT_FLAGS ConcFlags;
332 struct MISC_FLAGS MiscFlags;
333 struct DEBUG_FLAGS DebugFlags;
334 struct COST_CENTRE_FLAGS CcFlags;
335 struct PROFILING_FLAGS ProfFlags;
336 struct TICKY_FLAGS TickyFlags;
337 struct TRACE_FLAGS TraceFlags;
339 #if defined(THREADED_RTS) || defined(PAR)
340 struct PAR_FLAGS ParFlags;
343 struct GRAN_FLAGS GranFlags;
346 struct PAPI_FLAGS PapiFlags;
350 #ifdef COMPILING_RTS_MAIN
351 extern DLLIMPORT RTS_FLAGS RtsFlags;
353 /* Hack because the C code generator can't generate '&label'. */
354 extern RTS_FLAGS RtsFlags[];
356 extern RTS_FLAGS RtsFlags;
359 /* Routines that operate-on/to-do-with RTS flags: */
361 extern void initRtsFlagsDefaults(void);
362 extern void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
363 extern void setProgName(char *argv[]);
367 * The printf formats are here, so we are less likely to make
368 * overly-long filenames (with disastrous results). No more than 128
372 #define STATS_FILENAME_MAXLEN 128
374 #define GR_FILENAME_FMT "%0.124s.gr"
375 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.%s"
376 #define HP_FILENAME_FMT "%0.124s.hp"
377 #define LIFE_FILENAME_FMT "%0.122s.life"
378 #define PROF_FILENAME_FMT "%0.122s.prof"
379 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
380 #define QP_FILENAME_FMT "%0.124s.qp"
381 #define STAT_FILENAME_FMT "%0.122s.stat"
382 #define TICKY_FILENAME_FMT "%0.121s.ticky"
383 #define TIME_FILENAME_FMT "%0.122s.time"
384 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
386 /* an "int" so as to match normal "argc" */
387 /* Now defined in Stg.h (lib/std/cbits need these too.)
388 extern int prog_argc;
389 extern char **prog_argv;
391 extern int rts_argc; /* ditto */
392 extern char *rts_argv[];
394 #endif /* RTSFLAGS_H */