Skip to content

Commit

Permalink
Improve broadcast and generator constraints
Browse files Browse the repository at this point in the history
ChangeLog:

	* P1928/changelog.tex:
	* P1928/wording.tex:
  • Loading branch information
mattkretz committed Jul 16, 2024
1 parent f2032b1 commit 4b9dba6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
4 changes: 3 additions & 1 deletion P1928/changelog.tex
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ \section{Changelog}
\item Make \code{simd_flags} template arguments exposition-only.
\item Make \code{simd_alignment} \emph{not} implementation-defined.
\item Reword “supported” to “enabled or disabled”.
\item Apply improved wording from \ref{simd.overview} to \ref{simd.mask.overview}.
\item Apply improved wording from \ref{sec:simd.overview} to \ref{sec:simd.mask.overview}.
\item Add comments for LWG to address to broadcast ctor (\ref{sec:simd.ctor}).
\item Respecify generator ctor to not reuse broadcast constraint (\ref{sec:simd.ctor}).

%\todo Reorder \code{simd} and \code{simd_mask} specification in the wording (mask first).
\end{revision}
41 changes: 31 additions & 10 deletions P1928/wording.tex
Original file line number Diff line number Diff line change
Expand Up @@ -610,17 +610,35 @@
\pnum\constraints
\tcode{From} satisfies \tcode{convertible_to<value_type>}, and either
\begin{itemize}
\item \tcode{From} satisfies \tcode{\constexprwrapperlike} (\ref{simd.syn})
and the actual value of \tcode{From::value} after conversion to
\tcode{value_type} will fit into \tcode{value_type} and will produce the
original value when converted back to \tcode{decltype(From::value)}, or

\item \tcode{From} is a vectorizable type and the conversion from
\tcode{From} to \tcode{value_type} is value-preserving
(\ref{simd.general}), or

\item \tcode{From} is not an arithmetic type and does not satisfy
\tcode{\constexprwrapperlike}.
\tcode{\constexprwrapperlike}, or

\item \tcode{From} satisfies \tcode{\constexprwrapperlike} (\ref{simd.syn})
and the actual value of \tcode{From::value} after conversion to
\tcode{value_type} will fit into \tcode{value_type} and will produce the
original value when converted back to \tcode{decltype(From::value)}.
\FIXME{
A value “after conversion to \tcode{To}” is always representable by \tcode{To}.
What I actually implemented is
\tcode{!(unsigned_integral<To> \&\& From::value < decltype(From::value)()
\&\& From::value <= numeric_limits<To>::max()
\&\& From::value >= numeric_limits<To>::lowest()}
}
\INFO{
Design intent:
I'm trying to allow \tcode{1.f $\rightarrow$ int} while disallowing \tcode{1.1f $\rightarrow$
int}.
Also, if \tcode{From::value} is a UDT, e.g. fixed-point, I believe we cannot use wording
such as “value can be represented” because how can we speak about the numerical value of a
UDT? Or more importantly, how would you implement such a constraint? That'd be hand waving
at best. We can speak about the value after conversion. But then we don't know what was lost
until we convert it back.\\
Ultimately, I think we need to aim for a reasonable heuristic, no more.
}
\end{itemize}

\pnum\effects
Expand Down Expand Up @@ -661,14 +679,17 @@
\end{itemdecl}

\begin{itemdescr}
\pnum Let \tcode{From}$_i$ denote the type
\tcode{decltype(gen(integral_constant<\simdsizetype, $i$>()))}.

\pnum\constraints
\tcode{basic_simd(gen(integral_constant<\simdsizetype, $i$>()))} is well-formed
and the return type of \tcode{gen(integral_constant<\simdsizetype, $i$>())}
satisfies \tcode{convertible_to<value_type>} \foralli.
\tcode{From}$_i$ satisfies \tcode{convertible_to<value_type>} \foralli.
In addition, \foralli, if \tcode{From}$_i$ is a vectorizable type, conversion from
\tcode{From}$_i$ to \tcode{value_type} is value-preserving.

\pnum\effects
Initializes the $i^\text{th}$ element with
\tcode{gen(integral_constant<\simdsizetype, i>())} \foralli.
\tcode{static_cast<value_type>(gen(integral_constant<\simdsizetype, i>()))} \foralli.

\pnum
The calls to \tcode{gen} are unsequenced with respect to each other.
Expand Down

0 comments on commit 4b9dba6

Please sign in to comment.