Skip to content

Commit 9e15031

Browse files
committed
Introduce [parallel.simd.overview]
1 parent d6a5ee7 commit 9e15031

File tree

1 file changed

+200
-1
lines changed

1 file changed

+200
-1
lines changed

data_parallel_types.html

Lines changed: 200 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,206 @@ <h1><ins>Class templates <code>const_where_expression</code> and <code>where_exp
825825
</cxx-function>
826826
</cxx-section>
827827

828-
<cxx-section id="parallel.simd.overview">
828+
<cxx-section id="parallel.simd.class">
829+
<h1><ins>Class template <code>simd</code></ins></h1>
830+
831+
<cxx-section id="parallel.simd.overview">
832+
<h1><ins>Class template <code>simd</code> overview</ins></h1>
833+
834+
<ins>
835+
<pre>
836+
namespace std::experimental {
837+
inline namespace parallelism_v2 {
838+
template&lt;class T, class Abi&gt; class simd {
839+
public:
840+
using value_type = T;
841+
using reference = <em>see-below</em>;
842+
using mask_type = simd_mask&lt;T, Abi&gt;
843+
using abi_type = Abi;
844+
845+
static constexpr size_t size() noexcept;
846+
847+
simd() = default;
848+
849+
// implicit conversion constructor
850+
template&lt;class U&gt; simd(const simd&lt;U, simd_abi::fixed_size&lt;size()&gt;&gt;&);
851+
852+
// implicit broadcast constructor (see below for constraints)
853+
template&lt;class U&gt; simd(U&& value);
854+
855+
// generator constructor (see below for constraints)
856+
template&lt;class G&gt; explicit simd(G&& gen);
857+
858+
// load constructor
859+
template&lt;class U, class Flags&gt; simd(const U* mem, Flags f);
860+
861+
<cxx-ref insynopsis="" to="parallel.simd.load"></cxx-ref> loads
862+
template&lt;class U, class Flags&gt; copy_from(const U* mem, Flags f);
863+
864+
<cxx-ref insynopsis="" to="parallel.simd.store"></cxx-ref> stores
865+
template&lt;class U, class Flags&gt; copy_to(U* mem, Flags f);
866+
867+
<cxx-ref insynopsis="" to="parallel.simd.subscr"></cxx-ref> scalar access
868+
reference operator[](size_t);
869+
value_type operator[](size_t) const;
870+
871+
<cxx-ref insynopsis="" to="parallel.simd.unary"></cxx-ref> unary operators
872+
simd& operator++();
873+
simd operator++(int);
874+
simd& operator--();
875+
simd operator--(int);
876+
mask_type operator!() const;
877+
simd operator~() const; // see below
878+
simd operator+() const;
879+
simd operator-() const;
880+
881+
<cxx-ref insynopsis="" to="parallel.simd.binary"></cxx-ref> binary operators
882+
friend simd operator+(const simd&, const simd&);
883+
friend simd operator-(const simd&, const simd&);
884+
friend simd operator*(const simd&, const simd&);
885+
friend simd operator/(const simd&, const simd&);
886+
friend simd operator%(const simd&, const simd&);
887+
friend simd operator&(const simd&, const simd&);
888+
friend simd operator|(const simd&, const simd&);
889+
friend simd operator^(const simd&, const simd&);
890+
friend simd operator&lt;&lt;(const simd&, const simd&);
891+
friend simd operator&gt;&gt;(const simd&, const simd&);
892+
friend simd operator&lt;&lt;(const simd&, int);
893+
friend simd operator&gt;&gt;(const simd&, int);
894+
895+
<cxx-ref insynopsis="" to="parallel.simd.cassign"></cxx-ref> compound assignment
896+
friend simd& operator+=(simd&, const simd&);
897+
friend simd& operator-=(simd&, const simd&);
898+
friend simd& operator*=(simd&, const simd&);
899+
friend simd& operator/=(simd&, const simd&);
900+
friend simd& operator%=(simd&, const simd&);
901+
friend simd& operator&=(simd&, const simd&);
902+
friend simd& operator|=(simd&, const simd&);
903+
friend simd& operator^=(simd&, const simd&);
904+
friend simd& operator&lt;&lt;=(simd&, const simd&);
905+
friend simd& operator&gt;&gt;=(simd&, const simd&);
906+
friend simd& operator&lt;&lt;=(simd&, int);
907+
friend simd& operator&gt;&gt;=(simd&, int);
908+
909+
<cxx-ref insynopsis="" to="parallel.simd.comparison"></cxx-ref> compares
910+
friend mask_type operator==(const simd&, const simd&);
911+
friend mask_type operator!=(const simd&, const simd&);
912+
friend mask_type operator&gt;=(const simd&, const simd&);
913+
friend mask_type operator&lt;=(const simd&, const simd&);
914+
friend mask_type operator&gt;(const simd&, const simd&);
915+
friend mask_type operator&lt;(const simd&, const simd&);
916+
};
917+
}
918+
}
919+
</pre>
920+
</ins>
921+
922+
<p>
923+
<ins>
924+
The class template <code>simd</code> is a data-parallel type. The width of a given <code>simd</code> specialization is a constant expression, determined by the template parameters.
925+
</ins>
926+
</p>
927+
928+
<p>
929+
<ins>
930+
Every specialization of <code>simd</code> shall be a complete type. The specialization <code>simd&lt;T, Abi&gt;</code> is supported if <code>T</code> is a vectorizable type and
931+
932+
<bl>
933+
<li>
934+
<ins>
935+
<code>Abi</code> is <code>simd_abi::scalar</code>, or
936+
</ins>
937+
</li>
938+
939+
<li>
940+
<ins>
941+
<code>Abi</code> is <code>simd_abi::fixed_size&lt;N&gt;</code>, with <code>N</code> is constrained as defined in <cxx-ref to="parallel.simd.abi"></cxx-ref>.
942+
</ins>
943+
</li>
944+
</bl>
945+
946+
<ins>
947+
If <code>Abi</code> is an extended ABI tag, it is implementation-defined whether <code>simd&lt;T, Abi&gt;</code> is supported. <cxx-note>The intent is for implementations to decide on the basis of the currently targeted system.</cxx-note>
948+
949+
<br><br>
950+
951+
If <code>simd&lt;T, Abi&gt;</code> is not supported, the specialization shall have a deleted default constructor, deleted destructor, deleted copy constructor, and deleted copy assignment.
952+
953+
<br><br>
954+
955+
<cxx-example>
956+
Consider an implementation that defines the extended ABI tags <code>__simd_x</code> and <code>__gpu_y</code>. When the compiler is invoked to translate to a machine that has support for the <code>__simd_x</code> ABI tag for all arithmetic types other than <code>long double</code> and no support for the <code>__gpu_y</code> ABI tag, then:
957+
958+
<bl>
959+
<li>
960+
<code>simd&lt;T, simd_abi::__gpu_y&gt;</code> is not supported for any <code>T</code> and has a deleted constructor.
961+
</li>
962+
963+
<li>
964+
<code>simd&lt;long double, simd_abi::__simd_x&gt;</code> is not supported and has a deleted constructor.
965+
</li>
966+
967+
<li>
968+
<code>simd&lt;double, simd_abi::__simd_x&gt;</code> is supported.
969+
</li>
970+
971+
<li>
972+
<code>simd&lt;long double, simd_abi::scalar&gt;</code> is supported.
973+
</li>
974+
</bl>
975+
</cxx-example>
976+
</ins>
977+
</ins>
978+
</p>
979+
980+
<p>
981+
<ins>
982+
Default intialization performs no initialization of the elements; value-initialization initializes each element with <code>T()</code>. <cxx-note>Thus, default initialization leaves the elements in an indeterminate state.</cxx-note>
983+
</ins>
984+
</p>
985+
986+
<cxx-function>
987+
<cxx-signature><ins>
988+
static constexpr size_t size() noexcept;</ins>
989+
</cxx-signature>
990+
991+
<cxx-returns>
992+
<ins>
993+
The width of <code>simd&lt;T, Abi&gt;</code>.
994+
</ins>
995+
</cxx-returns>
996+
</cxx-function>
997+
998+
<p>
999+
<ins>
1000+
Implementations should enable explicit conversion from and to implementation-defined types. This adds one or more of the following declarations to class <code>simd</code>:
1001+
1002+
<br>
1003+
<br>
1004+
1005+
<code><ins>explicit operator <em>implementation-defined</em>() const;</ins></code>
1006+
<code><ins>explicit simd(const <em>implementation-defined</em>& init);</ins></code>
1007+
1008+
<br>
1009+
<br>
1010+
1011+
[ <em>Example:</em>
1012+
Consider an implementation that supports the type <code>__vec4f</code> and the function <code>__vec4f</code>, <code>_vec4f_addsub(__vec4f, __vec4f)</code> for the currently targeted system.
1013+
A user may require the use of <code>_vec4f_addsub</code> for maximum performance and thus writes:
1014+
1015+
<pre><ins>
1016+
using V = simd&lt;float, simd_abi::__simd128&gt;;
1017+
V addsub(V a, V b) {
1018+
return static_cast&lt;V&gt;(_vec4f_addsub(static_cast&lt;__vec4f&gt;(a), static_cast&lt;__vec4f&gt;(b)));
1019+
}
1020+
</ins>
1021+
</pre>
1022+
<ins>
1023+
<em>&mdash; end example</em> ]
1024+
</ins>
1025+
</ins>
1026+
</p>
1027+
</cxx-section>
8291028
</cxx-section>
8301029
</cxx-clause>
8311030

0 commit comments

Comments
 (0)