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