1 /* -----------------------------------------------------------------------------
2 * $Id: RtsFlags.h,v 1.48 2005/02/03 10:59:05 simonmar Exp $
4 * (c) The GHC Team, 1998-1999
6 * Datatypes that holds the command-line flag settings.
8 * ---------------------------------------------------------------------------*/
15 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
21 #define COLLECT_GC_STATS 1
22 #define ONELINE_GC_STATS 2
23 #define SUMMARY_GC_STATS 3
24 #define VERBOSE_GC_STATS 4
26 nat maxStkSize; /* in *words* */
27 nat initialStkSize; /* in *words* */
29 nat maxHeapSize; /* in *blocks* */
30 nat minAllocAreaSize; /* in *blocks* */
31 nat minOldGenSize; /* in *blocks* */
32 nat heapSizeSuggestion; /* in *blocks* */
38 rtsBool squeezeUpdFrames;
40 rtsBool compact; /* True <=> "compact all the time" */
41 double compactThreshold;
48 // flags to control debugging output & extra checking in various subsystems
49 rtsBool scheduler; // 's'
50 rtsBool interpreter; // 'i'
51 rtsBool codegen; // 'c'
53 rtsBool gccafs; // 'G'
55 rtsBool block_alloc; // 'b'
56 rtsBool sanity; // 'S' warning: might be expensive!
57 rtsBool stable; // 't'
61 rtsBool linker; // 'l' the object linker
66 struct COST_CENTRE_FLAGS {
67 unsigned int doCostCentres;
68 # define COST_CENTRES_SUMMARY 1
69 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
70 # define COST_CENTRES_ALL 3
71 # define COST_CENTRES_XML 4
73 int profilerTicks; /* derived */
74 int msecsPerTick; /* derived */
77 struct PROFILING_FLAGS {
78 unsigned int doHeapProfile;
79 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
80 # define HEAP_BY_CCS 1
81 # define HEAP_BY_MOD 2
82 # define HEAP_BY_DESCR 4
83 # define HEAP_BY_TYPE 5
84 # define HEAP_BY_RETAINER 6
85 # define HEAP_BY_LDV 7
87 # define HEAP_BY_INFOPTR 1 /* DEBUG only */
88 # define HEAP_BY_CLOSURE_TYPE 2 /* DEBUG only */
90 nat profileInterval; /* delta between samples (in ms) */
91 nat profileIntervalTicks; /* delta between samples (in 'ticks') */
95 rtsBool showCCSOnException;
97 nat maxRetainerSetSize;
104 char* retainerSelector;
109 struct CONCURRENT_FLAGS {
110 int ctxtSwitchTime; /* in milliseconds */
111 int ctxtSwitchTicks; /* derived */
115 /* currently the same as GRAN_STATS_FLAGS */
116 struct PAR_STATS_FLAGS {
117 rtsBool Full; /* Full .gr profile (rtsTrue) or only END events? */
118 rtsBool Suppressed; /* No .gr profile at all */
119 rtsBool Binary; /* Binary profile? (not yet implemented) */
120 rtsBool Sparks; /* Info on sparks in profile? */
121 rtsBool Heap; /* Info on heap allocs in profile? */
122 rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
123 rtsBool Global; /* Global statistics? (printed on shutdown; no log file) */
126 struct PAR_DEBUG_FLAGS {
127 /* flags to control debugging output in various subsystems */
128 rtsBool verbose : 1; /* 1 */
129 rtsBool bq : 1; /* 2 */
130 rtsBool schedule : 1; /* 4 */
131 rtsBool free : 1; /* 8 */
132 rtsBool resume : 1; /* 16 */
133 rtsBool weight : 1; /* 32 */
134 rtsBool fetch : 1; /* 64 */
135 rtsBool fish : 1; /* 128 */
136 rtsBool tables : 1; /* 256 */
137 rtsBool packet : 1; /* 512 */
138 rtsBool pack : 1; /* 1024 */
139 rtsBool paranoia : 1; /* 2048 */
142 #define MAX_PAR_DEBUG_OPTION 11
143 #define PAR_DEBUG_MASK(n) ((nat)(ldexp(1,n)))
144 #define MAX_PAR_DEBUG_MASK ((nat)(ldexp(1,(MAX_PAR_DEBUG_OPTION+1))-1))
147 struct PAR_STATS_FLAGS ParStats; /* profile and stats output */
148 struct PAR_DEBUG_FLAGS Debug; /* debugging options */
149 rtsBool outputDisabled; /* Disable output for performance purposes */
150 rtsBool doFairScheduling; /* Fair-ish scheduling (round robin; no time-slices) */
152 nat thunksToPack; /* number of thunks in packet + 1 */
153 nat globalising; /* globalisation scheme */
154 nat maxLocalSparks; /* spark pool size */
155 nat maxThreads; /* thread pool size */
156 nat maxFishes; /* max number of active fishes */
157 rtsTime fishDelay; /* delay before sending a new fish */
164 nat nNodes; /* number of threads to run simultaneously */
165 unsigned int maxLocalSparks;
170 struct GRAN_STATS_FLAGS {
171 rtsBool Full; /* Full .gr profile (rtsTrue) or only END events? */
172 rtsBool Suppressed; /* No .gr profile at all */
173 rtsBool Binary; /* Binary profile? (not yet implemented) */
174 rtsBool Sparks; /* Info on sparks in profile? */
175 rtsBool Heap; /* Info on heap allocs in profile? */
176 rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
177 rtsBool Global; /* Global statistics? (printed on shutdown; no log file) */
180 struct GRAN_COST_FLAGS {
181 /* Communication Cost Variables -- set in main program */
182 nat latency; /* Latency for single packet */
183 nat additional_latency; /* Latency for additional packets */
185 nat lunblocktime; /* Time for local unblock */
186 nat gunblocktime; /* Time for global unblock */
187 nat mpacktime; /* Cost of creating a packet */
188 nat munpacktime; /* Cost of receiving a packet */
189 nat mtidytime; /* Cost of cleaning up after send */
191 nat threadcreatetime; /* Thread creation costs */
192 nat threadqueuetime; /* Cost of adding a thread to the running/runnable queue */
193 nat threaddescheduletime; /* Cost of descheduling a thread */
194 nat threadscheduletime; /* Cost of scheduling a thread */
195 nat threadcontextswitchtime; /* Cost of context switch */
197 /* Instruction Costs */
198 nat arith_cost; /* arithmetic instructions (+,i,< etc) */
199 nat branch_cost; /* branch instructions */
200 nat load_cost; /* load into register */
201 nat store_cost; /* store into memory */
202 nat float_cost; /* floating point operations */
204 nat heapalloc_cost; /* heap allocation costs */
206 /* Overhead for granularity control mechanisms */
207 /* overhead per elem of spark queue */
208 nat pri_spark_overhead;
209 /* overhead per elem of thread queue */
210 nat pri_sched_overhead;
213 struct GRAN_DEBUG_FLAGS {
214 /* flags to control debugging output in various subsystems */
215 rtsBool event_trace : 1; /* 1 */
216 rtsBool event_stats : 1; /* 2 */
217 rtsBool bq : 1; /* 4 */
218 rtsBool pack : 1; /* 8 */
219 rtsBool checkSparkQ : 1; /* 16 */
220 rtsBool thunkStealing : 1; /* 32 */
221 rtsBool randomSteal : 1; /* 64 */
222 rtsBool findWork : 1; /* 128 */
223 rtsBool unused : 1; /* 256 */
224 rtsBool pri : 1; /* 512 */
225 rtsBool checkLight : 1; /* 1024 */
226 rtsBool sortedQ : 1; /* 2048 */
227 rtsBool blockOnFetch : 1; /* 4096 */
228 rtsBool packBuffer : 1; /* 8192 */
229 rtsBool blockOnFetch_sanity : 1; /* 16384 */
232 #define MAX_GRAN_DEBUG_OPTION 14
233 #define GRAN_DEBUG_MASK(n) ((nat)(ldexp(1,n)))
234 #define MAX_GRAN_DEBUG_MASK ((nat)(ldexp(1,(MAX_GRAN_DEBUG_OPTION+1))-1))
237 struct GRAN_STATS_FLAGS GranSimStats; /* profile and stats output */
238 struct GRAN_COST_FLAGS Costs; /* cost metric for simulation */
239 struct GRAN_DEBUG_FLAGS Debug; /* debugging options */
241 nat maxThreads; // ToDo: share with SMP and GUM
242 // rtsBool labelling;
244 nat packBufferSize_internal;
246 PEs proc; /* number of processors */
247 rtsBool Fishing; /* Simulate GUM style fishing mechanism? */
248 nat maxFishes; /* max number of spark or thread steals */
249 rtsTime time_slice; /* max time slice of one reduction thread */
251 /* GrAnSim-Light: This version puts no bound on the number of
252 processors but in exchange doesn't model communication costs
253 (all communication is 0 cost). Mainly intended to show maximal
254 degree of parallelism in the program (*not* to simulate the
255 execution on a real machine). */
259 rtsBool DoFairSchedule ; /* fair scheduling alg? default: unfair */
260 rtsBool DoAsyncFetch; /* async. communication? */
261 rtsBool DoStealThreadsFirst; /* prefer threads over sparks when stealing */
262 rtsBool DoAlwaysCreateThreads; /* eager thread creation */
263 rtsBool DoBulkFetching; /* bulk fetching */
264 rtsBool DoThreadMigration; /* allow to move threads */
265 nat FetchStrategy; /* what to do when waiting for data */
266 rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
267 rtsBool DoPrioritySparking; /* sparks sorted by priorities */
268 rtsBool DoPriorityScheduling; /* threads sorted by priorities */
269 nat SparkPriority; /* threshold for cut-off mechanism */
271 rtsBool RandomPriorities;
272 rtsBool InversePriorities;
273 rtsBool IgnorePriorities;
274 nat ThunksToPack; /* number of thunks in packet + 1 */
275 rtsBool RandomSteal; /* steal spark/thread from random proc */
276 rtsBool NoForward; /* no forwarding of fetch messages */
278 // unsigned int debug;
279 // rtsBool event_trace;
280 // rtsBool event_trace_all;
285 rtsBool showTickyStats;
290 /* Put them together: */
292 typedef struct _RTS_FLAGS {
293 // The first portion of RTS_FLAGS is invariant.
294 struct GC_FLAGS GcFlags;
295 struct CONCURRENT_FLAGS ConcFlags;
296 struct DEBUG_FLAGS DebugFlags;
297 struct COST_CENTRE_FLAGS CcFlags;
298 struct PROFILING_FLAGS ProfFlags;
299 struct TICKY_FLAGS TickyFlags;
301 #if defined(SMP) || defined(PAR)
302 struct PAR_FLAGS ParFlags;
305 struct GRAN_FLAGS GranFlags;
309 #ifdef COMPILING_RTS_MAIN
310 extern DLLIMPORT RTS_FLAGS RtsFlags;
312 // Hack because the C code generator can't generate '&label'.
313 extern RTS_FLAGS RtsFlags[];
315 extern RTS_FLAGS RtsFlags;
318 /* Routines that operate-on/to-do-with RTS flags: */
320 extern void initRtsFlagsDefaults(void);
321 extern void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
322 extern void setProgName(char *argv[]);
326 * The printf formats are here, so we are less likely to make
327 * overly-long filenames (with disastrous results). No more than 128
331 #define STATS_FILENAME_MAXLEN 128
333 #define GR_FILENAME_FMT "%0.124s.gr"
334 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.%s"
335 #define HP_FILENAME_FMT "%0.124s.hp"
336 #define LIFE_FILENAME_FMT "%0.122s.life"
337 #define PROF_FILENAME_FMT "%0.122s.prof"
338 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
339 #define QP_FILENAME_FMT "%0.124s.qp"
340 #define STAT_FILENAME_FMT "%0.122s.stat"
341 #define TICKY_FILENAME_FMT "%0.121s.ticky"
342 #define TIME_FILENAME_FMT "%0.122s.time"
343 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
345 /* an "int" so as to match normal "argc" */
346 /* Now defined in Stg.h (lib/std/cbits need these too.)
347 extern int prog_argc;
348 extern char **prog_argv;
350 extern int rts_argc; /* ditto */
351 extern char *rts_argv[];
353 #endif /* RTSFLAGS_H */