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