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