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;
179 #endif /* THREADED_RTS */
182 struct GRAN_STATS_FLAGS {
183 rtsBool Full; /* Full .gr profile (rtsTrue) or only END events? */
184 rtsBool Suppressed; /* No .gr profile at all */
185 rtsBool Binary; /* Binary profile? (not yet implemented) */
186 rtsBool Sparks; /* Info on sparks in profile? */
187 rtsBool Heap; /* Info on heap allocs in profile? */
188 rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
189 rtsBool Global; /* Global statistics? (printed on shutdown; no log file) */
192 struct GRAN_COST_FLAGS {
193 /* Communication Cost Variables -- set in main program */
194 nat latency; /* Latency for single packet */
195 nat additional_latency; /* Latency for additional packets */
197 nat lunblocktime; /* Time for local unblock */
198 nat gunblocktime; /* Time for global unblock */
199 nat mpacktime; /* Cost of creating a packet */
200 nat munpacktime; /* Cost of receiving a packet */
201 nat mtidytime; /* Cost of cleaning up after send */
203 nat threadcreatetime; /* Thread creation costs */
204 nat threadqueuetime; /* Cost of adding a thread to the running/runnable queue */
205 nat threaddescheduletime; /* Cost of descheduling a thread */
206 nat threadscheduletime; /* Cost of scheduling a thread */
207 nat threadcontextswitchtime; /* Cost of context switch */
209 /* Instruction Costs */
210 nat arith_cost; /* arithmetic instructions (+,i,< etc) */
211 nat branch_cost; /* branch instructions */
212 nat load_cost; /* load into register */
213 nat store_cost; /* store into memory */
214 nat float_cost; /* floating point operations */
216 nat heapalloc_cost; /* heap allocation costs */
218 /* Overhead for granularity control mechanisms */
219 /* overhead per elem of spark queue */
220 nat pri_spark_overhead;
221 /* overhead per elem of thread queue */
222 nat pri_sched_overhead;
225 struct GRAN_DEBUG_FLAGS {
226 /* flags to control debugging output in various subsystems */
227 rtsBool event_trace : 1; /* 1 */
228 rtsBool event_stats : 1; /* 2 */
229 rtsBool bq : 1; /* 4 */
230 rtsBool pack : 1; /* 8 */
231 rtsBool checkSparkQ : 1; /* 16 */
232 rtsBool thunkStealing : 1; /* 32 */
233 rtsBool randomSteal : 1; /* 64 */
234 rtsBool findWork : 1; /* 128 */
235 rtsBool unused : 1; /* 256 */
236 rtsBool pri : 1; /* 512 */
237 rtsBool checkLight : 1; /* 1024 */
238 rtsBool sortedQ : 1; /* 2048 */
239 rtsBool blockOnFetch : 1; /* 4096 */
240 rtsBool packBuffer : 1; /* 8192 */
241 rtsBool blockOnFetch_sanity : 1; /* 16384 */
244 #define MAX_GRAN_DEBUG_OPTION 14
245 #define GRAN_DEBUG_MASK(n) ((nat)(ldexp(1,n)))
246 #define MAX_GRAN_DEBUG_MASK ((nat)(ldexp(1,(MAX_GRAN_DEBUG_OPTION+1))-1))
249 struct GRAN_STATS_FLAGS GranSimStats; /* profile and stats output */
250 struct GRAN_COST_FLAGS Costs; /* cost metric for simulation */
251 struct GRAN_DEBUG_FLAGS Debug; /* debugging options */
253 nat maxThreads; /* ToDo: share with THREADED_RTS and GUM */
254 /* rtsBool labelling; */
256 nat packBufferSize_internal;
258 PEs proc; /* number of processors */
259 rtsBool Fishing; /* Simulate GUM style fishing mechanism? */
260 nat maxFishes; /* max number of spark or thread steals */
261 rtsTime time_slice; /* max time slice of one reduction thread */
263 /* GrAnSim-Light: This version puts no bound on the number of
264 processors but in exchange doesn't model communication costs
265 (all communication is 0 cost). Mainly intended to show maximal
266 degree of parallelism in the program (*not* to simulate the
267 execution on a real machine). */
271 rtsBool DoFairSchedule ; /* fair scheduling alg? default: unfair */
272 rtsBool DoAsyncFetch; /* async. communication? */
273 rtsBool DoStealThreadsFirst; /* prefer threads over sparks when stealing */
274 rtsBool DoAlwaysCreateThreads; /* eager thread creation */
275 rtsBool DoBulkFetching; /* bulk fetching */
276 rtsBool DoThreadMigration; /* allow to move threads */
277 nat FetchStrategy; /* what to do when waiting for data */
278 rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
279 rtsBool DoPrioritySparking; /* sparks sorted by priorities */
280 rtsBool DoPriorityScheduling; /* threads sorted by priorities */
281 nat SparkPriority; /* threshold for cut-off mechanism */
283 rtsBool RandomPriorities;
284 rtsBool InversePriorities;
285 rtsBool IgnorePriorities;
286 nat ThunksToPack; /* number of thunks in packet + 1 */
287 rtsBool RandomSteal; /* steal spark/thread from random proc */
288 rtsBool NoForward; /* no forwarding of fetch messages */
290 /* unsigned int debug; */
291 /* rtsBool event_trace; */
292 /* rtsBool event_trace_all; */
297 rtsBool showTickyStats;
302 rtsBool sched; /* trace scheduler events for profiling */
303 rtsBool timestamp; /* add timestamps to traces */
306 /* Put them together: */
310 nat eventType; /* The type of events to count */
313 #define PAPI_FLAG_CACHE_L1 1
314 #define PAPI_FLAG_CACHE_L2 2
315 #define PAPI_FLAG_BRANCH 3
316 #define PAPI_FLAG_STALLS 4
317 #define PAPI_FLAG_CB_EVENTS 5
321 typedef struct _RTS_FLAGS {
322 /* The first portion of RTS_FLAGS is invariant. */
323 struct GC_FLAGS GcFlags;
324 struct CONCURRENT_FLAGS ConcFlags;
325 struct MISC_FLAGS MiscFlags;
326 struct DEBUG_FLAGS DebugFlags;
327 struct COST_CENTRE_FLAGS CcFlags;
328 struct PROFILING_FLAGS ProfFlags;
329 struct TICKY_FLAGS TickyFlags;
330 struct TRACE_FLAGS TraceFlags;
332 #if defined(THREADED_RTS) || defined(PAR)
333 struct PAR_FLAGS ParFlags;
336 struct GRAN_FLAGS GranFlags;
339 struct PAPI_FLAGS PapiFlags;
343 #ifdef COMPILING_RTS_MAIN
344 extern DLLIMPORT RTS_FLAGS RtsFlags;
346 /* Hack because the C code generator can't generate '&label'. */
347 extern RTS_FLAGS RtsFlags[];
349 extern RTS_FLAGS RtsFlags;
352 /* Routines that operate-on/to-do-with RTS flags: */
354 extern void initRtsFlagsDefaults(void);
355 extern void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
356 extern void setProgName(char *argv[]);
360 * The printf formats are here, so we are less likely to make
361 * overly-long filenames (with disastrous results). No more than 128
365 #define STATS_FILENAME_MAXLEN 128
367 #define GR_FILENAME_FMT "%0.124s.gr"
368 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.%s"
369 #define HP_FILENAME_FMT "%0.124s.hp"
370 #define LIFE_FILENAME_FMT "%0.122s.life"
371 #define PROF_FILENAME_FMT "%0.122s.prof"
372 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
373 #define QP_FILENAME_FMT "%0.124s.qp"
374 #define STAT_FILENAME_FMT "%0.122s.stat"
375 #define TICKY_FILENAME_FMT "%0.121s.ticky"
376 #define TIME_FILENAME_FMT "%0.122s.time"
377 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
379 /* an "int" so as to match normal "argc" */
380 /* Now defined in Stg.h (lib/std/cbits need these too.)
381 extern int prog_argc;
382 extern char **prog_argv;
384 extern int rts_argc; /* ditto */
385 extern char *rts_argv[];
387 #endif /* RTSFLAGS_H */