Skip to content

P2876R3 Proposal to extend std::simd with more constructors and accessors #7997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions source/numerics.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19095,6 +19095,8 @@
template<size_t UBytes, class UAbi>
constexpr explicit basic_simd_mask(const basic_simd_mask<UBytes, UAbi>&) noexcept;
template<class G> constexpr explicit basic_simd_mask(G&& gen) noexcept;
constexpr basic_simd_mask(const bitset<size()>& b) noexcept;
constexpr explicit basic_simd_mask(@\libconcept{unsigned_integral}@ auto val) noexcept;

// \ref{simd.mask.subscr}, \tcode{basic_simd_mask} subscript operators
constexpr value_type operator[](@\exposid{simd-size-type}@) const;
Expand All @@ -19109,6 +19111,10 @@
template<class U, class A>
constexpr explicit(sizeof(U) != Bytes) operator basic_simd<U, A>() const noexcept;

// \ref{simd.mask.namedconv}, \tcode{basic_simd_mask} named type convertors
constexpr bitset<size()> to_bitset() const noexcept;
constexpr unsigned long long to_ullong() const;

// \ref{simd.mask.binary}, \tcode{basic_simd_mask} binary operators
friend constexpr basic_simd_mask
operator&&(const basic_simd_mask&, const basic_simd_mask&) noexcept;
Expand Down Expand Up @@ -19241,6 +19247,31 @@
\tcode{gen} is invoked exactly once for each $i$, in increasing order of $i$.
\end{itemdescr}

\begin{itemdecl}
constexpr basic_simd_mask(const bitset<size()>& b) noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Initializes the $i^\text{th}$ element with \tcode{b[$i$]} for all $i$ in the
range \range{0}{size()}.
\end{itemdescr}

\begin{itemdecl}
constexpr explicit basic_simd_mask(@\libconcept{unsigned_integral}@ auto val) noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Initializes the first $M$ elements to the corresponding bit values in
\tcode{val}, where $M$ is the smaller of \tcode{size()} and the number of bits in
the value representation \iref{basic.types.general} of the type of \tcode{val}. If
$M$ is less than \tcode{size()}, the remaining elements are initialized to
zero.
\end{itemdescr}

\rSec3[simd.mask.subscr]{\tcode{basic_simd_mask} subscript operator}

\begin{itemdecl}
Expand Down Expand Up @@ -19299,6 +19330,43 @@
\tcode{static_cast<U>(operator[]($i$))}.
\end{itemdescr}

\rSec3[simd.mask.namedconv]{\tcode{basic_simd_mask} named conversion operators}

\begin{itemdecl}
constexpr bitset<size()> to_bitset() const noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
A \tcode{bitset<size()>} object where the $i^\text{th}$ element is initialized to
\tcode{operator[]($i$)} for all $i$ in the range \range{0}{size()}.
\end{itemdescr}

\begin{itemdecl}
constexpr unsigned long long to_ullong() const;
\end{itemdecl}

\begin{itemdescr}
\pnum
Let $N$ be the width of \tcode{unsigned long long}.

\pnum
\expects
\begin{itemize}
\item \tcode{size()} $\le N$, or
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you've decided to change what is in the paper via fix-up here. We have tons of wording precedent for

x < y is true

... as dumb as it sounds, but to my knowledge, we don't have any kind of formal decision that would eliminate this. LWG approved this wording, so we may as well keep it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it because that's more consistent with what's in [simd] (i.e., what we did for P1928). I wanted to call that out as a questionable commit / a suggestion and forgot about it.
Better to drop it then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot answer with authority, but we have procedures in https://github.com/cplusplus/draft/wiki/Applying-papers-to-the-Working-Draft for this. To my understanding, we only use commits in the same PR for typo repairs and other things that are broken in the paper wording.

If there are stylistic/consistency improvements, those tend to go onto into a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the commit from my Motions 10–13 PR and will submit a separate PR.

\item for all $i$ in the range \range{$N$}{size()}, \tcode{operator[]($i$)} returns \tcode{false}.
\end{itemize}

\pnum
\returns
The integral value corresponding to the bits in \tcode{*this}.

\pnum
\throws
Nothing.
\end{itemdescr}

\rSec2[simd.mask.nonmembers]{Non-member operations}

\rSec3[simd.mask.binary]{\tcode{basic_simd_mask} binary operators}
Expand Down
2 changes: 1 addition & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@
#define @\defnlibxname{cpp_lib_shared_ptr_weak_type}@ 201606L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_shared_timed_mutex}@ 201402L // also in \libheader{shared_mutex}
#define @\defnlibxname{cpp_lib_shift}@ 202202L // also in \libheader{algorithm}
#define @\defnlibxname{cpp_lib_simd}@ 202502L // also in \libheader{simd}
#define @\defnlibxname{cpp_lib_simd}@ 202506L // also in \libheader{simd}
#define @\defnlibxname{cpp_lib_simd_complex}@ 202502L // also in \libheader{simd}
#define @\defnlibxname{cpp_lib_smart_ptr_for_overwrite}@ 202002L // also in \libheader{memory}
#define @\defnlibxname{cpp_lib_smart_ptr_owner_equality}@ 202306L // also in \libheader{memory}
Expand Down