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 */
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 */
65 rtsBool hpc; /* 'c' coverage */
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
75 int profilerTicks; /* derived */
76 int msecsPerTick; /* derived */
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
89 # define HEAP_BY_INFOPTR 1 /* DEBUG only */
90 # define HEAP_BY_CLOSURE_TYPE 2 /* DEBUG only */
92 nat profileInterval; /* delta between samples (in ms) */
93 nat profileIntervalTicks; /* delta between samples (in 'ticks') */
97 rtsBool showCCSOnException;
99 nat maxRetainerSetSize;
108 char* retainerSelector;
113 struct CONCURRENT_FLAGS {
114 int ctxtSwitchTime; /* in milliseconds */
115 int ctxtSwitchTicks; /* derived */
119 int tickInterval; /* in milliseconds */
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) */
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 */
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))
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) */
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 */
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;
177 #endif /* THREADED_RTS */
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) */
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 */
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 */
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 */
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 */
214 nat heapalloc_cost; /* heap allocation costs */
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;
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 */
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))
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 */
251 nat maxThreads; /* ToDo: share with THREADED_RTS and GUM */
252 /* rtsBool labelling; */
254 nat packBufferSize_internal;
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 */
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). */
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 */
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 */
288 /* unsigned int debug; */
289 /* rtsBool event_trace; */
290 /* rtsBool event_trace_all; */
295 rtsBool showTickyStats;
300 rtsBool sched; /* trace scheduler events for profiling */
301 rtsBool timestamp; /* add timestamps to traces */
304 /* Put them together: */
308 nat eventType; /* The type of events to count */
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
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;
330 #if defined(THREADED_RTS) || defined(PAR)
331 struct PAR_FLAGS ParFlags;
334 struct GRAN_FLAGS GranFlags;
337 struct PAPI_FLAGS PapiFlags;
341 #ifdef COMPILING_RTS_MAIN
342 extern DLLIMPORT RTS_FLAGS RtsFlags;
344 /* Hack because the C code generator can't generate '&label'. */
345 extern RTS_FLAGS RtsFlags[];
347 extern RTS_FLAGS RtsFlags;
350 /* Routines that operate-on/to-do-with RTS flags: */
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[]);
358 * The printf formats are here, so we are less likely to make
359 * overly-long filenames (with disastrous results). No more than 128
363 #define STATS_FILENAME_MAXLEN 128
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"
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;
382 extern int rts_argc; /* ditto */
383 extern char *rts_argv[];
385 #endif /* RTSFLAGS_H */