Skip to content

Commit 1ab4b9f

Browse files
committed
Initial WIP of P0214R9 integration
1 parent 39cffdb commit 1ab4b9f

File tree

2 files changed

+208
-0
lines changed

2 files changed

+208
-0
lines changed

data_parallel_types.html

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
<cxx-clause id="parallel.simd">
2+
<h1><ins>Data-Parallel Types</ins></h1>
3+
4+
<cxx-section id="parallel.simd.general">
5+
<h1><ins>General</ins></h1>
6+
7+
<p>
8+
<ins>
9+
The data-parallel library consists of data-parallel types and operations on these types. A data-parallel type consists of elements of an underlying arithmetic type, called the <em>element type</em>. The number of elements is a constant for each data-parallel type and called the <em>width</em> of that type.
10+
</ins>
11+
</p>
12+
13+
<p>
14+
<ins>
15+
Throughout this Clause, the term <em>data-parallel type</em> refers to all <em>supported</em> <cxx-ref to="parallel.simd.overview"></cxx-ref> specializations of the <code>simd</code> and <code>simd_mask</code> class templates. A <em>data-parallel object</em> is an object of <em>data-parallel type</em>.
16+
</ins>
17+
<p>
18+
19+
<p>
20+
<ins>
21+
An <em>element-wise operation</em> applies a specified operation to the elements of one or more data-parallel objects. Each such application is unsequenced with respect to the others. A <em>unary element-wise operation</em> is an element-wise operation that applies a unary operation to each element of a data-parallel object. A <em>binary element-wise operation</em> is an element-wise operation that applies a binary operation to corresponding elements of two data-parallel objects.
22+
</ins>
23+
</p>
24+
25+
<p>
26+
<ins>
27+
Throughout this Clause, the set of <em>vectorizable types</em> for a data-parallel type comprises all cv-unqualified arithmetic types other than <code>bool</code>.
28+
</ins>
29+
</p>
30+
31+
<p>
32+
<ins>
33+
<cxx-note>The intent is to support acceleration through data-parallel execution resources, such as SIMD registers and instructions or execution units driven by a common instruction decoder. If such execution resources are unavailable, the interfaces support a transparent fallback to sequential execution.</cxx-note>
34+
</ins>
35+
</p>
36+
37+
</cxx-section>
38+
39+
<cxx-section id="parallel.simd.synopsis">
40+
<h1><ins>Header <code>&lt;experimental/simd&gt;</code> synopsis</ins></h1>
41+
42+
<ins>
43+
<pre>
44+
45+
namespace std::experimental {
46+
inline namespace parallelism_v2 {
47+
namespace simd_abi {
48+
49+
struct scalar {};
50+
template&lt;int N&gt; struct fixed_size {};
51+
template&lt;class T&gt; inline constexpr int max_fixed_size = <em>implementation-defined</em>;
52+
template&lt;class T&gt; using compatible = <em>implementation-defined</em>;
53+
template&lt;class T&gt; using native = <em>implementation-defined</em>;
54+
55+
template&lt;class T, size_t N&gt; struct deduce { using type = <em>see-below</em>; };
56+
template&lt;class T, size_t N&gt; using deduce_t = typename deduce&lt;T, N&gt;::type;
57+
58+
struct element_aligned_tag {};
59+
struct vector_aligned_tag {};
60+
template&lt;size_t&gt; struct overaligned_tag {};
61+
inline constexpr element_aligned_tag element_aligned{};
62+
inline constexpr vector_aligned_tag vector_aligned{};
63+
template&lt;size_t N&gt; inline constexpr overaligned_tag&lt;N&gt; overaligned{};
64+
65+
<cxx-ref insynopsis="" to="parallel.simd.traits"></cxx-ref> traits
66+
template&lt;class T&gt; struct is_abi_tag;
67+
template&lt;class T&gt; inline constexpr bool is_abi_tag_v = is_abi_tag&lt;T&gt;::value;
68+
69+
template&lt;class T&gt; struct is_simd;
70+
template&lt;class T&gt; inline constexpr bool is_simd_v = is_simd&lt;T&gt;::value;
71+
72+
template&lt;class T&gt; struct is_simd_mask;
73+
template&lt;class T&gt; inline constexpr bool is_simd_mask_v = is_simd_mask&lt;T&gt;::value;
74+
75+
template&lt;class T&gt; struct is_simd_flag_type;
76+
template&lt;class T&gt; inline constexpr bool is_simd_flag_type_v = is_simd_flag_type&lt;T&gt;::value;
77+
78+
template&lt;class T, class Abi = simd_abi::compatible&lt;T&gt;&gt; struct simd_size;
79+
template&lt;class T, class Abi = simd_abi::compatible&lt;T&gt;&gt;
80+
inline constexpr size_t simd_size_v = simd_size&lt;T,Abi&gt;::value;
81+
82+
template&lt;class T, class U = typename T::value_type&gt; struct memory_alignment;
83+
template&lt;class T, class U = typename T::value_type&gt;
84+
inline constexpr size_t memory_alignment_v = memory_alignment&lt;T,U&gt;::value;
85+
86+
<cxx-ref insynopsis="" to="parallel.simd.class"></cxx-ref> class template simd
87+
template&lt;class T, class Abi = simd_abi::compatible&lt;T&gt;&gt; class simd;
88+
template&lt;class T&gt; using native_simd&lt;T, simd_abi::native&lt;T&gt;&gt;;
89+
template&lt;class T, int N&gt; using fixed_size_simd = simd&lt;T, simd_abi::fixed_size&lt;N&gt;&gt;;
90+
91+
<cxx-ref insynopsis="" to="parallel.simd.mask.class"></cxx-ref> class template simd_mask
92+
template&lt;class T, class Abi = simd_abi::compatible&lt;T&gt;&gt; class simd_mask;
93+
template&lt;class T&gt; using native_simd_mask&lt;T, simd_abi::native&lt;T&gt;&gt;;
94+
template&lt;class T, int N&gt; using fixed_size_simd_mask = simd_mask&lt;T, simd_abi::fixed_size&lt;N&gt;&gt;;
95+
96+
<cxx-ref insynopsis="" to="parallel.simd.casts"></cxx-ref> casts
97+
template&lt;class T, class U, class Abi&gt; <em>see-below</em> simd_cast(const simd&lt;U, Abi&gt;&);
98+
template&lt;class T, class U, class Abi&gt; <em>see-below</em> static_simd_cast(const simd&lt;U, Abi&gt;&);
99+
100+
template&lt;class T, class Abi&gt;
101+
fixed_size_simd&lt;T, simd_size_v&lt;T, Abi&gt;&gt; to_fixed_size(const simd&lt;T, Abi&gt;&) noexcept;
102+
template&lt;class T, class Abi&gt;
103+
fixed_size_simd_mask&lt;T, simd_size_v&lt;T, Abi&gt;&gt; to_fixed_size(const simd_mask&lt;T, Abi&gt;&) noexcept;
104+
template&lt;class T, int N&gt; native_simd&lt;T&gt; to_native(const fixed_size_simd&lt;T, N&gt;&) noexcept;
105+
template&lt;class T, int N&gt; native_simd_mask&lt;T&gt; to_native(const fixed_size_simd_mask&lt;T, N&gt;&) noexcept;
106+
template&lt;class T, int N&gt; simd&lt;T&gt; to_compatible(const fixed_size_simd&lt;T, N&gt;&) noexcept;
107+
template&lt;class T, int N&gt; simd_mask&lt;T&gt; to_compatible(const fixed_size_simd_mask&lt;T, N&gt;&) noexcept;
108+
109+
template&lt;size_t... Sizes, class T, class Abi&gt;
110+
tuple&lt;simd&lt;T, simd_abi::deduce_t&lt;T, Sizes&gt;&gt;...&gt; split(const simd&lt;T, Abi&gt;&);
111+
template&lt;size_t... Sizes, class T, class Abi&gt;
112+
tuple&lt;simd_mask&lt;T, simd_mask_abi::deduce_t&lt;T, Sizes&gt;&gt;...&gt; split(const simd_mask&lt;T, Abi&gt;&);
113+
template&lt;class V, class Abi&gt;
114+
array&lt;V, simd_size_v&lt;typename V::value_type, Abi&gt; / V::size()&gt; split(const simd&lt;typename V::value_type, Abi&gt;&);
115+
template&lt;class V, class Abi&gt;
116+
array&lt;V, simd_size_v&lt;typename V::value_type, Abi&gt; / V::size()&gt; split(const simd_mask&lt;typename V::value_type, Abi&gt;&);
117+
118+
template&lt;class T, class... Abis&gt;
119+
simd&lt;T, simd_abi::deduce_t&gt;T, (simd_size_v&lt;T, Abis&gt; + ...)&gt;&gt; concat(const simd&lt;T, Abis&gt;&...);
120+
template&lt;class T, class... Abis&gt;
121+
simd_mask&lt;T, simd_abi::deduce_t&gt;T, (simd_size_v&lt;T, Abis&gt; + ...)&gt;&gt; concat(const simd_mask&lt;T, Abis&gt;&...);
122+
123+
<cxx-ref insynopsys="" to="parallel.simd.mask.reductions"></cxx-ref> reductions
124+
template&lt;class T, class Abi&gt; bool all_of(const simd_mask&lt;T, Abi&gt;&) noexcept;
125+
template&lt;class T, class Abi&gt; bool any_of(const simd_mask&lt;T, Abi&gt;&) noexcept;
126+
template&lt;class T, class Abi&gt; bool none_of(const simd_mask&lt;T, Abi&gt;&) noexcept;
127+
template&lt;class T, class Abi&gt; bool some_of(const simd_mask&lt;T, Abi&gt;&) noexcept;
128+
template&lt;class T, class Abi&gt; int popcount(const simd_mask&lt;T, Abi&gt;&) noexcept;
129+
template&lt;class T, class Abi&gt; int find_first_set(const simd_mask&lt;T, Abi&gt;&);
130+
template&lt;class T, class Abi&gt; int find_last_set(const simd_mask&lt;T, Abi&gt;&);
131+
132+
bool all_of(<em>see-below</em>) noexcept;
133+
bool any_of(<em>see-below</em>) noexcept;
134+
bool none_of(<em>see-below</em>) noexcept;
135+
bool some_of(<em>see-below</em>) noexcept;
136+
int popcount(<em>see-below</em>) noexcept;
137+
int find_first_set(<em>see-below</em>) noexcept;
138+
int find_last_set(<em>see-below</em>) noexcept;
139+
140+
<cxx-ref insynopsis="" to="parallel.simd.whereexpr"></cxx-ref> where expressions
141+
template&lt;class M, class T&gt; class const_where_expression;
142+
template&lt;class M, class T&gt; class where_expression;
143+
144+
<cxx-ref insynopsis="" to="parallel.simd.mask.where"></cxx-ref> masked assignment
145+
template&lt;class T&gt; struct nodeduce { using type = T; }; // exposition only
146+
template&lt;class T&gt; using nodeduce_t = typename nodeduce&lt;T&gt;::type; // exposition only
147+
148+
template&lt;class T, class Abi&gt;
149+
where_expression&lt;simd_mask&lt;T, Abi&gt;, simd&lt;T, Abi&gt;&gt; where(const typename simd&lt;T, Abi&gt;::mask_type&, simd&lt;T, Abi&gt;&) noexcept;
150+
151+
template&lt;class T, class Abi&gt;
152+
const_where_expression&lt;simd_mask&lt;T, Abi&gt;, simd&lt;T, Abi&gt;&gt; where(const typename simd&lt;T, Abi&gt;::mask_type&, const simd&lt;T, Abi&gt;&) noexcept;
153+
154+
template&lt;class T, class Abi&gt;
155+
where_expression&lt;simd_mask&lt;T, Abi&gt;, simd_mask&lt;T, Abi&gt;&gt; where(const nodeduce_t&lt;simd_mask&lt;T, Abit&gt;&gt;&, simd_mask&lt;T, Abi&gt;&) noexcept;
156+
157+
template&lt;class T, class Abi&gt;
158+
const_where_expression&lt;simd_mask&lt;T, Abi&gt;, simd_mask&lt;T, Abi&gt;&gt; where(const nodeduce_t&lt;simd_mask&lt;T, Abit&gt;&gt;&, const simd_mask&lt;T, Abi&gt;&) noexcept;
159+
160+
template&lt;class T&gt;
161+
const_where_expression&lt;bool, T&gt; where(<em>see-below</em> k, const T& d) noexcept;
162+
163+
<cxx-ref insynopsis="" to="parallel.simd.reductions"></cxx-ref> reductions
164+
template&lt;class T, class Abi, class BinaryOperation = plus&lt;&gt;&gt;
165+
T reduce(const simd&lt;T, Abi&gt;&, BinaryOperation = {});
166+
167+
template&lt;class M, class V, class BinaryOperation&gt;
168+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt;& x,
169+
typename V::value_type identity_element, BinaryOperation binary_op);
170+
template&lt;class M, class V&gt;
171+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt; x, plus&lt;&gt; binary_op = {});
172+
template&lt;class M, class V&gt;
173+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt; x, multiplies&lt;&gt; binary_op = {});
174+
template&lt;class M, class V&gt;
175+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt; x, bit_and&lt;&gt; binary_op = {});
176+
template&lt;class M, class V&gt;
177+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt; x, bit_or&lt;&gt; binary_op = {});
178+
template&lt;class M, class V&gt;
179+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt; x, bit_xor&lt;&gt; binary_op = {});
180+
181+
template&lt;class T, class Abi&gt; T hmin(const simd&lt;T, abi&gt;&);
182+
template&lt;class T, class Abi&gt; typename V::value_type hmin(const const_where_expression&lt;M, V&gt;&);
183+
template&lt;class T, class Abi&gt; T hmax(const simd&lt;T, abi&gt;&);
184+
template&lt;class T, class Abi&gt; typename V::value_type hmax(const const_where_expression&lt;M, V&gt;&);
185+
186+
<cxx-ref insynopsis="" to="parallel.simd.alg"></cxx-ref> algorithms
187+
template&lt;class T, class Abi&gt; simd&lt;T, Abi&gt; min(const simd&lt;T, Abi&gt;& a, const simd&lt;T, Abi&gt;& b) noexcept;
188+
template&lt;class T, class Abi&gt; simd&lt;T, Abi&gt; max(const simd&lt;T, Abi&gt;& a, const simd&lt;T, Abi&gt;& b) noexcept;
189+
template&lt;class T, class Abi&gt; simd&lt;T, Abi&gt; minmax(const simd&lt;T, Abi&gt;& a, const simd&lt;T, Abi&gt;& b) noexcept;
190+
template&lt;class T, class Abi&gt; simd&lt;T, Abi&gt; clamp(const simd&lt;T, Abi&gt;& v, const simd&lt;T, Abi&gt;& lo, const simd&lt;T, Abi&gt;& hi) noexcept;
191+
}
192+
}
193+
}
194+
</pre>
195+
</ins>
196+
197+
<p>
198+
<ins>
199+
The header <code>&lt;experimental/simd&gt;</code> defines class templates, tag types, trait types, and function templates for element-wise operations on data-parallel objects.
200+
</ins>
201+
</p>
202+
</cxx-section>
203+
204+
<cxx-section id="parallel.simd.overview">
205+
</cxx-section>
206+
</cxx-clause>
207+

main.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<cxx-include href="exceptions.html"></cxx-include>
1717
<cxx-include href="algorithms.html"></cxx-include>
1818
<cxx-include href="task_block.html"></cxx-include>
19+
<cxx-include href="data_parallel_types.html"></cxx-include>
1920
<cxx-publish-button source="https://github.com/cplusplus/parallelism-ts"></cxx-publish-button>
2021

2122
</body>

0 commit comments

Comments
 (0)