-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspawning.tex
173 lines (144 loc) · 4.03 KB
/
spawning.tex
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
\clause{Task statements}
\sclause{Introduction}
\pnum
The grammar of a statement (6.8, paragraph 1)
\begin{cpp}
(clause 6, paragraph 1)
\end{cpp}
is modified to add task-statement as a new alternative.
\ssclause*{Syntax}
\begin{bnf}
\nontermdef{task-statement}
\br
task-block-statement
\br
task-spawn-statement
\br
task-sync-statement
\br
task-call-statement
\end{bnf}
\sclause{The task block statement}
\ssclause*{Syntax}
\begin{bnf}
\nontermdef{task-block-statement}
\br
\terminal{_Task} \terminal{_Block} reduction-capture\opt{} compound-statement
\end{bnf}
\ssclause*{Constraints}
\pnum
There shall be no
\tcode{switch}
or jump statement that might transfer control into or out of
a task block statement.
\ssclause*{Semantics}
\pnum
Defines a task block, within which tasks can be spawned.
At the end of the contained compound statement,
execution joins with
all child tasks spawned directly or indirectly
within the compound statement.
\pnum
For a given statement, the
\defn{associated task block}
is defined as follows.
For a statement within a task spawn statement,
there is no associated task block,
except within a nested task block statement
or parallel loop.
For a statement within a task block statement
or parallel loop,
the associated task block is the smallest enclosing task block statement
or parallel loop.
Otherwise, for a statement within the body of a function
with spawning function type,
the associated task block is the same as it was
at the point of the task spawning call statement
that invoked the spawning function.
For a statement in any other context,
there is no associated task block.
\begin{note}
Task blocks can be nested lexically and/or dynamically.
Determination of the associated task block is a hybrid process:
lexically within a function,
and dynamically across calls to spawning functions.%
\footnote{DFEP:
In Cilk, this determination can be done entirely lexically.
In OpenMP, this determination can be done entirely dynamically.
}
Code designated for execution in another thread
by means other than a task statement
(e.g. using
\tcode{thrd_create})
is not part of any task block.
\end{note}
\pnum
Attempting to terminate a task block with
\tcode{longjmp}
produces undefined behavior.
\sclause{The task spawn statement}
\ssclause*{Syntax}
\begin{bnf}
\nontermdef{task-spawn-statement}
\br
\terminal{_Task} \terminal{_Spawn} spawn-capture\opt{} compound-statement
\end{bnf}
\ssclause*{Constraints}
\pnum
A task spawn statement shall have an associated task block.
\pnum
There shall be no
\tcode{switch}
or jump statement that might transfer control into or out of
a task spawn statement.
\pnum
Attempting to terminate a task spawn statement with
\tcode{longjmp}
produces undefined behavior.
\ssclause*{Semantics}
\pnum
The contained compound statement is executed as a task,
independent of the continued execution
of the associated task block.
\sclause{The task sync statement}
\ssclause*{Syntax}
\begin{bnf}
\nontermdef{task-sync-statement}
\br
\terminal{_Task} \terminal{_Sync} \terminal{;}
\end{bnf}
\ssclause*{Constraints}
\pnum
A task sync statement shall have an associated task block.
\ssclause*{Semantics}
\pnum
Execution joins with
all child tasks of the associated task block
of the task sync statement.
\sclause{The task spawning call statement}
\ssclause*{Syntax}
\begin{bnf}
\nontermdef{task-call-statement}
\br
\terminal{_Task} \terminal{_Call} expression-statement
\end{bnf}
\ssclause*{Constraints}
\pnum
A task spawning call statement shall have an associated task block.
\ssclause*{Semantics}
\pnum
The contained expression statement is executed normally.
Any called spawning function is allowed to spawn tasks;
any such tasks are associated with the associated task block
of the task spawning call statement,
and are
independent of
the statements of the task block
following the task spawning call statement.
\begin{note}
A call to a task spawning function need not be
the ``outermost'' operation of the expression statement.
A task spawning call statement
might invoke more than one spawning function,
or might invoke none.
\end{note}