diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-03-13 11:46:46 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-03-13 11:46:46 +0000 |
commit | 3b5940fd32df31b56c1ab6891b0a8f338e796049 (patch) | |
tree | 5e3dc646c39aa082dc97a6e1e8452f84b554fc93 /rts/RtsFlags.c | |
parent | 8815f0c06c1dcea2ecca14c98f0972ea9ed29d51 (diff) | |
download | haskell-3b5940fd32df31b56c1ab6891b0a8f338e796049.tar.gz |
Add "+RTS -N" to determine the -N value automatically (see #1741)
Diffstat (limited to 'rts/RtsFlags.c')
-rw-r--r-- | rts/RtsFlags.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index 86900404d4..cbc2bb5261 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -17,6 +17,14 @@ #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> @@ -454,7 +462,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", @@ -1138,7 +1147,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) { |