Skip to content

Commit 53135c4

Browse files
committed
Add description of tasking statements
redline.sh is a script to generate a redlined document
1 parent 11cb805 commit 53135c4

File tree

4 files changed

+191
-4
lines changed

4 files changed

+191
-4
lines changed

cplexts.tex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
\usepackage[normalem]{ulem} % for underlining and strikeout
2626
\usepackage{underscore} % to simplify use of underscores
2727
\usepackage{verbatim} % for code font
28-
\usepackage{xspace} % to simplify a macro that expands to text
28+
\usepackage{xspace} % to simplify macros that expand to text
2929
\makeindex
3030
\setcounter{secnumdepth}{6}
31-
\setcounter{tocdepth}{6} % increase to check outline structure
31+
\setcounter{tocdepth}{2} % practical TOC size
32+
\setcounter{tocdepth}{6} % uncomment to check outline structure
3233

3334
% These macros are from the WG21 standard source.
3435
\input{macros}
@@ -43,7 +44,7 @@
4344
% These parameters, and the documentclass options,
4445
% are about document identification and overall formatting.
4546
\newcommand{\cplexts}{$CPLEXTS$}
46-
\renewcommand{\extrahead}{2014-06-24}
47+
\renewcommand{\extrahead}{2014-08-13}
4748
\standard{\cplexts}
4849
\yearofedition{2016}
4950
\languageofedition{(E)}
@@ -140,6 +141,8 @@
140141

141142
\include{parallelloop}
142143

144+
\include{spawning}
145+
143146
\include{loopparameter}
144147

145148
%\include{samples}

loopparameter.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@
172172
each iteration should be assumed to execute
173173
in approximately the same amount of time.
174174
A loop with an unbalanced workload
175-
should be assumed to have iterations taking a random amount of time.
175+
should be assumed to have iterations
176+
taking widely varying amounts of time.
176177

177178
\begin{note}
178179
This parameter is semantically a statement about the associated loop,

redline.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rm -f ../old
2+
git checkout-index -f -a --prefix=../old/
3+
latexdiff-so --flatten ../old/cplexts.tex cplexts.tex >cplexts-diff.tex

spawning.tex

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
\clause{Spawning tasks}
2+
\sclause{Task statements}
3+
4+
\pnum
5+
The grammar of a statement (6.8, paragraph 1)
6+
\begin{cpp}
7+
(clause 6, paragraph 1)
8+
\end{cpp}
9+
is modified to add task-statement as a new alternative.
10+
11+
\ssclause*{Syntax}
12+
13+
\begin{bnf}
14+
\nontermdef{task-statement}
15+
\br
16+
task-block-statement
17+
\br
18+
task-spawn-statement
19+
\br
20+
task-sync-statement
21+
\br
22+
task-call-statement
23+
\end{bnf}
24+
25+
\sclause{The task block statement}
26+
\ssclause*{Syntax}
27+
28+
\begin{bnf}
29+
\nontermdef{task-block-statement}
30+
\br
31+
\terminal{_Task_parallel} \terminal{_Block} compound-statement
32+
\end{bnf}
33+
34+
\ssclause*{Semantics}
35+
36+
\pnum
37+
Defines a task block, within which tasks can be spawned.
38+
At the end of the contained compound statement,
39+
all child tasks spawned directly or indirectly
40+
within the compound statement are
41+
\defn{joined}:
42+
the statement following the task block is not executed
43+
until all of the child tasks complete.
44+
45+
\pnum
46+
For a given statement, the
47+
\defn{associated task block}
48+
is defined as follows.
49+
For a statement within a task spawn statement,
50+
there is no associated task block,
51+
except within a nested task block statement.
52+
For a statement within a task block statement,
53+
the associated task block is the smallest enclosing task block statement.
54+
Otherwise, for a statement within the body of a function
55+
declared with the spawning function specifier,
56+
the associated task block is the same as it was
57+
at the point of the task spawning call statement
58+
that invoked the spawning function.
59+
For statements in other contexts,
60+
there is no associated task block.
61+
\footnote{EN:
62+
Should a parallel loop implicitly establish its own task block?
63+
}
64+
65+
\begin{note}
66+
Task blocks can be nested lexically and/or dynamically.
67+
Determination of the associated task block is a hybrid process:
68+
lexically within a function,
69+
and dynamically across calls to spawning functions.%
70+
\footnote{DFEP:
71+
In Cilk, this determination can be done entirely lexically.
72+
In OpenMP, this determination can be done entirely dynamically.
73+
}
74+
Code designated for execution in another thread
75+
by means other than a task statement
76+
(e.g. using
77+
\tcode{thrd_create})
78+
is not part of any task block.
79+
\end{note}
80+
81+
\sclause{The task spawn statement}
82+
\ssclause*{Syntax}
83+
84+
\begin{bnf}
85+
\nontermdef{task-spawn-statement}
86+
\br
87+
\terminal{_Task_parallel} \terminal{_Spawn} compound-statement
88+
\end{bnf}
89+
90+
\ssclause*{Constraints}
91+
92+
\pnum
93+
A task spawn statement shall have an associated task block.
94+
95+
\ssclause*{Semantics}
96+
\pnum
97+
Creates a child task of the associated task block
98+
of the task spawn statement,
99+
in which the contained compound statement is executed.
100+
The execution of the task is unsequenced
101+
with respect to the statements of the associated task block
102+
following the spawn statement.
103+
The completion of the task synchronizes
104+
with the completion of the associated task block,
105+
or with the next execution of a sync statement
106+
within the associated task block.
107+
108+
\sclause{The task sync statement}
109+
\ssclause*{Syntax}
110+
111+
\begin{bnf}
112+
\nontermdef{task-sync-statement}
113+
\br
114+
\terminal{_Task_parallel} \terminal{_Sync} \terminal{;}
115+
\end{bnf}
116+
117+
\ssclause*{Constraints}
118+
119+
\pnum
120+
A task sync statement shall have an associated task block.
121+
122+
\ssclause*{Semantics}
123+
\pnum
124+
Joins all child tasks of the associated task block
125+
of the task sync statement.
126+
127+
\sclause{The task spawning call statement}
128+
\ssclause*{Syntax}
129+
\begin{bnf}
130+
\nontermdef{task-call-statement}
131+
\br
132+
\terminal{_Task_parallel} \terminal{_Call} expression-statement
133+
\footnote{EN:
134+
Using the same keyword pair
135+
for the statement prefix and the function specifier
136+
introduces a case where three tokens of lookahead
137+
(and hopefully no more)
138+
are sometimes needed
139+
to disambiguate a declaration from a statement.
140+
Is this what we want?
141+
}
142+
\end{bnf}
143+
\ssclause*{Constraints}
144+
145+
\pnum
146+
A task spawning call statement shall have an associated task block.
147+
148+
\ssclause*{Semantics}
149+
150+
\pnum
151+
The contained expression statement is executed normally.
152+
Any called spawning function is allowed to spawn tasks;
153+
any such tasks are associated with the associated task block
154+
of the task spawning call statement,
155+
and are unsequenced with respect to the statements of the task block
156+
following the task spawning call statement.
157+
158+
\sclause{The spawning function specifier}
159+
\ssclause*{Syntax}
160+
\pnum
161+
A new alternative is added to the grammar of function specifier
162+
(6.7.4 paragraph 1):
163+
164+
\begin{bnf}
165+
\nontermdef{function-specifier}
166+
\br
167+
\terminal{_Task_parallel} \terminal{_Call}
168+
\end{bnf}
169+
170+
\ssclause*{Constraints}
171+
\pnum
172+
If a spawning function specifier appears
173+
on any declaration of a function,
174+
it shall appear on every declaration of that function.
175+
A function declared with a spawning function specifier
176+
shall be called only from a task spawning call statement.
177+
\footnote{EN:
178+
Is a spawning function specifier part of the function's type?
179+
If so, are function-pointer conversions allowed?
180+
}

0 commit comments

Comments
 (0)