summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/users_guide/using-concurrent.rst8
-rw-r--r--rts/RtsFlags.c17
2 files changed, 20 insertions, 5 deletions
diff --git a/docs/users_guide/using-concurrent.rst b/docs/users_guide/using-concurrent.rst
index c00a294132..2621afce0f 100644
--- a/docs/users_guide/using-concurrent.rst
+++ b/docs/users_guide/using-concurrent.rst
@@ -107,11 +107,14 @@ RTS options for SMP parallelism
There are two ways to run a program on multiple processors: call
``Control.Concurrent.setNumCapabilities`` from your program, or use the
-RTS ``-N`` option.
+RTS ``-N`` options.
``-N⟨x⟩``
+``-Nmax⟨x⟩``
+
.. index::
single: -N⟨x⟩; RTS option
+ single: -Nmax(x); RTS option
Use ⟨x⟩ simultaneous threads when running the program.
@@ -133,6 +136,9 @@ RTS ``-N`` option.
value of ⟨x⟩ itself based on how many processors are in your
machine.
+ With Nmax⟨x⟩, i.e. ``+RTS -Nmax3 -RTS``, the runtime will choose at
+ most (x), also limited by the number of processors on the system.
+
Be careful when using all the processors in your machine: if some of
your processors are in use by other programs, this can actually harm
performance rather than improve it.
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);
}