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