1 /* -----------------------------------------------------------------------------
2 * $Id: RtsFlags.h,v 1.46 2004/08/13 13:09:29 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
65 struct COST_CENTRE_FLAGS {
66 unsigned int doCostCentres;
67 # define COST_CENTRES_SUMMARY 1
68 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
69 # define COST_CENTRES_ALL 3
70 # define COST_CENTRES_XML 4
72 int profilerTicks; /* derived */
73 int msecsPerTick; /* derived */
76 struct PROFILING_FLAGS {
77 unsigned int doHeapProfile;
78 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
79 # define HEAP_BY_CCS 1
80 # define HEAP_BY_MOD 2
81 # define HEAP_BY_DESCR 4
82 # define HEAP_BY_TYPE 5
83 # define HEAP_BY_RETAINER 6
84 # define HEAP_BY_LDV 7
86 # define HEAP_BY_INFOPTR 1 /* DEBUG only */
87 # define HEAP_BY_CLOSURE_TYPE 2 /* DEBUG only */
89 nat profileInterval; /* delta between samples (in ms) */
90 nat profileIntervalTicks; /* delta between samples (in 'ticks') */
94 rtsBool showCCSOnException;
96 nat maxRetainerSetSize;
103 char* retainerSelector;
108 struct CONCURRENT_FLAGS {
109 int ctxtSwitchTime; /* in milliseconds */
110 int ctxtSwitchTicks; /* derived */
114 /* currently the same as GRAN_STATS_FLAGS */
115 struct PAR_STATS_FLAGS {
116 rtsBool Full; /* Full .gr profile (rtsTrue) or only END events? */
117 rtsBool Suppressed; /* No .gr profile at all */
118 rtsBool Binary; /* Binary profile? (not yet implemented) */
119 rtsBool Sparks; /* Info on sparks in profile? */
120 rtsBool Heap; /* Info on heap allocs in profile? */
121 rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
122 rtsBool Global; /* Global statistics? (printed on shutdown; no log file) */
125 struct PAR_DEBUG_FLAGS {
126 /* flags to control debugging output in various subsystems */
127 rtsBool verbose : 1; /* 1 */
128 rtsBool bq : 1; /* 2 */
129 rtsBool schedule : 1; /* 4 */
130 rtsBool free : 1; /* 8 */
131 rtsBool resume : 1; /* 16 */
132 rtsBool weight : 1; /* 32 */
133 rtsBool fetch : 1; /* 64 */
134 rtsBool fish : 1; /* 128 */
135 rtsBool tables : 1; /* 256 */
136 rtsBool packet : 1; /* 512 */
137 rtsBool pack : 1; /* 1024 */
138 rtsBool paranoia : 1; /* 2048 */
141 #define MAX_PAR_DEBUG_OPTION 11
142 #define PAR_DEBUG_MASK(n) ((nat)(ldexp(1,n)))
143 #define MAX_PAR_DEBUG_MASK ((nat)(ldexp(1,(MAX_PAR_DEBUG_OPTION+1))-1))
146 struct PAR_STATS_FLAGS ParStats; /* profile and stats output */
147 struct PAR_DEBUG_FLAGS Debug; /* debugging options */
148 rtsBool outputDisabled; /* Disable output for performance purposes */
149 rtsBool doFairScheduling; /* Fair-ish scheduling (round robin; no time-slices) */
151 nat thunksToPack; /* number of thunks in packet + 1 */
152 nat globalising; /* globalisation scheme */
153 nat maxLocalSparks; /* spark pool size */
154 nat maxThreads; /* thread pool size */
155 nat maxFishes; /* max number of active fishes */
156 rtsTime fishDelay; /* delay before sending a new fish */
163 nat nNodes; /* number of threads to run simultaneously */
164 unsigned int maxLocalSparks;
169 struct GRAN_STATS_FLAGS {
170 rtsBool Full; /* Full .gr profile (rtsTrue) or only END events? */
171 rtsBool Suppressed; /* No .gr profile at all */
172 rtsBool Binary; /* Binary profile? (not yet implemented) */
173 rtsBool Sparks; /* Info on sparks in profile? */
174 rtsBool Heap; /* Info on heap allocs in profile? */
175 rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
176 rtsBool Global; /* Global statistics? (printed on shutdown; no log file) */
179 struct GRAN_COST_FLAGS {
180 /* Communication Cost Variables -- set in main program */
181 nat latency; /* Latency for single packet */
182 nat additional_latency; /* Latency for additional packets */
184 nat lunblocktime; /* Time for local unblock */
185 nat gunblocktime; /* Time for global unblock */
186 nat mpacktime; /* Cost of creating a packet */
187 nat munpacktime; /* Cost of receiving a packet */
188 nat mtidytime; /* Cost of cleaning up after send */
190 nat threadcreatetime; /* Thread creation costs */
191 nat threadqueuetime; /* Cost of adding a thread to the running/runnable queue */
192 nat threaddescheduletime; /* Cost of descheduling a thread */
193 nat threadscheduletime; /* Cost of scheduling a thread */
194 nat threadcontextswitchtime; /* Cost of context switch */
196 /* Instruction Costs */
197 nat arith_cost; /* arithmetic instructions (+,i,< etc) */
198 nat branch_cost; /* branch instructions */
199 nat load_cost; /* load into register */
200 nat store_cost; /* store into memory */
201 nat float_cost; /* floating point operations */
203 nat heapalloc_cost; /* heap allocation costs */
205 /* Overhead for granularity control mechanisms */
206 /* overhead per elem of spark queue */
207 nat pri_spark_overhead;
208 /* overhead per elem of thread queue */
209 nat pri_sched_overhead;
212 struct GRAN_DEBUG_FLAGS {
213 /* flags to control debugging output in various subsystems */
214 rtsBool event_trace : 1; /* 1 */
215 rtsBool event_stats : 1; /* 2 */
216 rtsBool bq : 1; /* 4 */
217 rtsBool pack : 1; /* 8 */
218 rtsBool checkSparkQ : 1; /* 16 */
219 rtsBool thunkStealing : 1; /* 32 */
220 rtsBool randomSteal : 1; /* 64 */
221 rtsBool findWork : 1; /* 128 */
222 rtsBool unused : 1; /* 256 */
223 rtsBool pri : 1; /* 512 */
224 rtsBool checkLight : 1; /* 1024 */
225 rtsBool sortedQ : 1; /* 2048 */
226 rtsBool blockOnFetch : 1; /* 4096 */
227 rtsBool packBuffer : 1; /* 8192 */
228 rtsBool blockOnFetch_sanity : 1; /* 16384 */
231 #define MAX_GRAN_DEBUG_OPTION 14
232 #define GRAN_DEBUG_MASK(n) ((nat)(ldexp(1,n)))
233 #define MAX_GRAN_DEBUG_MASK ((nat)(ldexp(1,(MAX_GRAN_DEBUG_OPTION+1))-1))
236 struct GRAN_STATS_FLAGS GranSimStats; /* profile and stats output */
237 struct GRAN_COST_FLAGS Costs; /* cost metric for simulation */
238 struct GRAN_DEBUG_FLAGS Debug; /* debugging options */
240 nat maxThreads; // ToDo: share with SMP and GUM
241 // rtsBool labelling;
243 nat packBufferSize_internal;
245 PEs proc; /* number of processors */
246 rtsBool Fishing; /* Simulate GUM style fishing mechanism? */
247 nat maxFishes; /* max number of spark or thread steals */
248 rtsTime time_slice; /* max time slice of one reduction thread */
250 /* GrAnSim-Light: This version puts no bound on the number of
251 processors but in exchange doesn't model communication costs
252 (all communication is 0 cost). Mainly intended to show maximal
253 degree of parallelism in the program (*not* to simulate the
254 execution on a real machine). */
258 rtsBool DoFairSchedule ; /* fair scheduling alg? default: unfair */
259 rtsBool DoAsyncFetch; /* async. communication? */
260 rtsBool DoStealThreadsFirst; /* prefer threads over sparks when stealing */
261 rtsBool DoAlwaysCreateThreads; /* eager thread creation */
262 rtsBool DoBulkFetching; /* bulk fetching */
263 rtsBool DoThreadMigration; /* allow to move threads */
264 nat FetchStrategy; /* what to do when waiting for data */
265 rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
266 rtsBool DoPrioritySparking; /* sparks sorted by priorities */
267 rtsBool DoPriorityScheduling; /* threads sorted by priorities */
268 nat SparkPriority; /* threshold for cut-off mechanism */
270 rtsBool RandomPriorities;
271 rtsBool InversePriorities;
272 rtsBool IgnorePriorities;
273 nat ThunksToPack; /* number of thunks in packet + 1 */
274 rtsBool RandomSteal; /* steal spark/thread from random proc */
275 rtsBool NoForward; /* no forwarding of fetch messages */
277 // unsigned int debug;
278 // rtsBool event_trace;
279 // rtsBool event_trace_all;
284 rtsBool showTickyStats;
289 /* Put them together: */
291 typedef struct _RTS_FLAGS {
292 // The first portion of RTS_FLAGS is invariant.
293 struct GC_FLAGS GcFlags;
294 struct CONCURRENT_FLAGS ConcFlags;
295 struct DEBUG_FLAGS DebugFlags;
296 struct COST_CENTRE_FLAGS CcFlags;
297 struct PROFILING_FLAGS ProfFlags;
298 struct TICKY_FLAGS TickyFlags;
300 #if defined(SMP) || defined(PAR)
301 struct PAR_FLAGS ParFlags;
304 struct GRAN_FLAGS GranFlags;
308 #ifdef COMPILING_RTS_MAIN
309 extern DLLIMPORT RTS_FLAGS RtsFlags;
311 // Hack because the C code generator can't generate '&label'.
312 extern RTS_FLAGS RtsFlags[];
314 extern RTS_FLAGS RtsFlags;
317 /* Routines that operate-on/to-do-with RTS flags: */
319 void initRtsFlagsDefaults(void);
320 void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
323 * The printf formats are here, so we are less likely to make
324 * overly-long filenames (with disastrous results). No more than 128
328 #define STATS_FILENAME_MAXLEN 128
330 #define GR_FILENAME_FMT "%0.124s.gr"
331 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.%s"
332 #define HP_FILENAME_FMT "%0.124s.hp"
333 #define LIFE_FILENAME_FMT "%0.122s.life"
334 #define PROF_FILENAME_FMT "%0.122s.prof"
335 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
336 #define QP_FILENAME_FMT "%0.124s.qp"
337 #define STAT_FILENAME_FMT "%0.122s.stat"
338 #define TICKY_FILENAME_FMT "%0.121s.ticky"
339 #define TIME_FILENAME_FMT "%0.122s.time"
340 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
342 /* an "int" so as to match normal "argc" */
343 /* Now defined in Stg.h (lib/std/cbits need these too.)
344 extern int prog_argc;
345 extern char **prog_argv;
347 extern int rts_argc; /* ditto */
348 extern char *rts_argv[];
350 #endif /* RTSFLAGS_H */