Skip to content

Commit 8d9cea7

Browse files
committed
Introduce [parallel.simd.reductions]
1 parent b14d51b commit 8d9cea7

File tree

1 file changed

+215
-0
lines changed

1 file changed

+215
-0
lines changed

data_parallel_types.html

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,221 @@ <h1><ins><code>simd</code> compare operators</ins></h1>
17671767
</cxx-throws>
17681768
</cxx-function>
17691769
</cxx-section>
1770+
1771+
<cxx-section id="parallel.simd.reductions">
1772+
<cxx-function>
1773+
<cxx-signature><ins>
1774+
template&lt;class T, class Abi, class BinaryOperation = plus&lt;&gt;&gt;
1775+
T reduce(const simd&lt;T, Abi&gt;& x, BinaryOperation binary_op = {});
1776+
</ins></cxx-signature>
1777+
1778+
<cxx-requires>
1779+
<ins>
1780+
<code>binary_op</code> shall be callable with two arguments of type <code>T</code> returning <code>T</code>, or callable with two arguments of type <code>simd&lt;T, A1&gt;</code> returning <code>simd&lt;T, A1&gt;</code> for every <code>A1</code> that is an ABI tag type.
1781+
</ins>
1782+
</cxx-requires>
1783+
1784+
<cxx-returns>
1785+
<ins>
1786+
<code><em>GENERALIZED_SUM</em>(binary_op, x.data[i], ...)</code> for all <code>i</code> &#8714; <code>[0, size())</code>.
1787+
</ins>
1788+
</cxx-returns>
1789+
1790+
<cxx-throws>
1791+
<ins>
1792+
Any exception thrown from <code>binary_op</code>.
1793+
</ins>
1794+
</cxx-throws>
1795+
1796+
<p>
1797+
<cxx-note>
1798+
<ins>
1799+
This overload of <code>reduce</code> does not require an initial value because <code>x</code> is guaranteed to be non-empty.
1800+
</ins>
1801+
</cxx-note>
1802+
</p>
1803+
</cxx-function>
1804+
1805+
<cxx-function>
1806+
<cxx-signature><ins>
1807+
template&lt;class M, class V, class BinaryOperation&gt;
1808+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt;& x, typename V::value_type identity_element,
1809+
BinaryOperation binary_op);
1810+
</ins></cxx-signature>
1811+
1812+
<cxx-requires>
1813+
<ins>
1814+
<code>binary_op</code> shall be callable with two arguments of type <code>T</code> returning <code>T</code>, or callable with two arguments of type <code>simd&lt;T, A1&gt;</code> returning <code>simd&lt;T, A1&gt;</code> for every <code>A1</code> that is an ABI tag type. The results of <code>binary_op(identity_element, x)</code> and <code>binary_op(x, identity_element)</code> shall be equal to <code>x</code> for all finite values <code>x</code> representable by <code>V::value_type</code>.
1815+
</ins>
1816+
</cxx-requires>
1817+
1818+
<cxx-returns>
1819+
<ins>
1820+
If <code>none_of(x.mask)</code>, returns <code>identity_element</code>. Otherwise, returns <code><em>GENERALIZED_SUM</em>(binary_op, x.data[i], ...)</code> for all <code>i</code> &#8714; {<em>j</em> &#8714; &#8469;<sub>0</sub> &#8739; <em>j</em> &lt; <code>M::size()</code> &#8896; <code>mask[</code><em>j</em><code>]</code> }.
1821+
</ins>
1822+
</cxx-returns>
1823+
1824+
<cxx-throws>
1825+
<ins>
1826+
Any exception thrown from <code>binary_op</code>.
1827+
</ins>
1828+
</cxx-throws>
1829+
</cxx-function>
1830+
1831+
<cxx-function>
1832+
<cxx-signature><ins>
1833+
template&lt;class M, class V&gt;
1834+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt;& x, plus&lt;&gt; binary_op = {});
1835+
</ins></cxx-signature>
1836+
1837+
<cxx-returns>
1838+
<ins>
1839+
If <code>none_of(x.mask)</code>, returns <code>0</code>. Otherwise, returns <code><em>GENERALIZED_SUM</em>(binary_op, x.data[i], ...)</code> for all <code>i</code> &#8714; {<em>j</em> &#8714; &#8469;<sub>0</sub> &#8739; <em>j</em> &lt; <code>M::size()</code> &#8896; <code>mask[</code><em>j</em><code>]</code> }.
1840+
</ins>
1841+
</cxx-returns>
1842+
1843+
<cxx-throws>
1844+
<ins>
1845+
Nothing.
1846+
</ins>
1847+
</cxx-throws>
1848+
</cxx-function>
1849+
1850+
<cxx-function>
1851+
<cxx-signature><ins>
1852+
template&lt;class M, class V&gt;
1853+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt;& x, multiplies&lt;&gt; binary_op = {});
1854+
</ins></cxx-signature>
1855+
1856+
<cxx-returns>
1857+
<ins>
1858+
If <code>none_of(x.mask)</code>, returns <code>1</code>. Otherwise, returns <code><em>GENERALIZED_SUM</em>(binary_op, x.data[i], ...)</code> for all <code>i</code> &#8714; {<em>j</em> &#8714; &#8469;<sub>0</sub> &#8739; <em>j</em> &lt; <code>M::size()</code> &#8896; <code>mask[</code><em>j</em><code>]</code> }.
1859+
</ins>
1860+
</cxx-returns>
1861+
1862+
<cxx-throws>
1863+
<ins>
1864+
Nothing.
1865+
</ins>
1866+
</cxx-throws>
1867+
</cxx-function>
1868+
1869+
<cxx-function>
1870+
<cxx-signature><ins>
1871+
template&lt;class M, class V&gt;
1872+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt;& x, bit_and&lt;&gt; binary_op = {});
1873+
</ins></cxx-signature>
1874+
1875+
<cxx-requires>
1876+
<ins>
1877+
<code>is_integral_v&lt;V::value_type&gt;</code> is <code>true</code>.
1878+
</ins>
1879+
</cxx-requires>
1880+
1881+
<cxx-returns>
1882+
<ins>
1883+
If <code>none_of(x.mask)</code>, returns <code>~V::value_type()</code>. Otherwise, returns <code><em>GENERALIZED_SUM</em>(binary_op, x.data[i], ...)</code> for all <code>i</code> &#8714; {<em>j</em> &#8714; &#8469;<sub>0</sub> &#8739; <em>j</em> &lt; <code>M::size()</code> &#8896; <code>mask[</code><em>j</em><code>]</code> }.
1884+
</ins>
1885+
</cxx-returns>
1886+
1887+
<cxx-throws>
1888+
<ins>
1889+
Nothing.
1890+
</ins>
1891+
</cxx-throws>
1892+
</cxx-function>
1893+
1894+
<cxx-function>
1895+
<cxx-signature><ins>
1896+
template&lt;class M, class V&gt;
1897+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt;& x, bit_or&lt;&gt; binary_op = {});
1898+
template&lt;class M, class V&gt;
1899+
typename V::value_type reduce(const const_where_expression&lt;M, V&gt;& x, bit_xor&lt;&gt; binary_op = {});
1900+
</ins></cxx-signature>
1901+
1902+
<cxx-requires>
1903+
<ins>
1904+
<code>is_integral_v&lt;V::value_type&gt;</code> is <code>true</code>.
1905+
</ins>
1906+
</cxx-requires>
1907+
1908+
<cxx-returns>
1909+
<ins>
1910+
If <code>none_of(x.mask)</code>, returns <code>0</code>. Otherwise, returns <code><em>GENERALIZED_SUM</em>(binary_op, x.data[i], ...)</code> for all <code>i</code> &#8714; {<em>j</em> &#8714; &#8469;<sub>0</sub> &#8739; <em>j</em> &lt; <code>M::size()</code> &#8896; <code>mask[</code><em>j</em><code>]</code> }.
1911+
</ins>
1912+
</cxx-returns>
1913+
1914+
<cxx-throws>
1915+
<ins>
1916+
Nothing.
1917+
</ins>
1918+
</cxx-throws>
1919+
</cxx-function>
1920+
1921+
<cxx-function>
1922+
<cxx-signature><ins>template&lt;class T, class Abi&gt; T hmin(const simd&lt;T, Abi&gt;& x);</ins></cxx-signature>
1923+
1924+
<cxx-returns>
1925+
<ins>
1926+
The value of an element <code>x[j]</code> for which <code>x[j] &lt;= x[i]</code> for all <code>i</code> &#8714; <code>[0, size())</code>.
1927+
</ins>
1928+
</cxx-returns>
1929+
1930+
<cxx-throws>
1931+
<ins>
1932+
Nothing.
1933+
</ins>
1934+
</cxx-throws>
1935+
</cxx-function>
1936+
1937+
<cxx-function>
1938+
<cxx-signature><ins>template&lt;class T, class V&gt; typename V::value_type hmin(const const_where_expression&lt;M, V&gt;& x);</ins></cxx-signature>
1939+
1940+
<cxx-returns>
1941+
<ins>
1942+
If <code>none_of(x.mask)</code>, the return value is <code>numeric_limits&lt;V::value_type&gt;::max()</code>. Otherwise, returns the value of an element <code>x.data[j]</code> for which <code>x.mask[j] == true</code> and <code>x.data[j] &lt;= x.data[i]</code> for all <code>i</code> &#8714; {<em>j</em> &#8714; &#8469;<sub>0</sub> &#8739; <em>j</em> &lt; <code>M::size()</code> &#8896; <code>mask[</code><em>j</em><code>]</code> }.
1943+
</ins>
1944+
</cxx-returns>
1945+
1946+
<cxx-throws>
1947+
<ins>
1948+
Nothing.
1949+
</ins>
1950+
</cxx-throws>
1951+
</cxx-function>
1952+
1953+
<cxx-function>
1954+
<cxx-signature><ins>template&lt;class T, class Abi&gt; T hmax(const simd&lt;T, Abi&gt;& x);</ins></cxx-signature>
1955+
1956+
<cxx-returns>
1957+
<ins>
1958+
The value of an element <code>x[j]</code> for which <code>x[j] &gt;= x[i]</code> for all <code>i</code> &#8714; <code>[0, size())</code>.
1959+
</ins>
1960+
</cxx-returns>
1961+
1962+
<cxx-throws>
1963+
<ins>
1964+
Nothing.
1965+
</ins>
1966+
</cxx-throws>
1967+
</cxx-function>
1968+
1969+
<cxx-function>
1970+
<cxx-signature><ins>template&lt;class T, class V&gt; typename V::value_type hmax(const const_where_expression&lt;M, V&gt;& x);</ins></cxx-signature>
1971+
1972+
<cxx-returns>
1973+
<ins>
1974+
If <code>none_of(x.mask)</code>, the return value is <code>numeric_limits&lt;V::value_type&gt;::lowest()</code>. Otherwise, returns the value of an element <code>x.data[j]</code> for which <code>x.mask[j] == true</code> and <code>x.data[j] &gt;= x.data[i]</code> for all <code>i</code> &#8714; {<em>j</em> &#8714; &#8469;<sub>0</sub> &#8739; <em>j</em> &lt; <code>M::size()</code> &#8896; <code>mask[</code><em>j</em><code>]</code> }.
1975+
</ins>
1976+
</cxx-returns>
1977+
1978+
<cxx-throws>
1979+
<ins>
1980+
Nothing.
1981+
</ins>
1982+
</cxx-throws>
1983+
</cxx-function>
1984+
</cxx-section>
17701985
</cxx-section>
17711986
</cxx-section>
17721987
</cxx-clause>

0 commit comments

Comments
 (0)