1 /* -----------------------------------------------------------------------------
2 * $Id: RtsFlags.h,v 1.25 2000/04/19 12:42:48 simonmar Exp $
4 * (c) The GHC Team, 1998-1999
6 * Datatypes that holds the command-line flag settings.
8 * ---------------------------------------------------------------------------*/
13 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
19 #define SUMMARY_GC_STATS 1
20 #define VERBOSE_GC_STATS 2
22 nat maxStkSize; /* in *words* */
23 nat initialStkSize; /* in *words* */
25 nat maxHeapSize; /* in *blocks* */
26 nat minAllocAreaSize; /* in *blocks* */
27 nat minOldGenSize; /* in *blocks* */
28 nat heapSizeSuggestion; /* in *blocks* */
37 rtsBool squeezeUpdFrames;
40 /* Hack: this struct uses bitfields so that we can use a binary arg
42 * Remember to update the corresponding bit of RtsFlags.c if you
43 * change/extend this struct.
46 /* flags to control debugging output in various subsystems */
47 rtsBool scheduler : 1; /* 1 */
48 rtsBool evaluator : 1; /* 2 */
49 rtsBool codegen : 1; /* 4 */
50 rtsBool weak : 1; /* 8 */
51 rtsBool gccafs : 1; /* 16 */
52 rtsBool gc : 1; /* 32 */
53 rtsBool block_alloc : 1; /* 64 */
55 /* flags to control consistency checking (often very expensive!) */
56 rtsBool sanity : 1; /* 128 */
58 rtsBool stable : 1; /* 256 */
59 rtsBool prof : 1; /* 512 */
60 rtsBool gran : 1; /* 1024 */
61 rtsBool par : 1; /* 2048 */
64 #define MAX_DEBUG_OPTION 11
65 #define DEBUG_MASK(n) ((nat)(ldexp(1,n)))
66 #define MAX_DEBUG_MASK ((nat)(ldexp(1,(MAX_DEBUG_OPTION+1))-1))
68 #if defined(PROFILING) || defined(PAR)
69 /* with PROFILING, full cost-centre stuff (also PROFILING_FLAGS);
70 with PAR, just the four fixed cost-centres.
72 struct COST_CENTRE_FLAGS {
73 unsigned int doCostCentres;
74 # define COST_CENTRES_SUMMARY 1
75 # define COST_CENTRES_VERBOSE 2 /* incl. serial time profile */
76 # define COST_CENTRES_ALL 3
77 # define COST_CENTRES_XML 4
79 int ctxtSwitchTicks; /* derived */
80 int profilerTicks; /* derived */
81 int msecsPerTick; /* derived */
86 struct PROFILING_FLAGS {
87 unsigned int doHeapProfile;
89 # define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */
90 # define HEAP_BY_CCS 1
91 # define HEAP_BY_MOD 2
92 # define HEAP_BY_DESCR 4
93 # define HEAP_BY_TYPE 5
94 # define HEAP_BY_TIME 6
96 rtsBool showCCSOnException;
100 # define DESCRchar 'D'
101 # define TYPEchar 'Y'
102 # define TIMEchar 'T'
105 # define NO_HEAP_PROFILING 0
106 # define HEAP_BY_INFOPTR 1
107 # define HEAP_BY_CLOSURE_TYPE 2
108 struct PROFILING_FLAGS {
109 unsigned int doHeapProfile; /* heap profile using symbol table */
111 #endif /* DEBUG || PROFILING */
113 struct CONCURRENT_FLAGS {
114 int ctxtSwitchTime; /* in milliseconds */
118 /* currently the same as GRAN_STATS_FLAGS */
119 struct PAR_STATS_FLAGS {
120 rtsBool Full; /* Full .gr profile (rtsTrue) or only END events? */
121 // rtsBool Suppressed; /* No .gr profile at all */
122 rtsBool Binary; /* Binary profile? (not yet implemented) */
123 rtsBool Sparks; /* Info on sparks in profile? */
124 rtsBool Heap; /* Info on heap allocs in profile? */
125 rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
126 rtsBool Global; /* Global statistics? (printed on shutdown; no log file) */
129 struct PAR_DEBUG_FLAGS {
130 /* flags to control debugging output in various subsystems */
131 rtsBool verbose : 1; /* 1 */
132 rtsBool trace : 1; /* 2 */
133 rtsBool schedule : 1; /* 4 */
134 rtsBool free : 1; /* 8 */
135 rtsBool resume : 1; /* 16 */
136 rtsBool weight : 1; /* 32 */
137 rtsBool fetch : 1; /* 64 */
138 rtsBool fish : 1; /* 128 */
139 rtsBool tables : 1; /* 256 */
140 rtsBool packet : 1; /* 512 */
141 rtsBool pack : 1; /* 1024 */
144 #define MAX_PAR_DEBUG_OPTION 10
145 #define PAR_DEBUG_MASK(n) ((nat)(ldexp(1,n)))
146 #define MAX_PAR_DEBUG_MASK ((nat)(ldexp(1,(MAX_PAR_DEBUG_OPTION+1))-1))
149 struct PAR_STATS_FLAGS ParStats; /* profile and stats output */
150 struct PAR_DEBUG_FLAGS Debug; /* debugging options */
151 rtsBool outputDisabled; /* Disable output for performance purposes */
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;
285 rtsBool showTickyStats;
288 #endif /* TICKY_TICKY */
291 /* Put them together: */
294 struct GC_FLAGS GcFlags;
295 struct DEBUG_FLAGS DebugFlags;
296 struct CONCURRENT_FLAGS ConcFlags;
298 #if defined(PROFILING) || defined(PAR)
299 struct COST_CENTRE_FLAGS CcFlags;
301 #if defined(PROFILING) || defined(DEBUG)
302 struct PROFILING_FLAGS ProfFlags;
304 #if defined(SMP) || defined(PAR)
305 struct PAR_FLAGS ParFlags;
308 struct GRAN_FLAGS GranFlags;
311 struct TICKY_FLAGS TickyFlags;
315 #ifdef COMPILING_RTS_MAIN
316 extern DLLIMPORT struct RTS_FLAGS RtsFlags;
318 extern struct RTS_FLAGS RtsFlags;
321 /* Routines that operate-on/to-do-with RTS flags: */
323 void initRtsFlagsDefaults(void);
324 void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
327 * The printf formats are here, so we are less likely to make
328 * overly-long filenames (with disastrous results). No more than 128
332 #define STATS_FILENAME_MAXLEN 128
334 #define GR_FILENAME_FMT "%0.124s.gr"
335 #define GR_FILENAME_FMT_GUM "%0.120s.%03d.%s"
336 #define HP_FILENAME_FMT "%0.124s.hp"
337 #define LIFE_FILENAME_FMT "%0.122s.life"
338 #define PROF_FILENAME_FMT "%0.122s.prof"
339 #define PROF_FILENAME_FMT_GUM "%0.118s.%03d.prof"
340 #define QP_FILENAME_FMT "%0.124s.qp"
341 #define STAT_FILENAME_FMT "%0.122s.stat"
342 #define TICKY_FILENAME_FMT "%0.121s.ticky"
343 #define TIME_FILENAME_FMT "%0.122s.time"
344 #define TIME_FILENAME_FMT_GUM "%0.118s.%03d.time"
346 /* an "int" so as to match normal "argc" */
347 /* Now defined in Stg.h (lib/std/cbits need these too.)
348 extern int prog_argc;
349 extern char **prog_argv;
351 extern int rts_argc; /* ditto */
352 extern char *rts_argv[];
354 #endif /* RTSFLAGS_H */