ce6ba6d16b28efde943650f854840fbb7a9c90b2
[ghc-hetmet.git] / ghc / rts / RtsFlags.h
1 /* -----------------------------------------------------------------------------
2  * $Id: RtsFlags.h,v 1.4 1999/01/19 15:07:55 simonm Exp $
3  *
4  * Datatypes that holds the command-line flag settings.
5  *
6  * ---------------------------------------------------------------------------*/
7
8 #ifndef RTSFLAGS_H
9 #define RTSFLAGS_H
10
11 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
12
13 struct GC_FLAGS {
14     FILE   *statsFile;
15     nat     giveStats; /* ToDo: replace with enum type? */
16 #define NO_GC_STATS      0
17 #define VERBOSE_GC_STATS 1
18
19     nat     maxStkSize;         /* in *words* */
20     nat     initialStkSize;     /* in *words* */
21
22     nat     maxHeapSize;        /* in *blocks* */
23     nat     minAllocAreaSize;   /* in *blocks* */
24     nat     minOldGenSize;      /* in *blocks* */
25     double  oldGenFactor;
26     double  pcFreeHeap;
27
28     nat     generations;
29
30     rtsBool forceGC; /* force a major GC every <interval> bytes */
31     int     forcingInterval; /* actually, stored as a number of *words* */
32     rtsBool ringBell;
33
34     rtsBool squeezeUpdFrames;
35 };
36
37 /* Hack: this struct uses bitfields so that we can use a binary arg
38  * with the -D flag
39  */
40 struct DEBUG_FLAGS {  
41   /* flags to control debugging output in various subsystems */
42   rtsBool scheduler   : 1; /*  1 */
43   rtsBool evaluator   : 1; /*  2 */
44   rtsBool codegen     : 1; /*  4 */
45   rtsBool weak        : 1; /*  8 */
46   rtsBool gccafs      : 1; /* 16 */
47   rtsBool gc          : 1; /* 32 */
48   rtsBool block_alloc : 1; /* 64 */
49
50   /* flags to control consistency checking (often very expensive!) */
51   rtsBool sanity      : 1; /* 128 */
52 };
53
54 #if defined(PROFILING) || defined(PAR)
55     /* with PROFILING, full cost-centre stuff (also PROFILING_FLAGS);
56        with PAR, just the four fixed cost-centres.
57     */
58 struct COST_CENTRE_FLAGS {
59     unsigned int            doCostCentres;
60 # define COST_CENTRES_SUMMARY   1
61 # define COST_CENTRES_VERBOSE   2 /* incl. serial time profile */
62 # define COST_CENTRES_ALL       3
63
64     char    sortBy;
65 # define SORTCC_LABEL   'C'
66 # define SORTCC_TIME    'T'
67 # define SORTCC_ALLOC   'A'
68
69     int     ctxtSwitchTicks; /* derived */
70     int     profilerTicks;   /* derived */
71     int     msecsPerTick;    /* derived */
72 };
73 #endif
74
75 #ifdef PROFILING
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_CC             1
80 # define HEAP_BY_MOD            2
81 # define HEAP_BY_GRP            3
82 # define HEAP_BY_DESCR          4
83 # define HEAP_BY_TYPE           5
84 # define HEAP_BY_TIME           6
85   
86 # define CCchar    'C'
87 # define MODchar   'M'
88 # define GRPchar   'G'
89 # define DESCRchar 'D'
90 # define TYPEchar  'Y'
91 # define TIMEchar  'T'
92
93     char *ccSelector;
94     char *modSelector;
95     char *grpSelector;
96     char *descrSelector;
97     char *typeSelector;
98     char *kindSelector;
99 };
100 #elif defined(DEBUG)
101 # define NO_HEAP_PROFILING      0
102 # define HEAP_BY_INFOPTR        1
103 # define HEAP_BY_CLOSURE_TYPE   2
104 struct PROFILING_FLAGS {
105     unsigned int      doHeapProfile; /* heap profile using symbol table */
106 };
107 #endif /* DEBUG || PROFILING */
108
109 struct CONCURRENT_FLAGS {
110     int     ctxtSwitchTime; /* in milliseconds */
111     int     maxThreads;
112 };
113
114 #ifdef PAR
115 struct PAR_FLAGS {
116     rtsBool parallelStats;      /* Gather parallel statistics */
117     rtsBool granSimStats;       /* Full .gr profile (rtsTrue) or only END events? */
118     rtsBool granSimStats_Binary;
119
120     rtsBool outputDisabled;     /* Disable output for performance purposes */
121     
122     unsigned int            packBufferSize;
123     unsigned int            maxLocalSparks;
124 };
125
126 #endif /* PAR */
127
128 #ifdef GRAN
129 struct GRAN_FLAGS {
130     rtsBool granSimStats;  /* Full .gr profile (rtsTrue) or only END events? */
131     rtsBool granSimStats_suppressed; /* No .gr profile at all */
132     rtsBool granSimStats_Binary;
133     rtsBool granSimStats_Sparks;
134     rtsBool granSimStats_Heap;
135     rtsBool labelling;
136     unsigned int            packBufferSize;
137     unsigned int            packBufferSize_internal;
138
139     int proc;                      /* number of processors */
140     int max_fishes;                /* max number of spark or thread steals */
141     TIME time_slice;              /* max time slice of one reduction thread */
142
143     /* Communication Cost Variables -- set in main program */
144     unsigned int gran_latency;              /* Latency for single packet */
145     unsigned int gran_additional_latency;   /* Latency for additional packets */
146     unsigned int gran_fetchtime;            
147     unsigned int gran_lunblocktime;         /* Time for local unblock */
148     unsigned int gran_gunblocktime;         /* Time for global unblock */
149     unsigned int gran_mpacktime;            /* Cost of creating a packet */     
150     unsigned int gran_munpacktime;        /* Cost of receiving a packet */    
151     unsigned int gran_mtidytime;                  /* Cost of cleaning up after send */
152
153     unsigned int gran_threadcreatetime;     /* Thread creation costs */
154     unsigned int gran_threadqueuetime;      /* Cost of adding a thread to the running/runnable queue */
155     unsigned int gran_threaddescheduletime; /* Cost of descheduling a thread */
156     unsigned int gran_threadscheduletime;   /* Cost of scheduling a thread */
157     unsigned int gran_threadcontextswitchtime;  /* Cost of context switch  */
158
159     /* Instruction Costs */
160     unsigned int gran_arith_cost;        /* arithmetic instructions (+,i,< etc) */
161     unsigned int gran_branch_cost;       /* branch instructions */ 
162     unsigned int gran_load_cost;         /* load into register */
163     unsigned int gran_store_cost;        /* store into memory */
164     unsigned int gran_float_cost;        /* floating point operations */
165
166     unsigned int gran_heapalloc_cost;    /* heap allocation costs */
167
168     /* Overhead for granularity control mechanisms */
169     /* overhead per elem of spark queue */
170     unsigned int gran_pri_spark_overhead;
171     /* overhead per elem of thread queue */
172     unsigned int gran_pri_sched_overhead;
173
174     /* GrAnSim-Light: This version puts no bound on the number of
175          processors but in exchange doesn't model communication costs
176          (all communication is 0 cost). Mainly intended to show maximal
177          degree of parallelism in the program (*not* to simulate the
178          execution on a real machine). */
179    
180     rtsBool Light;
181
182     rtsBool DoFairSchedule ;        /* fair scheduling alg? default: unfair */
183     rtsBool DoReScheduleOnFetch ;   /* async. communication? */
184     rtsBool DoStealThreadsFirst;    /* prefer threads over sparks when stealing */
185     rtsBool SimplifiedFetch;        /* fast but inaccurate fetch modelling */
186     rtsBool DoAlwaysCreateThreads;  /* eager thread creation */
187     rtsBool DoGUMMFetching;         /* bulk fetching */
188     rtsBool DoThreadMigration;      /* allow to move threads */
189     int      FetchStrategy;          /* what to do when waiting for data */
190     rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
191     rtsBool DoPrioritySparking;     /* sparks sorted by priorities */
192     rtsBool DoPriorityScheduling;   /* threads sorted by priorities */
193     int      SparkPriority;          /* threshold for cut-off mechanism */
194     int      SparkPriority2;
195     rtsBool RandomPriorities;
196     rtsBool InversePriorities;
197     rtsBool IgnorePriorities;
198     int      ThunksToPack;           /* number of thunks in packet + 1 */ 
199     rtsBool RandomSteal;            /* steal spark/thread from random proc */
200     rtsBool NoForward;              /* no forwarding of fetch messages */
201     rtsBool PrintFetchMisses;       /* print number of fetch misses */
202
203     unsigned int            debug;
204     rtsBool event_trace;
205     rtsBool event_trace_all;
206    
207 };
208 #endif /* GRAN */
209
210 #ifdef TICKY_TICKY
211 struct TICKY_FLAGS {
212     rtsBool showTickyStats;
213     FILE   *tickyFile;
214
215     /* see also: doUpdEntryCounts in AllFlags */
216 };
217 #endif /* TICKY_TICKY */
218
219
220 /* Put them together: */
221
222 struct RTS_FLAGS {
223     struct GC_FLAGS     GcFlags;
224     struct DEBUG_FLAGS  DebugFlags; /* unused at present */
225     struct CONCURRENT_FLAGS ConcFlags;
226
227 #if defined(PROFILING) || defined(PAR)
228     struct COST_CENTRE_FLAGS CcFlags;
229 #endif
230 #if defined(PROFILING) || defined(DEBUG)
231     struct PROFILING_FLAGS ProfFlags;
232 #endif
233 #ifdef PAR
234     struct PAR_FLAGS    ParFlags;
235 #endif
236 #ifdef GRAN
237     struct GRAN_FLAGS   GranFlags;
238 #endif
239 #ifdef TICKY_TICKY
240     struct TICKY_FLAGS  TickyFlags;
241 #endif
242 };
243
244 extern struct RTS_FLAGS RtsFlags;
245
246 /* Routines that operate-on/to-do-with RTS flags: */
247
248 void initRtsFlagsDefaults(void);
249 void setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[]);
250
251 /*
252  * The printf formats are here, so we are less likely to make
253  * overly-long filenames (with disastrous results).  No more than 128
254  * chars, please!  
255  */
256
257 #define STATS_FILENAME_MAXLEN   128
258
259 #define GR_FILENAME_FMT         "%0.124s.gr"
260 #define GR_FILENAME_FMT_GUM     "%0.120s.%03d.%s"
261 #define HP_FILENAME_FMT         "%0.124s.hp"
262 #define LIFE_FILENAME_FMT       "%0.122s.life"
263 #define PROF_FILENAME_FMT       "%0.122s.prof"
264 #define PROF_FILENAME_FMT_GUM   "%0.118s.%03d.prof"
265 #define QP_FILENAME_FMT         "%0.124s.qp"
266 #define STAT_FILENAME_FMT       "%0.122s.stat"
267 #define TICKY_FILENAME_FMT      "%0.121s.ticky"
268 #define TIME_FILENAME_FMT       "%0.122s.time"
269 #define TIME_FILENAME_FMT_GUM   "%0.118s.%03d.time"
270
271 extern int     prog_argc; /* an "int" so as to match normal "argc" */
272 extern char  **prog_argv;
273 extern int     rts_argc;  /* ditto */
274 extern char   *rts_argv[];
275
276 #endif  /* RTSFLAGS_H */