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