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