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