Use work-stealing for load-balancing in the GC
[ghc-hetmet.git] / rts / RtsFlags.c
index 14f4fb0..2af67e7 100644 (file)
 #include <ctype.h>
 #endif
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 
@@ -178,6 +186,7 @@ void initRtsFlagsDefaults(void)
     RtsFlags.DebugFlags.prof           = rtsFalse;
     RtsFlags.DebugFlags.gran           = rtsFalse;
     RtsFlags.DebugFlags.par            = rtsFalse;
+    RtsFlags.DebugFlags.apply          = rtsFalse;
     RtsFlags.DebugFlags.linker         = rtsFalse;
     RtsFlags.DebugFlags.squeeze                = rtsFalse;
     RtsFlags.DebugFlags.hpc            = rtsFalse;
@@ -217,6 +226,7 @@ void initRtsFlagsDefaults(void)
     RtsFlags.ParFlags.wakeupMigrate     = rtsFalse;
     RtsFlags.ParFlags.parGcEnabled      = 1;
     RtsFlags.ParFlags.parGcGen          = 1;
+    RtsFlags.ParFlags.parGcLoadBalancing = 1;
 #endif
 
 #ifdef PAR
@@ -445,6 +455,7 @@ usage_text[] = {
 "  -Dp  DEBUG: prof",
 "  -Dr  DEBUG: gran",
 "  -DP  DEBUG: par",
+"  -Da  DEBUG: apply",
 "  -Dl  DEBUG: linker",
 "  -Dm  DEBUG: stm",
 "  -Dz  DEBUG: stack squezing",
@@ -452,7 +463,8 @@ usage_text[] = {
 "",
 #endif /* DEBUG */
 #if defined(THREADED_RTS) && !defined(NOSMP)
-"  -N<n>     Use <n> OS threads (default: 1)",
+"  -N<n>     Use <n> processors (default: 1)",
+"  -N        Determine the number of processors to use automatically",
 "  -q1       Use one OS thread for GC (turns off parallel GC)",
 "  -qg<n>    Use parallel GC only for generations >= <n> (default: 1)",
 "  -qm       Don't automatically migrate threads between CPUs",
@@ -1136,7 +1148,23 @@ error = rtsTrue;
 #if defined(THREADED_RTS) && !defined(NOSMP)
              case 'N':
                THREADED_BUILD_ONLY(
-               if (rts_argv[arg][2] != '\0') {
+               if (rts_argv[arg][2] == '\0') {
+#if defined(PROFILING)
+                   RtsFlags.ParFlags.nNodes = 1;
+#else
+#if defined(mingw32_HOST_OS)
+                    {
+                        SYSTEM_INFO si;
+                        GetSystemInfo(&si);
+                        RtsFlags.ParFlags.nNodes = si.dwNumberOfProcessors;
+                    }
+#elif defined(HAVE_SYSCONF)
+                    RtsFlags.ParFlags.nNodes = sysconf(_SC_NPROCESSORS_CONF);
+#else
+                    RtsFlags.ParFlags.nNodes = 1;
+#endif
+#endif
+               } else {
                    RtsFlags.ParFlags.nNodes
                      = strtol(rts_argv[arg]+2, (char **) NULL, 10);
                    if (RtsFlags.ParFlags.nNodes <= 0) {
@@ -1184,6 +1212,9 @@ error = rtsTrue;
                             error = rtsTrue;
                         }
                         break;
+                   case 'b':
+                       RtsFlags.ParFlags.parGcLoadBalancing = rtsFalse;
+                       break;
                    case 'm':
                        RtsFlags.ParFlags.migrate = rtsFalse;
                        break;