From 50c4d03919a9d5c37c14004e964083251f655e93 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 28 Feb 2008 11:16:31 +0000 Subject: [PATCH] Enable -prof -threaded (#886) 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 | 1 + rts/RtsFlags.c | 6 ++++++ rts/RtsStartup.c | 9 +++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/main/StaticFlags.hs b/compiler/main/StaticFlags.hs index f245d18..043df54 100644 --- a/compiler/main/StaticFlags.hs +++ b/compiler/main/StaticFlags.hs @@ -492,6 +492,7 @@ allowed_combination way = and [ x `allowedWith` y WayDebug `allowedWith` _ = True WayProf `allowedWith` WayNDP = True + WayThreaded `allowedWith` WayProf = True _ `allowedWith` _ = False diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 8f1b700..f8c8403 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -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; diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index 4f84468..4f42823 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -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 } /* ---------------------------------------------------------------------------- -- 1.7.10.4