RtsFlags.h 11.8 KB
Newer Older
1
/* -----------------------------------------------------------------------------
2
 * $Id: RtsFlags.h,v 1.21 2000/02/17 17:19:42 simonmar Exp $
3
4
 *
 * (c) The GHC Team, 1998-1999
5
6
7
8
9
 *
 * Datatypes that holds the command-line flag settings.
 *
 * ---------------------------------------------------------------------------*/

10
11
12
#ifndef RTSFLAGS_H
#define RTSFLAGS_H

13
/* For defaults, see the @initRtsFlagsDefaults@ routine. */
14
15
16

struct GC_FLAGS {
    FILE   *statsFile;
17
    nat	    giveStats;
18
#define NO_GC_STATS	 0
19
20
#define SUMMARY_GC_STATS 1
#define VERBOSE_GC_STATS 2
21

22
23
24
25
26
    nat     maxStkSize;         /* in *words* */
    nat     initialStkSize;     /* in *words* */

    nat	    maxHeapSize;        /* in *blocks* */
    nat     minAllocAreaSize;   /* in *blocks* */
27
    nat     minOldGenSize;      /* in *blocks* */
28
    nat     heapSizeSuggestion; /* in *blocks* */
29
    double  oldGenFactor;
30
31
    double  pcFreeHeap;

32
    nat     generations;
33
    nat     steps;
34

35
    rtsBool forceGC; /* force a major GC every <interval> bytes */
36
    int	    forcingInterval; /* actually, stored as a number of *words* */
37
    rtsBool ringBell;
38

39
40
41
    rtsBool squeezeUpdFrames;
};

42
/* Hack: this struct uses bitfields so that we can use a binary arg
43
44
45
 * with the -D flag.
 * Remember to update the corresponding bit of RtsFlags.c if you
 * change/extend this struct.
46
47
48
49
50
51
52
53
54
55
56
57
58
 */
struct DEBUG_FLAGS {  
  /* flags to control debugging output in various subsystems */
  rtsBool scheduler   : 1; /*  1 */
  rtsBool evaluator   : 1; /*  2 */
  rtsBool codegen     : 1; /*  4 */
  rtsBool weak        : 1; /*  8 */
  rtsBool gccafs      : 1; /* 16 */
  rtsBool gc          : 1; /* 32 */
  rtsBool block_alloc : 1; /* 64 */

  /* flags to control consistency checking (often very expensive!) */
  rtsBool sanity      : 1; /* 128 */
59
60

  rtsBool stable      : 1; /* 256 */
61
  rtsBool prof        : 1; /* 512 */
62
63
  rtsBool gran        : 1; /* 1024 */
  rtsBool par         : 1; /* 2048 */
64
65
66
67
68
69
70
};

#if defined(PROFILING) || defined(PAR)
    /* with PROFILING, full cost-centre stuff (also PROFILING_FLAGS);
       with PAR, just the four fixed cost-centres.
    */
struct COST_CENTRE_FLAGS {
71
    unsigned int	    doCostCentres;
72
73
74
# define COST_CENTRES_SUMMARY	1
# define COST_CENTRES_VERBOSE	2 /* incl. serial time profile */
# define COST_CENTRES_ALL	3
75
# define COST_CENTRES_XML       4
76

77
78
79
    int	    ctxtSwitchTicks; /* derived */
    int	    profilerTicks;   /* derived */
    int	    msecsPerTick;    /* derived */
80
81
82
83
84
};
#endif

#ifdef PROFILING
struct PROFILING_FLAGS {
85
    unsigned int	doHeapProfile;
86

87
# define NO_HEAP_PROFILING	0	/* N.B. Used as indexes into arrays */
88
# define HEAP_BY_CCS		1
89
90
91
92
93
# define HEAP_BY_MOD		2
# define HEAP_BY_GRP		3
# define HEAP_BY_DESCR		4
# define HEAP_BY_TYPE		5
# define HEAP_BY_TIME		6
94
95

    rtsBool		showCCSOnException;
96
97
98
99
100
101
102
  
# define CCchar    'C'
# define MODchar   'M'
# define GRPchar   'G'
# define DESCRchar 'D'
# define TYPEchar  'Y'
# define TIMEchar  'T'
103
104
105
106
107
108
109

    char *ccSelector;
    char *modSelector;
    char *grpSelector;
    char *descrSelector;
    char *typeSelector;
    char *kindSelector;
110
};
111
112
113
114
115
116
117
118
#elif defined(DEBUG)
# define NO_HEAP_PROFILING	0
# define HEAP_BY_INFOPTR        1
# define HEAP_BY_CLOSURE_TYPE   2
struct PROFILING_FLAGS {
    unsigned int      doHeapProfile; /* heap profile using symbol table */
};
#endif /* DEBUG || PROFILING */
119
120

struct CONCURRENT_FLAGS {
121
  int ctxtSwitchTime; /* in milliseconds */
122
123
124
};

#ifdef PAR
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* currently the same as GRAN_STATS_FLAGS */
struct PAR_STATS_FLAGS {
  rtsBool Full;       /* Full .gr profile (rtsTrue) or only END events? */
  // rtsBool Suppressed; /* No .gr profile at all */
  rtsBool Binary;     /* Binary profile? (not yet implemented) */
  rtsBool Sparks;     /* Info on sparks in profile? */
  rtsBool Heap;       /* Info on heap allocs in profile? */ 
  rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
  rtsBool Global;     /* Global statistics? (printed on shutdown; no log file) */
};

struct PAR_DEBUG_FLAGS {  
  /* flags to control debugging output in various subsystems */
  rtsBool verbose    : 1; /*    1 */
  rtsBool trace      : 1; /*    2 */
  rtsBool schedule   : 1; /*    4 */
  rtsBool free       : 1; /*    8 */
  rtsBool resume     : 1; /*   16 */
  rtsBool weight     : 1; /*   32 */
  rtsBool fetch      : 1; /*   64 */
  rtsBool ack        : 1; /*  128 */
  rtsBool fish       : 1; /*  256 */
  rtsBool forward    : 1; /*  512 */
  rtsBool pack       : 1; /* 1024 */
};

#define MAX_PAR_DEBUG_OPTION     10
#define PAR_DEBUG_MASK(n)        ((nat)(ldexp(1,n)))
#define MAX_PAR_DEBUG_MASK       ((nat)(ldexp(1,(MAX_PAR_DEBUG_OPTION+1))-1))

155
struct PAR_FLAGS {
156
157
158
159
160
161
162
163
164
  struct PAR_STATS_FLAGS ParStats;  /* profile and stats output */
  struct PAR_DEBUG_FLAGS Debug;         /* debugging options */
  rtsBool  outputDisabled;	  /* Disable output for performance purposes */
  nat      packBufferSize;
  nat	   maxLocalSparks;        /* spark pool size */
  nat      maxThreads;            /* thread pool size */
  nat      maxFishes;             /* max number of active fishes */
  rtsTime  fishDelay;             /* delay before sending a new fish */
  long   wait;
165
166
167
};
#endif /* PAR */

168
169
170
171
172
#ifdef SMP
struct PAR_FLAGS {
  nat            nNodes;         /* number of threads to run simultaneously */
  unsigned int	 maxLocalSparks;
};
173
#endif /* SMP */
174

175
#ifdef GRAN
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
struct GRAN_STATS_FLAGS {
  rtsBool Full;       /* Full .gr profile (rtsTrue) or only END events? */
  rtsBool Suppressed; /* No .gr profile at all */
  rtsBool Binary;     /* Binary profile? (not yet implemented) */
  rtsBool Sparks;     /* Info on sparks in profile? */
  rtsBool Heap;       /* Info on heap allocs in profile? */ 
  rtsBool NewLogfile; /* Use new log-file format? (not yet implemented) */
  rtsBool Global;     /* Global statistics? (printed on shutdown; no log file) */
};

struct GRAN_COST_FLAGS {
  /* Communication Cost Variables -- set in main program */
  nat latency;              /* Latency for single packet */
  nat additional_latency;   /* Latency for additional packets */
  nat fetchtime;            
  nat lunblocktime;         /* Time for local unblock */
  nat gunblocktime;         /* Time for global unblock */
  nat mpacktime;            /* Cost of creating a packet */     
  nat munpacktime;	    /* Cost of receiving a packet */    
  nat mtidytime;	    /* Cost of cleaning up after send */
  
  nat threadcreatetime;     /* Thread creation costs */
  nat threadqueuetime;      /* Cost of adding a thread to the running/runnable queue */
  nat threaddescheduletime; /* Cost of descheduling a thread */
  nat threadscheduletime;   /* Cost of scheduling a thread */
  nat threadcontextswitchtime;  /* Cost of context switch  */
  
  /* Instruction Costs */
  nat arith_cost;        /* arithmetic instructions (+,i,< etc) */
  nat branch_cost;       /* branch instructions */ 
  nat load_cost;         /* load into register */
  nat store_cost;        /* store into memory */
  nat float_cost;        /* floating point operations */
  
  nat heapalloc_cost;    /* heap allocation costs */
  
  /* Overhead for granularity control mechanisms */
  /* overhead per elem of spark queue */
  nat pri_spark_overhead;
  /* overhead per elem of thread queue */
  nat pri_sched_overhead;
};

struct GRAN_DEBUG_FLAGS {  
  /* flags to control debugging output in various subsystems */
  rtsBool event_trace    : 1; /*    1 */
  rtsBool event_stats    : 1; /*    2 */
  rtsBool bq             : 1; /*    4 */
  rtsBool pack           : 1; /*    8 */
  rtsBool checkSparkQ    : 1; /*   16 */
  rtsBool thunkStealing  : 1; /*   32 */
  rtsBool randomSteal  	 : 1; /*   64 */
  rtsBool findWork     	 : 1; /*  128 */
  rtsBool unused     	 : 1; /*  256 */
  rtsBool pri     	 : 1; /*  512 */
  rtsBool checkLight   	 : 1; /* 1024 */
  rtsBool sortedQ      	 : 1; /* 2048 */
  rtsBool blockOnFetch   : 1; /* 4096 */
  rtsBool packBuffer     : 1; /* 8192 */
  rtsBool blockOnFetch_sanity : 1; /*  16384 */
};

#define MAX_GRAN_DEBUG_OPTION     14
#define GRAN_DEBUG_MASK(n)        ((nat)(ldexp(1,n)))
#define MAX_GRAN_DEBUG_MASK       ((nat)(ldexp(1,(MAX_GRAN_DEBUG_OPTION+1))-1))

242
struct GRAN_FLAGS {
243
244
245
246
247
248
249
250
251
252
253
254
  struct GRAN_STATS_FLAGS GranSimStats;  /* profile and stats output */
  struct GRAN_COST_FLAGS Costs;          /* cost metric for simulation */
  struct GRAN_DEBUG_FLAGS Debug;         /* debugging options */

  // rtsBool labelling;
  nat  packBufferSize;
  nat  packBufferSize_internal;

  PEs proc;                     /* number of processors */
  rtsBool Fishing;              /* Simulate GUM style fishing mechanism? */
  nat maxFishes;                /* max number of spark or thread steals */
  rtsTime time_slice;           /* max time slice of one reduction thread */
255
256
257
258
259
260
261
262
263
264

    /* GrAnSim-Light: This version puts no bound on the number of
         processors but in exchange doesn't model communication costs
         (all communication is 0 cost). Mainly intended to show maximal
         degree of parallelism in the program (*not* to simulate the
         execution on a real machine). */
   
    rtsBool Light;

    rtsBool DoFairSchedule ;        /* fair scheduling alg? default: unfair */
265
    rtsBool DoAsyncFetch;           /* async. communication? */
266
    rtsBool DoStealThreadsFirst;    /* prefer threads over sparks when stealing */
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
  rtsBool DoAlwaysCreateThreads;  /* eager thread creation */
  rtsBool DoBulkFetching;         /* bulk fetching */
  rtsBool DoThreadMigration;      /* allow to move threads */
  nat     FetchStrategy;         /* what to do when waiting for data */
  rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
  rtsBool DoPrioritySparking;     /* sparks sorted by priorities */
  rtsBool DoPriorityScheduling;   /* threads sorted by priorities */
  nat     SparkPriority;         /* threshold for cut-off mechanism */
  nat     SparkPriority2;
  rtsBool RandomPriorities;
  rtsBool InversePriorities;
  rtsBool IgnorePriorities;
  nat     ThunksToPack;      /* number of thunks in packet + 1 */ 
  rtsBool RandomSteal;        /* steal spark/thread from random proc */
  rtsBool NoForward;        /* no forwarding of fetch messages */

  // unsigned int	    debug;
  //  rtsBool event_trace;
  //  rtsBool event_trace_all;
286
287
288
289
290
291
292
293
294
295
};
#endif /* GRAN */

#ifdef TICKY_TICKY
struct TICKY_FLAGS {
    rtsBool showTickyStats;
    FILE   *tickyFile;
};
#endif /* TICKY_TICKY */

296
297
298

/* Put them together: */

299
300
struct RTS_FLAGS {
    struct GC_FLAGS	GcFlags;
sof's avatar
sof committed
301
    struct DEBUG_FLAGS	DebugFlags;
302
    struct CONCURRENT_FLAGS ConcFlags;
303
304
305
306

#if defined(PROFILING) || defined(PAR)
    struct COST_CENTRE_FLAGS CcFlags;
#endif
307
#if defined(PROFILING) || defined(DEBUG)
308
309
    struct PROFILING_FLAGS ProfFlags;
#endif
310
#if defined(SMP) || defined(PAR)
311
312
313
314
315
316
317
318
319
320
    struct PAR_FLAGS	ParFlags;
#endif
#ifdef GRAN
    struct GRAN_FLAGS	GranFlags;
#endif
#ifdef TICKY_TICKY
    struct TICKY_FLAGS	TickyFlags;
#endif
};

sof's avatar
sof committed
321
322
323
#ifdef COMPILING_RTS_MAIN
extern DLLIMPORT struct RTS_FLAGS RtsFlags;
#else
324
extern struct RTS_FLAGS RtsFlags;
sof's avatar
sof committed
325
#endif
326

327
/* Routines that operate-on/to-do-with RTS flags: */
328

329
330
void initRtsFlagsDefaults(void);
void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
331

332
333
334
335
336
/*
 * The printf formats are here, so we are less likely to make
 * overly-long filenames (with disastrous results).  No more than 128
 * chars, please!  
 */
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351

#define STATS_FILENAME_MAXLEN	128

#define GR_FILENAME_FMT		"%0.124s.gr"
#define GR_FILENAME_FMT_GUM	"%0.120s.%03d.%s"
#define HP_FILENAME_FMT		"%0.124s.hp"
#define LIFE_FILENAME_FMT	"%0.122s.life"
#define PROF_FILENAME_FMT	"%0.122s.prof"
#define PROF_FILENAME_FMT_GUM	"%0.118s.%03d.prof"
#define QP_FILENAME_FMT		"%0.124s.qp"
#define STAT_FILENAME_FMT	"%0.122s.stat"
#define TICKY_FILENAME_FMT	"%0.121s.ticky"
#define TIME_FILENAME_FMT	"%0.122s.time"
#define TIME_FILENAME_FMT_GUM	"%0.118s.%03d.time"

sof's avatar
sof committed
352
353
354
/* an "int" so as to match normal "argc" */
/* Now defined in Stg.h (lib/std/cbits need these too.)
extern int     prog_argc;
355
extern char  **prog_argv;
sof's avatar
sof committed
356
*/
357
358
359
extern int     rts_argc;  /* ditto */
extern char   *rts_argv[];

360
#endif	/* RTSFLAGS_H */