[project @ 1999-11-02 15:05:38 by simonmar]
[ghc-hetmet.git] / ghc / rts / RtsFlags.c
index 3d0d866..eac04b1 100644 (file)
@@ -1,5 +1,8 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.5 1999/01/19 17:06:04 simonm Exp $
+ * $Id: RtsFlags.c,v 1.20 1999/11/02 15:06:00 simonmar Exp $
+ *
+ * (c) The AQUA Project, Glasgow University, 1994-1997
+ * (c) The GHC Team, 1998-1999
  *
  * Functions for parsing the argument list.
  *
 #include "BlockAlloc.h"
 #include "ProfRts.h"
 
+#if defined(PROFILING) 
+#include "Itimer.h"
+#endif
+
 #if HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -64,9 +71,11 @@ void initRtsFlagsDefaults(void)
     RtsFlags.GcFlags.minAllocAreaSize   = (256 * 1024)        / BLOCK_SIZE;
     RtsFlags.GcFlags.minOldGenSize      = (1024 * 1024)       / BLOCK_SIZE;
     RtsFlags.GcFlags.maxHeapSize       = (64  * 1024 * 1024) / BLOCK_SIZE;
+    RtsFlags.GcFlags.heapSizeSuggestion        = 0;    /* none */
     RtsFlags.GcFlags.pcFreeHeap                = 3;    /* 3% */
     RtsFlags.GcFlags.oldGenFactor       = 2;
     RtsFlags.GcFlags.generations        = 2;
+    RtsFlags.GcFlags.steps              = 2;
 
     RtsFlags.GcFlags.forceGC           = rtsFalse;
     RtsFlags.GcFlags.forcingInterval   = 5000000; /* 5MB (or words?) */
@@ -92,23 +101,10 @@ void initRtsFlagsDefaults(void)
     RtsFlags.ProfFlags.doHeapProfile = rtsFalse;
 #endif
 
-/* there really shouldn't be a threads limit for concurrent mandatory threads.
-   For now, unlimitied means less than 64k (there's a storage overhead) -- SOF
-*/
-#if defined(CONCURRENT) && !defined(GRAN)
     RtsFlags.ConcFlags.ctxtSwitchTime  = CS_MIN_MILLISECS;  /* In milliseconds */
-    RtsFlags.ConcFlags.maxThreads      = 65536;
-    RtsFlags.ConcFlags.stkChunkSize    = 1024;
-    RtsFlags.ConcFlags.maxLocalSparks  = 65536;
-#endif /* CONCURRENT only */
-
-#if GRAN
-    RtsFlags.ConcFlags.ctxtSwitchTime  = CS_MIN_MILLISECS;  /* In milliseconds */
-    RtsFlags.ConcFlags.maxThreads      = 32;
-    RtsFlags.ConcFlags.stkChunkSize    = 1024;
-    RtsFlags.ConcFlags.maxLocalSparks  = 500;
-#endif /* GRAN */
-
+#ifdef SMP
+    RtsFlags.ConcFlags.nNodes  = 1;
+#endif
 #ifdef PAR
     RtsFlags.ParFlags.parallelStats    = rtsFalse;
     RtsFlags.ParFlags.granSimStats     = rtsFalse;
@@ -188,10 +184,8 @@ void initRtsFlagsDefaults(void)
 #endif
 
 #ifdef TICKY_TICKY
-    RtsFlags.TickyFlags.showTickyStats = rtsFalse;
-    RtsFlags.TickyFlags.tickyFile      = NULL;
-
-    AllFlags.doUpdEntryCounts          = rtsTrue; /*ToDo:move? */
+    RtsFlags.TickyFlags.showTickyStats  = rtsFalse;
+    RtsFlags.TickyFlags.tickyFile       = NULL;
 #endif
 }
 
@@ -213,9 +207,11 @@ usage_text[] = {
 "  -k<size> Sets the initial thread stack size (default 1k)  Egs: -K4k   -K2m",
 "",
 "  -A<size> Sets the minimum allocation area size (default 256k) Egs: -A1m -A10k",
-"  -M<size> Sets the maximum heap size (default 64M)  Egs: -H256k -H1G",
+"  -M<size> Sets the maximum heap size (default 64M)  Egs: -M256k -M1G",
+"  -H<size> Sets the minimum heap size (default 0M)   Egs: -H24m  -H1G",
 "  -m<n>%   Minimum % of heap which must be available (default 3%)",
 "  -G<n>    Number of generations (default: 2)",
+"  -T<n>    Number of steps in younger generations (default: 2)",
 "  -s<file> Summary GC statistics   (default file: <program>.stat)",
 "  -S<file> Detailed GC statistics  (with -Sstderr going to stderr)",
 "",
@@ -231,7 +227,7 @@ usage_text[] = {
 # if defined(PROFILING)
 "",
 "  -h<break-down> Heap residency profile      (output file <program>.hp)",
-"     break-down: C = cost centre (default), M = module, G = group",
+"     break-down: C = cost centre stack (default), M = module, G = group",
 "                 D = closure description, Y = type description",
 "                 T<ints>,<start> = time closure created",
 "                    ints:  no. of interval bands plotted (default 18)",
@@ -267,8 +263,6 @@ usage_text[] = {
 "  -r<file>  Produce reduction profiling statistics (with -rstderr for stderr)",
 "",
 #endif
-"  -T<level> Trace garbage collection execution (debugging)",
-"",
 # ifdef PAR
 "  -N<n>     Use <n> PVMish processors in parallel (default: 2)",
 /* NB: the -N<n> is implemented by the driver!! */
@@ -276,16 +270,14 @@ usage_text[] = {
 "  -C<secs>  Context-switch interval in seconds",
 "                (0 or no argument means switch as often as possible)",
 "                the default is .01 sec; resolution is .01 sec",
-"  -e<size>        Size of spark pools (default 100)",
+# ifdef SMP
+"  -N<n>     Use <n> OS threads (default: 1)",
+# endif
 # ifdef PAR
 "  -q        Enable activity profile (output files in ~/<program>*.gr)",
 "  -qb       Enable binary activity profile (output file /tmp/<program>.gb)",
 "  -Q<size>  Set pack-buffer size (default: 1024)",
-# else
-"  -q[v]     Enable quasi-parallel profile (output file <program>.qp)",
 # endif
-"  -t<num>   Set maximum number of advisory threads per PE (default 32)",
-"  -o<num>   Set stack chunk size (default 1024)",
 # ifdef PAR
 "  -d        Turn on PVM-ish debugging",
 "  -O        Disable output for performance measurement",
@@ -441,7 +433,19 @@ error = rtsTrue;
 #ifdef DEBUG
              case 'D':
                /* hack warning: interpret the flags as a binary number */
-               *(int*)(&RtsFlags.DebugFlags) = decode(rts_argv[arg]+2);
+               { 
+                   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;
+                }
                break;
 #endif
 
@@ -486,8 +490,20 @@ error = rtsTrue;
                }
                break;
 
+             case 'T':
+               RtsFlags.GcFlags.steps = decode(rts_argv[arg]+2);
+               if (RtsFlags.GcFlags.steps < 1) {
+                 bad_option(rts_argv[arg]);
+               }
+               break;
+
              case 'H':
-               /* ignore for compatibility with older versions */
+               RtsFlags.GcFlags.heapSizeSuggestion = 
+                 decode(rts_argv[arg]+2) / BLOCK_SIZE;
+
+               if (RtsFlags.GcFlags.heapSizeSuggestion <= 0) {
+                 bad_option(rts_argv[arg]);
+               }
                break;
 
              case 'j': /* force GC option */
@@ -498,9 +514,11 @@ error = rtsTrue;
                }
                break;
 
-             case 'S': /* NB: no difference at present ! */
+             case 'S':
+               RtsFlags.GcFlags.giveStats ++;
+
              case 's':
-               RtsFlags.GcFlags.giveStats ++; /* will be VERBOSE_GC_STATS */
+               RtsFlags.GcFlags.giveStats ++;
 #ifdef PAR
                /* Opening all those files would almost certainly fail... */
                RtsFlags.ParFlags.parallelStats = rtsTrue;
@@ -567,7 +585,7 @@ error = rtsTrue;
                switch (rts_argv[arg][2]) {
                  case '\0':
                  case CCchar:
-                   RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_CC;
+                   RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_CCS;
                    break;
                  case MODchar:
                    RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_MOD;
@@ -706,16 +724,18 @@ error = rtsTrue;
                }
                break;
 
-             case 't':
+#ifdef SMP
+             case 'N':
                if (rts_argv[arg][2] != '\0') {
-                   RtsFlags.ConcFlags.maxThreads
+                   RtsFlags.ConcFlags.nNodes
                      = strtol(rts_argv[arg]+2, (char **) NULL, 10);
-               } else {
-                   fprintf(stderr, "setupRtsFlags: missing size for -t\n");
-                   error = rtsTrue;
-               }
+                   if (RtsFlags.ConcFlags.nNodes <= 0) {
+                       fprintf(stderr, "setupRtsFlags: bad value for -N\n");
+                       error = rtsTrue;
+                   }
+               }
                break;
-
+#endif
              /* =========== PARALLEL =========================== */
              case 'e':
                PAR_BUILD_ONLY(