-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParallel.html
More file actions
97 lines (80 loc) · 4.48 KB
/
Parallel.html
File metadata and controls
97 lines (80 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<html lang="en">
<head>
<title>GNU `make'</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU `make'">
<meta name="generator" content="makeinfo 4.3">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
</head>
<body>
<div class="node">
<p>
Node:<a name="Parallel">Parallel</a>,
Next:<a rel="next" accesskey="n" href="Errors.html#Errors">Errors</a>,
Previous:<a rel="previous" accesskey="p" href="Execution.html#Execution">Execution</a>,
Up:<a rel="up" accesskey="u" href="Commands.html#Commands">Commands</a>
<hr><br>
</div>
<h3 class="section">Parallel Execution</h3>
<p>GNU <code>make</code> knows how to execute several commands at once.
Normally, <code>make</code> will execute only one command at a time, waiting
for it to finish before executing the next. However, the <code>-j</code> or
<code>--jobs</code> option tells <code>make</code> to execute many commands
simultaneously.
<p>On MS-DOS, the <code>-j</code> option has no effect, since that system doesn't
support multi-processing.
<p>If the <code>-j</code> option is followed by an integer, this is the number of
commands to execute at once; this is called the number of <dfn>job slots</dfn>.
If there is nothing looking like an integer after the <code>-j</code> option,
there is no limit on the number of job slots. The default number of job
slots is one, which means serial execution (one thing at a time).
<p>One unpleasant consequence of running several commands simultaneously is
that output generated by the commands appears whenever each command
sends it, so messages from different commands may be interspersed.
<p>Another problem is that two processes cannot both take input from the
same device; so to make sure that only one command tries to take input
from the terminal at once, <code>make</code> will invalidate the standard
input streams of all but one running command. This means that
attempting to read from standard input will usually be a fatal error (a
<code>Broken pipe</code> signal) for most child processes if there are
several.
<p>It is unpredictable which command will have a valid standard input stream
(which will come from the terminal, or wherever you redirect the standard
input of <code>make</code>). The first command run will always get it first, and
the first command started after that one finishes will get it next, and so
on.
<p>We will change how this aspect of <code>make</code> works if we find a better
alternative. In the mean time, you should not rely on any command using
standard input at all if you are using the parallel execution feature; but
if you are not using this feature, then standard input works normally in
all commands.
<p>Finally, handling recursive <code>make</code> invocations raises issues. For
more information on this, see
<a href="Options-Recursion.html#Options%2fRecursion">Communicating Options to a Sub-<code>make</code></a>.
<p>If a command fails (is killed by a signal or exits with a nonzero
status), and errors are not ignored for that command
(see <a href="Errors.html#Errors">Errors in Commands</a>),
the remaining command lines to remake the same target will not be run.
If a command fails and the <code>-k</code> or <code>--keep-going</code>
option was not given
(see <a href="Options-Summary.html#Options%20Summary">Summary of Options</a>),
<code>make</code> aborts execution. If make
terminates for any reason (including a signal) with child processes
running, it waits for them to finish before actually exiting.
<p>When the system is heavily loaded, you will probably want to run fewer jobs
than when it is lightly loaded. You can use the <code>-l</code> option to tell
<code>make</code> to limit the number of jobs to run at once, based on the load
average. The <code>-l</code> or <code>--max-load</code>
option is followed by a floating-point number. For
example,
<pre class="example"> -l 2.5
</pre>
<p>will not let <code>make</code> start more than one job if the load average is
above 2.5. The <code>-l</code> option with no following number removes the
load limit, if one was given with a previous <code>-l</code> option.
<p>More precisely, when <code>make</code> goes to start up a job, and it already has
at least one job running, it checks the current load average; if it is not
lower than the limit given with <code>-l</code>, <code>make</code> waits until the load
average goes below that limit, or until all the other jobs finish.
<p>By default, there is no load limit.
</body></html>