diff options
author | MarcelineVQ <matthewnhyatt@gmail.com> | 2015-12-23 01:23:33 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-23 10:05:39 +0100 |
commit | 7ed0da6cde909e662d09e1f39c3fccfa10f91a7f (patch) | |
tree | 5afdda1d857199b41a520db124083991daa04ae6 /rts | |
parent | ed213ead5e92aa3c2ae830a00f06684a1028d3ad (diff) | |
download | haskell-7ed0da6cde909e662d09e1f39c3fccfa10f91a7f.tar.gz |
Modify Nmax to maxN Trac #10728
Added test and changed -Nmax to -maxN, -n was taken
Noticed strange -m behavoir and fixed -m from quietly
ignoring being passed invalid opts, e.g. "-msasd"
Reviewers: simonmar, hvr, austin, thomie, bgamari
Reviewed By: hvr, thomie, bgamari
Subscribers: bgamari, hvr, thomie, simonmar
Differential Revision: https://phabricator.haskell.org/D1677
GHC Trac Issues: #10728
Diffstat (limited to 'rts')
-rw-r--r-- | rts/RtsFlags.c | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index bd60591f33..56f4420142 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -393,7 +393,7 @@ usage_text[] = { #if defined(THREADED_RTS) && !defined(NOSMP) " -N[<n>] Use <n> processors (default: 1, -N alone determines", " the number of processors to use automatically)", -" -Nmax[<n>] Use up to n processors automatically", +" -maxN[<n>] Use up to <n> processors automatically", " -qg[<n>] Use parallel GC only for generations >= <n>", " (default: 0, -qg alone turns off parallel GC)", " -qb[<n>] Use load-balancing in the parallel GC only for generations >= <n>", @@ -846,14 +846,46 @@ error = rtsTrue; break; case 'm': - OPTION_UNSAFE; - RtsFlags.GcFlags.pcFreeHeap = atof(rts_argv[arg]+2); + /* Case for maxN feature request ticket #10728, it's a little + odd being so far from the N case. */ +#if !defined(NOSMP) + if (strncmp("maxN", &rts_argv[arg][1], 4) == 0) { + OPTION_SAFE; + THREADED_BUILD_ONLY( + int nNodes; + int proc = (int)getNumberOfProcessors(); + OPTION_SAFE; + + nNodes = strtol(rts_argv[arg]+5, (char **) NULL, 10); + if (nNodes > proc) { nNodes = proc; } - if (RtsFlags.GcFlags.pcFreeHeap < 0 || - RtsFlags.GcFlags.pcFreeHeap > 100) + if (nNodes <= 0) { + errorBelch("bad value for -maxN"); + error = rtsTrue; + } +#if defined(PROFILING) + RtsFlags.ParFlags.nNodes = 1; +#else + RtsFlags.ParFlags.nNodes = (nat)nNodes; +#endif + ) break; + } else { +#endif + OPTION_UNSAFE; + RtsFlags.GcFlags.pcFreeHeap = atof(rts_argv[arg]+2); + + /* -m was allowing bad flags to go unreported */ + if (RtsFlags.GcFlags.pcFreeHeap == 0.0 && + rts_argv[arg][2] != '0') bad_option( rts_argv[arg] ); - break; + if (RtsFlags.GcFlags.pcFreeHeap < 0 || + RtsFlags.GcFlags.pcFreeHeap > 100) + bad_option( rts_argv[arg] ); + break; +#if !defined(NOSMP) + } +#endif case 'G': OPTION_UNSAFE; RtsFlags.GcFlags.generations = @@ -1043,14 +1075,8 @@ error = rtsTrue; int nNodes; OPTION_SAFE; /* but see extra checks below... */ - // <=n feature request ticket #10728 - if (strncmp("max", &rts_argv[arg][2], 3) == 0) { - int proc = (int)getNumberOfProcessors(); - nNodes = strtol(rts_argv[arg]+5, (char **) NULL, 10); - if (nNodes > proc) { nNodes = proc; } - } else { - nNodes = strtol(rts_argv[arg]+2, (char **) NULL, 10); - } + nNodes = strtol(rts_argv[arg]+2, (char **) NULL, 10); + if (nNodes <= 0) { errorBelch("bad value for -N"); error = rtsTrue; |