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