summaryrefslogtreecommitdiff
path: root/rts/RtsFlags.c
diff options
context:
space:
mode:
authorMarcelineVQ <matthewnhyatt@gmail.com>2015-12-19 11:10:54 +0100
committerThomas Miedema <thomasmiedema@gmail.com>2015-12-19 11:10:58 +0100
commitb02838405b00bcdeebb44da0a7a9562cd7fda66b (patch)
tree590b90460663933028aedea25c4ac09f251f83be /rts/RtsFlags.c
parent2cc5b607df27e702541985f7c4c987806c4ec2a1 (diff)
downloadhaskell-b02838405b00bcdeebb44da0a7a9562cd7fda66b.tar.gz
Add -Nmax<n> RTS feature (#10728)
Added maximum core use based on processors -Nmax<x> chooses the minimum of processor count or x Added documentation. Reviewed By: simonmar, thomie Differential Revision: https://phabricator.haskell.org/D1650
Diffstat (limited to 'rts/RtsFlags.c')
-rw-r--r--rts/RtsFlags.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index 94572792de..bd60591f33 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -391,8 +391,9 @@ usage_text[] = {
"",
#endif /* DEBUG */
#if defined(THREADED_RTS) && !defined(NOSMP)
-" -N[<n>] Use <n> processors (default: 1, -N alone determines",
-" the number of processors to use automatically)",
+" -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",
" -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>",
@@ -1041,13 +1042,21 @@ error = rtsTrue;
} else {
int nNodes;
OPTION_SAFE; /* but see extra checks below... */
- nNodes = strtol(rts_argv[arg]+2, (char **) NULL, 10);
+
+ // <=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);
+ }
if (nNodes <= 0) {
errorBelch("bad value for -N");
error = rtsTrue;
}
if (rtsOptsEnabled == RtsOptsSafeOnly &&
- nNodes > (int)getNumberOfProcessors()) {
+ nNodes > (int)getNumberOfProcessors()) {
errorRtsOptsDisabled("Using large values for -N is not allowed by default. %s");
stg_exit(EXIT_FAILURE);
}