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