[project @ 1999-06-25 09:18:49 by simonmar]
[ghc-hetmet.git] / ghc / rts / RtsFlags.h
1 /* -----------------------------------------------------------------------------
2  * $Id: RtsFlags.h,v 1.14 1999/06/25 09:18:49 simonmar 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;
18 #define NO_GC_STATS      0
19 #define SUMMARY_GC_STATS 1
20 #define VERBOSE_GC_STATS 2
21
22     nat     maxStkSize;         /* in *words* */
23     nat     initialStkSize;     /* in *words* */
24
25     nat     maxHeapSize;        /* in *blocks* */
26     nat     minAllocAreaSize;   /* in *blocks* */
27     nat     minOldGenSize;      /* in *blocks* */
28     nat     heapSizeSuggestion; /* in *blocks* */
29     double  oldGenFactor;
30     double  pcFreeHeap;
31
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     rtsBool squeezeUpdFrames;
40 };
41
42 /* Hack: this struct uses bitfields so that we can use a binary arg
43  * with the -D flag.
44  * Remember to update the corresponding bit of RtsFlags.c if you
45  * change/extend this struct.
46  */
47 struct DEBUG_FLAGS {  
48   /* flags to control debugging output in various subsystems */
49   rtsBool scheduler   : 1; /*  1 */
50   rtsBool evaluator   : 1; /*  2 */
51   rtsBool codegen     : 1; /*  4 */
52   rtsBool weak        : 1; /*  8 */
53   rtsBool gccafs      : 1; /* 16 */
54   rtsBool gc          : 1; /* 32 */
55   rtsBool block_alloc : 1; /* 64 */
56
57   /* flags to control consistency checking (often very expensive!) */
58   rtsBool sanity      : 1; /* 128 */
59
60   rtsBool stable      : 1; /* 256 */
61   rtsBool prof        : 1; /* 512 */
62 };
63
64 #if defined(PROFILING) || defined(PAR)
65     /* with PROFILING, full cost-centre stuff (also PROFILING_FLAGS);
66        with PAR, just the four fixed cost-centres.
67     */
68 struct COST_CENTRE_FLAGS {
69     unsigned int            doCostCentres;
70 # define COST_CENTRES_SUMMARY   1
71 # define COST_CENTRES_VERBOSE   2 /* incl. serial time profile */
72 # define COST_CENTRES_ALL       3
73
74     char    sortBy;
75 # define SORTCC_LABEL   'C'
76 # define SORTCC_TIME    'T'
77 # define SORTCC_ALLOC   'A'
78
79     int     ctxtSwitchTicks; /* derived */
80     int     profilerTicks;   /* derived */
81     int     msecsPerTick;    /* derived */
82 };
83 #endif
84
85 #ifdef PROFILING
86 struct PROFILING_FLAGS {
87     unsigned int        doHeapProfile;
88 # define NO_HEAP_PROFILING      0       /* N.B. Used as indexes into arrays */
89 # define HEAP_BY_CC             1
90 # define HEAP_BY_MOD            2
91 # define HEAP_BY_GRP            3
92 # define HEAP_BY_DESCR          4
93 # define HEAP_BY_TYPE           5
94 # define HEAP_BY_TIME           6
95   
96 # define CCchar    'C'
97 # define MODchar   'M'
98 # define GRPchar   'G'
99 # define DESCRchar 'D'
100 # define TYPEchar  'Y'
101 # define TIMEchar  'T'
102
103     char *ccSelector;
104     char *modSelector;
105     char *grpSelector;
106     char *descrSelector;
107     char *typeSelector;
108     char *kindSelector;
109 };
110 #elif defined(DEBUG)
111 # define NO_HEAP_PROFILING      0
112 # define HEAP_BY_INFOPTR        1
113 # define HEAP_BY_CLOSURE_TYPE   2
114 struct PROFILING_FLAGS {
115     unsigned int      doHeapProfile; /* heap profile using symbol table */
116 };
117 #endif /* DEBUG || PROFILING */
118
119 struct CONCURRENT_FLAGS {
120     int     ctxtSwitchTime; /* in milliseconds */
121     int     maxThreads;
122 };
123
124 #ifdef PAR
125 struct PAR_FLAGS {
126     rtsBool parallelStats;      /* Gather parallel statistics */
127     rtsBool granSimStats;       /* Full .gr profile (rtsTrue) or only END events? */
128     rtsBool granSimStats_Binary;
129
130     rtsBool outputDisabled;     /* Disable output for performance purposes */
131     
132     unsigned int            packBufferSize;
133     unsigned int            maxLocalSparks;
134 };
135
136 #endif /* PAR */
137
138 #ifdef GRAN
139 struct GRAN_FLAGS {
140     rtsBool granSimStats;  /* Full .gr profile (rtsTrue) or only END events? */
141     rtsBool granSimStats_suppressed; /* No .gr profile at all */
142     rtsBool granSimStats_Binary;
143     rtsBool granSimStats_Sparks;
144     rtsBool granSimStats_Heap;
145     rtsBool labelling;
146     unsigned int            packBufferSize;
147     unsigned int            packBufferSize_internal;
148
149     int proc;                      /* number of processors */
150     int max_fishes;                /* max number of spark or thread steals */
151     TIME time_slice;              /* max time slice of one reduction thread */
152
153     /* Communication Cost Variables -- set in main program */
154     unsigned int gran_latency;              /* Latency for single packet */
155     unsigned int gran_additional_latency;   /* Latency for additional packets */
156     unsigned int gran_fetchtime;            
157     unsigned int gran_lunblocktime;         /* Time for local unblock */
158     unsigned int gran_gunblocktime;         /* Time for global unblock */
159     unsigned int gran_mpacktime;            /* Cost of creating a packet */     
160     unsigned int gran_munpacktime;        /* Cost of receiving a packet */    
161     unsigned int gran_mtidytime;                  /* Cost of cleaning up after send */
162
163     unsigned int gran_threadcreatetime;     /* Thread creation costs */
164     unsigned int gran_threadqueuetime;      /* Cost of adding a thread to the running/runnable queue */
165     unsigned int gran_threaddescheduletime; /* Cost of descheduling a thread */
166     unsigned int gran_threadscheduletime;   /* Cost of scheduling a thread */
167     unsigned int gran_threadcontextswitchtime;  /* Cost of context switch  */
168
169     /* Instruction Costs */
170     unsigned int gran_arith_cost;        /* arithmetic instructions (+,i,< etc) */
171     unsigned int gran_branch_cost;       /* branch instructions */ 
172     unsigned int gran_load_cost;         /* load into register */
173     unsigned int gran_store_cost;        /* store into memory */
174     unsigned int gran_float_cost;        /* floating point operations */
175
176     unsigned int gran_heapalloc_cost;    /* heap allocation costs */
177
178     /* Overhead for granularity control mechanisms */
179     /* overhead per elem of spark queue */
180     unsigned int gran_pri_spark_overhead;
181     /* overhead per elem of thread queue */
182     unsigned int gran_pri_sched_overhead;
183
184     /* GrAnSim-Light: This version puts no bound on the number of
185          processors but in exchange doesn't model communication costs
186          (all communication is 0 cost). Mainly intended to show maximal
187          degree of parallelism in the program (*not* to simulate the
188          execution on a real machine). */
189    
190     rtsBool Light;
191
192     rtsBool DoFairSchedule ;        /* fair scheduling alg? default: unfair */
193     rtsBool DoReScheduleOnFetch ;   /* async. communication? */
194     rtsBool DoStealThreadsFirst;    /* prefer threads over sparks when stealing */
195     rtsBool SimplifiedFetch;        /* fast but inaccurate fetch modelling */
196     rtsBool DoAlwaysCreateThreads;  /* eager thread creation */
197     rtsBool DoGUMMFetching;         /* bulk fetching */
198     rtsBool DoThreadMigration;      /* allow to move threads */
199     int      FetchStrategy;          /* what to do when waiting for data */
200     rtsBool PreferSparksOfLocalNodes; /* prefer local over global sparks */
201     rtsBool DoPrioritySparking;     /* sparks sorted by priorities */
202     rtsBool DoPriorityScheduling;   /* threads sorted by priorities */
203     int      SparkPriority;          /* threshold for cut-off mechanism */
204     int      SparkPriority2;
205     rtsBool RandomPriorities;
206     rtsBool InversePriorities;
207     rtsBool IgnorePriorities;
208     int      ThunksToPack;           /* number of thunks in packet + 1 */ 
209     rtsBool RandomSteal;            /* steal spark/thread from random proc */
210     rtsBool NoForward;              /* no forwarding of fetch messages */
211     rtsBool PrintFetchMisses;       /* print number of fetch misses */
212
213     unsigned int            debug;
214     rtsBool event_trace;
215     rtsBool event_trace_all;
216    
217 };
218 #endif /* GRAN */
219
220 #ifdef TICKY_TICKY
221 struct TICKY_FLAGS {
222     rtsBool showTickyStats;
223     FILE   *tickyFile;
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 */