Enable -prof -threaded (#886)
authorSimon Marlow <simonmar@microsoft.com>
Thu, 28 Feb 2008 11:16:31 +0000 (11:16 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Thu, 28 Feb 2008 11:16:31 +0000 (11:16 +0000)
It turns out that -prof -threaded works (modulo some small changes),
because all the data structures used in profiling are only accessed by
one thread at a time, at long as we don't use +RTS -N2 or higher.  So
this patch enables the use of -prof -threaded, but an error is given
if you ask for more than one CPU with +RTS -N.

compiler/main/StaticFlags.hs
rts/RtsFlags.c
rts/RtsStartup.c

index f245d18..043df54 100644 (file)
@@ -492,6 +492,7 @@ allowed_combination way = and [ x `allowedWith` y
        WayDebug `allowedWith` _                = True
 
        WayProf `allowedWith` WayNDP            = True
+       WayThreaded `allowedWith` WayProf       = True
        _ `allowedWith` _                       = False
 
 
index 8f1b700..f8c8403 100644 (file)
@@ -1117,6 +1117,12 @@ error = rtsTrue;
                      errorBelch("bad value for -N");
                      error = rtsTrue;
                    }
+#if defined(PROFILING)
+                    if (RtsFlags.ParFlags.nNodes > 1) {
+                        errorBelch("bad option %s: only -N1 is supported with profiling", rts_argv[arg]);
+                     error = rtsTrue;
+                    }
+#endif
                }
                ) break;
 
index 4f84468..4f42823 100644 (file)
@@ -281,10 +281,6 @@ hs_init(int *argc, char **argv[])
     x86_init_fpu();
 #endif
 
-#if defined(THREADED_RTS)
-    ioManagerStart();
-#endif
-
     /* Record initialization times */
     stat_endInit();
 }
@@ -360,6 +356,11 @@ hs_add_root(void (*init_root)(void))
     // This must be done after module initialisation.
     // ToDo: make this work in the presence of multiple hs_add_root()s.
     initProfiling2();
+
+    // ditto.
+#if defined(THREADED_RTS)
+    ioManagerStart();
+#endif
 }
 
 /* ----------------------------------------------------------------------------