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