X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FRtsFlags.c;h=c86690f3f01702d158e890bc52ae2349bbbf7cb8;hb=fd23905bf703daa9df3a0d6858d32aa737b0516b;hp=19d58cc5cd1bf126eb79609ab1b4ed1a162608cd;hpb=462bf5bab1e61d48cc3d0efc81decead27ea11bd;p=ghc-hetmet.git diff --git a/ghc/rts/RtsFlags.c b/ghc/rts/RtsFlags.c index 19d58cc..c86690f 100644 --- a/ghc/rts/RtsFlags.c +++ b/ghc/rts/RtsFlags.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: RtsFlags.c,v 1.26 2000/02/17 17:19:42 simonmar Exp $ + * $Id: RtsFlags.c,v 1.31 2000/08/03 11:28:35 simonmar Exp $ * * (c) The AQUA Project, Glasgow University, 1994-1997 * (c) The GHC Team, 1998-1999 @@ -25,18 +25,15 @@ #include "RtsFlags.h" #include "RtsUtils.h" #include "BlockAlloc.h" -#include "ProfRts.h" +#include "Itimer.h" /* CS_MIN_MILLISECS */ +#include "Profiling.h" #if defined(PROFILING) #include "Itimer.h" #endif -#if HAVE_STDLIB_H -#include -#endif - -#ifdef HAVE_STRING_H -#include +#ifdef HAVE_CTYPE_H +#include #endif extern struct RTS_FLAGS RtsFlags; @@ -58,6 +55,36 @@ char *rts_argv[MAX_RTS_ARGS]; #define RTS 1 #define PGM 0 +char *debug_opts_strs[] = { + "DEBUG (-D1): scheduler\n", + "DEBUG (-D2): evaluator\n", + "DEBUG (-D4): codegen\n", + "DEBUG (-D8): weak\n", + "DEBUG (-D16): gccafs\n", + "DEBUG (-D32): gc\n", + "DEBUG (-D64): block\n", + "DEBUG (-D128): sanity\n", + "DEBUG (-D256): stable\n", + "DEBUG (-D512): prof\n", + "DEBUG (-D1024): gran\n", + "DEBUG (-D2048): par\n" +}; + +char *debug_opts_prefix[] = { + "_-", /* scheduler */ + "_.", /* evaluator */ + "_,", /* codegen */ + "_;", /* weak */ + "_~", /* gccafs */ + "_@", /* gc */ + "_#", /* block */ + "_&", /* sanity */ + "_:", /* stable */ + "_!", /* prof */ + "_=", /* gran */ + "_=" /* par */ +}; + #if defined(GRAN) char *gran_debug_opts_strs[] = { @@ -110,17 +137,19 @@ char *par_debug_opts_strs[] = { "DEBUG (-qDs, -qD4): schedule; scheduling of parallel threads.\n", "DEBUG (-qDe, -qD8): free; free messages.\n", "DEBUG (-qDr, -qD16): resume; resume messages.\n", - "DEBUG (-qDw, -qD32): weight; print weights for GC.\n", + "DEBUG (-qDw, -qD32): weight; print weights and distrib GC stuff.\n", "DEBUG (-qDF, -qD64): fetch; fetch messages.\n", - "DEBUG (-qDa, -qD128): ack; ack messages.\n", - "DEBUG (-qDf, -qD256): fish; fish messages.\n", - "DEBUG (-qDo, -qD512): forward; forwarding messages to other PEs.\n", + // "DEBUG (-qDa, -qD128): ack; ack messages.\n", + "DEBUG (-qDf, -qD128): fish; fish messages.\n", + //"DEBUG (-qDo, -qD512): forward; forwarding messages to other PEs.\n", + "DEBUG (-qDl, -qD256): tables; print internal LAGA etc tables.\n", + "DEBUG (-qDo, -qD512): packet; packets and graph structures when packing.\n", "DEBUG (-qDp, -qD1024): pack; packing and unpacking graphs.\n" }; /* one character codes for the available debug options */ char par_debug_opts_flags[] = { - 'v', 't', 's', 'e', 'r', 'w', 'F', 'a', 'f', 'o', 'p' + 'v', 't', 's', 'e', 'r', 'w', 'F', 'f', 'l', 'o', 'p' }; /* prefix strings printed with the debug messages of the corresponding type */ @@ -132,9 +161,10 @@ char *par_debug_opts_prefix[] = { "[]", /* resume */ ";;", /* weight */ "%%", /* fetch */ - ",,", /* ack */ + //",,", /* ack */ "$$", /* fish */ - "", /* forward */ + "", /* tables */ + "**", /* packet */ "**" /* pack */ }; @@ -167,6 +197,10 @@ static void process_par_option(int arg, int *rts_argc, char *rts_argv[], rtsBool static void set_par_debug_options(nat n); static void help_par_debug_options(nat n); #endif +#if defined(DEBUG) +static void set_debug_options(nat n); +static void help_debug_options(nat n); +#endif //@node Command-line option parsing routines, GranSim specific options, Static function decls //@subsection Command-line option parsing routines @@ -192,10 +226,6 @@ void initRtsFlagsDefaults(void) RtsFlags.GcFlags.generations = 2; RtsFlags.GcFlags.steps = 2; - RtsFlags.GcFlags.forceGC = rtsFalse; - RtsFlags.GcFlags.forcingInterval = 5000000; /* 5MB (or words?) */ - RtsFlags.GcFlags.ringBell = rtsFalse; - RtsFlags.GcFlags.squeezeUpdFrames = rtsTrue; #if defined(PROFILING) || defined(PAR) @@ -205,13 +235,6 @@ void initRtsFlagsDefaults(void) #ifdef PROFILING RtsFlags.ProfFlags.doHeapProfile = rtsFalse; RtsFlags.ProfFlags.showCCSOnException = rtsFalse; - - RtsFlags.ProfFlags.ccSelector = NULL; - RtsFlags.ProfFlags.modSelector = NULL; - RtsFlags.ProfFlags.grpSelector = NULL; - RtsFlags.ProfFlags.descrSelector = NULL; - RtsFlags.ProfFlags.typeSelector = NULL; - RtsFlags.ProfFlags.kindSelector = NULL; #elif defined(DEBUG) RtsFlags.ProfFlags.doHeapProfile = rtsFalse; #endif @@ -244,11 +267,10 @@ void initRtsFlagsDefaults(void) #if defined(GRAN) /* ToDo: check defaults for GranSim and GUM */ - RtsFlags.ConcFlags.ctxtSwitchTime = CS_MIN_MILLISECS; /* In milliseconds */ - RtsFlags.ConcFlags.maxThreads = 65536; // refers to mandatory threads RtsFlags.GcFlags.maxStkSize = (1024 * 1024) / sizeof(W_); RtsFlags.GcFlags.initialStkSize = 1024 / sizeof(W_); + RtsFlags.GranFlags.maxThreads = 65536; // refers to mandatory threads RtsFlags.GranFlags.GranSimStats.Full = rtsFalse; RtsFlags.GranFlags.GranSimStats.Suppressed = rtsFalse; RtsFlags.GranFlags.GranSimStats.Binary = rtsFalse; @@ -348,38 +370,19 @@ usage_text[] = { " -B Sound the bell at the start of each garbage collection", #if defined(PROFILING) || defined(PAR) "", -" -p Produce cost centre time profile (output file .prof)", +" -px Time/allocation profile (XML) (output file .prof)", +" -p Time/allocation profile (output file .prof)", " sort: T = time (default), A = alloc, C = cost centre label", -" -P Produce serial time profile (output file .time)", -" and a -p profile with detailed tick/alloc info", +" -P More detailed Time/Allocation profile" # if defined(PROFILING) "", -" -h Heap residency profile (output file .hp)", -" break-down: C = cost centre stack (default), M = module, G = group", +" -hx Heap residency profile (XML) (output file .prof)", +" -h Heap residency profile (text) (output file .prof)", +" break-down: C = cost centre stack (default), M = module", " D = closure description, Y = type description", -" T, = time closure created", -" ints: no. of interval bands plotted (default 18)", -" start: seconds after which intervals start (default 0.0)", -" A subset of closures may be selected by the attached cost centre using:", -" -c{mod:lab,mod:lab...}, specific module:label cost centre(s)", -" -m{mod,mod...} all cost centres from the specified modules(s)", -" -g{grp,grp...} all cost centres from the specified group(s)", -" Selections can also be made by description, type, kind and age:", -" -d{des,des...} closures with specified closure descriptions", -" -y{typ,typ...} closures with specified type descriptions", -" -k{knd,knd...} closures of the specified kinds", -" -a closures which survived complete intervals", -" The selection logic used is summarised as follows:", -" ([-c] or [-m] or [-g]) and ([-d] or [-y] or [-k]) and [-a]", -" where an option is true if not specified", "", " -xc Show current cost centre stack on raising an exception", # endif -"", -" -z set hash table for (C, M, G, D or Y)", -"", -" -i Number of seconds in a profiling interval (default 1.0):", -" heap profile (-h) and/or serial time profile (-P) frequency", #endif /* PROFILING or PAR */ #if !defined(PROFILING) && defined(DEBUG) "", @@ -399,7 +402,7 @@ usage_text[] = { #endif " -C Context-switch interval in seconds", " (0 or no argument means switch as often as possible)", -" the default is .01 sec; resolution is .01 sec", +" the default is .02 sec; resolution is .02 sec", #if defined(SMP) " -N Use OS threads (default: 1)", #endif @@ -586,22 +589,11 @@ error = rtsTrue; #ifdef DEBUG case 'D': - /* hack warning: interpret the flags as a binary number */ - { - I_ n = decode(rts_argv[arg]+2); - if (n &1) RtsFlags.DebugFlags.scheduler = rtsTrue; - if ((n>>1)&1) RtsFlags.DebugFlags.evaluator = rtsTrue; - if ((n>>2)&1) RtsFlags.DebugFlags.codegen = rtsTrue; - if ((n>>3)&1) RtsFlags.DebugFlags.weak = rtsTrue; - if ((n>>4)&1) RtsFlags.DebugFlags.gccafs = rtsTrue; - if ((n>>5)&1) RtsFlags.DebugFlags.gc = rtsTrue; - if ((n>>6)&1) RtsFlags.DebugFlags.block_alloc = rtsTrue; - if ((n>>7)&1) RtsFlags.DebugFlags.sanity = rtsTrue; - if ((n>>8)&1) RtsFlags.DebugFlags.stable = rtsTrue; - if ((n>>9)&1) RtsFlags.DebugFlags.prof = rtsTrue; - if ((n>>10)&1) RtsFlags.DebugFlags.gran = rtsTrue; - if ((n>>11)&1) RtsFlags.DebugFlags.par = rtsTrue; - } + if (isdigit(rts_argv[arg][2])) {/* Set all debugging options in one */ + /* hack warning: interpret the flags as a binary number */ + nat n = decode(rts_argv[arg]+2); + set_debug_options(n); + } break; #endif @@ -662,14 +654,6 @@ error = rtsTrue; } break; - case 'j': /* force GC option */ - RtsFlags.GcFlags.forceGC = rtsTrue; - if (rts_argv[arg][2]) { - RtsFlags.GcFlags.forcingInterval - = decode(rts_argv[arg]+2) / sizeof(W_); - } - break; - case 'S': RtsFlags.GcFlags.giveStats ++; @@ -710,13 +694,6 @@ error = rtsTrue; } ) break; - case 'i': /* serial profiling -- initial timer interval */ - COST_CENTRE_USING_BUILD_ONLY( - interval_ticks = (I_) ((atof(rts_argv[arg]+2) * TICK_FREQUENCY)); - if (interval_ticks <= 0) - interval_ticks = 1; - ) break; - case 'h': /* serial heap profile */ #if !defined(PROFILING) && defined(DEBUG) switch (rts_argv[arg][2]) { @@ -741,31 +718,12 @@ error = rtsTrue; case MODchar: RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_MOD; break; - case GRPchar: - RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_GRP; - break; case DESCRchar: RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_DESCR; break; case TYPEchar: RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_TYPE; break; - case TIMEchar: - RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_TIME; - if (rts_argv[arg][3]) { - char *start_str = strchr(rts_argv[arg]+3, ','); - I_ intervals; - if (start_str) *start_str = '\0'; - - if ((intervals = decode(rts_argv[arg]+3)) != 0) { - time_intervals = (hash_t) intervals; - /* ToDo: and what if it *is* zero intervals??? */ - } - if (start_str) { - earlier_ticks = (I_)((atof(start_str + 1) * TICK_FREQUENCY)); - } - } - break; default: prog_belch("invalid heap profile option: %s",rts_argv[arg]); error = rtsTrue; @@ -774,92 +732,6 @@ error = rtsTrue; #endif break; - case 'z': /* size of index tables */ - PROFILING_BUILD_ONLY( - switch (rts_argv[arg][2]) { - case CCchar: - max_cc_no = (hash_t) decode(rts_argv[arg]+3); - if (max_cc_no == 0) { - prog_belch("bad number of cost centres %s", rts_argv[arg]); - error = rtsTrue; - } - break; - case MODchar: - max_mod_no = (hash_t) decode(rts_argv[arg]+3); - if (max_mod_no == 0) { - prog_belch("bad number of modules %s", rts_argv[arg]); - error = rtsTrue; - } - break; - case GRPchar: - max_grp_no = (hash_t) decode(rts_argv[arg]+3); - if (max_grp_no == 0) { - prog_belch("bad number of groups %s", rts_argv[arg]); - error = rtsTrue; - } - break; - case DESCRchar: - max_descr_no = (hash_t) decode(rts_argv[arg]+3); - if (max_descr_no == 0) { - prog_belch("bad number of closure descriptions %s", - rts_argv[arg]); - error = rtsTrue; - } - break; - case TYPEchar: - max_type_no = (hash_t) decode(rts_argv[arg]+3); - if (max_type_no == 0) { - prog_belch("bad number of type descriptions %s", - rts_argv[arg]); - error = rtsTrue; - } - break; - default: - prog_belch("invalid index table size option: %s", - rts_argv[arg]); - error = rtsTrue; - } - ) break; - - case 'c': /* cost centre label select */ - case 'g': /* cost centre group select */ - case 'd': /* closure descr select */ - case 'y': /* closure type select */ - PROFILING_BUILD_ONLY( - {char *left = strchr(rts_argv[arg], '{'); - char *right = strrchr(rts_argv[arg], '}'); - - if (! left || ! right || - strrchr(rts_argv[arg], '{') != left || - strchr(rts_argv[arg], '}') != right) { - prog_belch("invalid heap profiling selection bracketing: %s", - rts_argv[arg]); - error = rtsTrue; - } else { - *right = '\0'; - switch (rts_argv[arg][1]) { - case 'c': /* cost centre label select */ - RtsFlags.ProfFlags.ccSelector = left + 1; - break; - case 'm': /* cost centre module select */ - RtsFlags.ProfFlags.modSelector = left + 1; - break; - case 'g': /* cost centre group select */ - RtsFlags.ProfFlags.grpSelector = left + 1; - break; - case 'd': /* closure descr select */ - RtsFlags.ProfFlags.descrSelector = left + 1; - break; - case 'y': /* closure type select */ - RtsFlags.ProfFlags.typeSelector = left + 1; - break; - case 'k': /* closure kind select */ - RtsFlags.ProfFlags.kindSelector = left + 1; - break; - } - }} - ) break; - /* =========== CONCURRENT ========================= */ case 'C': /* context switch interval */ if (rts_argv[arg][2] == '\0') @@ -870,7 +742,7 @@ error = rtsTrue; /* Convert to milliseconds */ cst = (I_) ((atof(rts_argv[arg]+2) * 1000)); cst = (cst / CS_MIN_MILLISECS) * CS_MIN_MILLISECS; - if (cst < CS_MIN_MILLISECS) + if (cst != 0 && cst < CS_MIN_MILLISECS) cst = CS_MIN_MILLISECS; RtsFlags.ConcFlags.ctxtSwitchTime = cst; @@ -1878,9 +1750,10 @@ set_par_debug_options(nat n) { case 4: RtsFlags.ParFlags.Debug.resume = rtsTrue; break; case 5: RtsFlags.ParFlags.Debug.weight = rtsTrue; break; case 6: RtsFlags.ParFlags.Debug.fetch = rtsTrue; break; - case 7: RtsFlags.ParFlags.Debug.ack = rtsTrue; break; - case 8: RtsFlags.ParFlags.Debug.fish = rtsTrue; break; - case 9: RtsFlags.ParFlags.Debug.forward = rtsTrue; break; + //case 7: RtsFlags.ParFlags.Debug.ack = rtsTrue; break; + case 7: RtsFlags.ParFlags.Debug.fish = rtsTrue; break; + case 8: RtsFlags.ParFlags.Debug.tables = rtsTrue; break; + case 9: RtsFlags.ParFlags.Debug.packet = rtsTrue; break; case 10: RtsFlags.ParFlags.Debug.pack = rtsTrue; break; default: barf("set_par_debug_options: only %d debug options expected"); } /* switch */ @@ -1900,7 +1773,42 @@ help_par_debug_options(nat n) { fprintf(stderr, par_debug_opts_strs[i]); } -#endif /* GRAN */ +#endif /* PAR */ + +#ifdef DEBUG +static void +set_debug_options(nat n) { + nat i; + + for (i=0; i<=MAX_DEBUG_OPTION; i++) + if ((n>>i)&1) { + fprintf(stderr, debug_opts_strs[i]); + switch (i) { + case 0: RtsFlags.DebugFlags.scheduler = rtsTrue; break; + case 1: RtsFlags.DebugFlags.evaluator = rtsTrue; break; + case 2: RtsFlags.DebugFlags.codegen = rtsTrue; break; + case 3: RtsFlags.DebugFlags.weak = rtsTrue; break; + case 4: RtsFlags.DebugFlags.gccafs = rtsTrue; break; + case 5: RtsFlags.DebugFlags.gc = rtsTrue; break; + case 6: RtsFlags.DebugFlags.block_alloc = rtsTrue; break; + case 7: RtsFlags.DebugFlags.sanity = rtsTrue; break; + case 8: RtsFlags.DebugFlags.stable = rtsTrue; break; + case 9: RtsFlags.DebugFlags.prof = rtsTrue; break; + case 10: RtsFlags.DebugFlags.gran = rtsTrue; break; + case 11: RtsFlags.DebugFlags.par = rtsTrue; break; + } /* switch */ + } /* if */ +} + +static void +help_debug_options(nat n) { + nat i; + + for (i=0; i<=MAX_DEBUG_OPTION; i++) + if ((n>>i)&1) + fprintf(stderr, debug_opts_strs[i]); +} +#endif /* DEBUG */ //@node Aux fcts, , GranSim specific options //@subsection Aux fcts