Skip to content
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

Documents arithmetic reduction semantics #391

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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: 56 additions & 12 deletions coresimd/ppsv/api/arithmetic_reductions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@ macro_rules! impl_arithmetic_reductions {
impl $id {
/// Lane-wise addition of the vector elements.
///
/// FIXME: document guarantees with respect to:
/// * integers: overflow behavior
/// * floats: order and NaNs
/// The intrinsic performs a tree-reduction of the vector elements.
/// That is, for an 8 element vector:
///
/// > ((x0 + x1) + (x2 + x3)) + ((x4 + x5) + (x6 + x7))
///
/// # Integer vectors
///
/// If an operation overflows it returns the mathematical result
/// modulo `2^n` where `n` is the number of times it overflows.
///
/// # Floating-point vectors
///
/// If one of the vector element is `NaN` the reduction returns
/// `NaN`.
#[cfg(not(target_arch = "aarch64"))]
#[inline]
pub fn sum(self) -> $elem_ty {
Expand All @@ -19,9 +30,20 @@ macro_rules! impl_arithmetic_reductions {
}
/// Lane-wise addition of the vector elements.
///
/// FIXME: document guarantees with respect to:
/// * integers: overflow behavior
/// * floats: order and NaNs
/// The intrinsic performs a tree-reduction of the vector elements.
/// That is, for an 8 element vector:
///
/// > ((x0 + x1) + (x2 + x3)) + ((x4 + x5) + (x6 + x7))
///
/// # Integer vectors
///
/// If an operation overflows it returns the mathematical result
/// modulo `2^n` where `n` is the number of times it overflows.
///
/// # Floating-point vectors
///
/// If one of the vector element is `NaN` the reduction returns
/// `NaN`.
#[cfg(target_arch = "aarch64")]
#[inline]
pub fn sum(self) -> $elem_ty {
Expand All @@ -36,9 +58,20 @@ macro_rules! impl_arithmetic_reductions {

/// Lane-wise multiplication of the vector elements.
///
/// FIXME: document guarantees with respect to:
/// * integers: overflow behavior
/// * floats: order and NaNs
/// The intrinsic performs a tree-reduction of the vector elements.
/// That is, for an 8 element vector:
///
/// > ((x0 * x1) * (x2 * x3)) * ((x4 * x5) * (x6 * x7))
///
/// # Integer vectors
///
/// If an operation overflows it returns the mathematical result
/// modulo `2^n` where `n` is the number of times it overflows.
///
/// # Floating-point vectors
///
/// If one of the vector element is `NaN` the reduction returns
/// `NaN`.
#[cfg(not(target_arch = "aarch64"))]
#[inline]
pub fn product(self) -> $elem_ty {
Expand All @@ -49,9 +82,20 @@ macro_rules! impl_arithmetic_reductions {
}
/// Lane-wise multiplication of the vector elements.
///
/// FIXME: document guarantees with respect to:
/// * integers: overflow behavior
/// * floats: order and NaNs
/// The intrinsic performs a tree-reduction of the vector elements.
/// That is, for an 8 element vector:
///
/// > ((x0 * x1) * (x2 * x3)) * ((x4 * x5) * (x6 * x7))
///
/// # Integer vectors
///
/// If an operation overflows it returns the mathematical result
/// modulo `2^n` where `n` is the number of times it overflows.
///
/// # Floating-point vectors
///
/// If one of the vector element is `NaN` the reduction returns
/// `NaN`.
#[cfg(target_arch = "aarch64")]
#[inline]
pub fn product(self) -> $elem_ty {
Expand Down
34 changes: 29 additions & 5 deletions coresimd/ppsv/api/minmax_reductions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ macro_rules! impl_minmax_reductions {
impl $id {
/// Largest vector value.
///
/// FIXME: document behavior for float vectors with NaNs.
/// # Floating-point behvior
///
/// If the vector contains only `NaN` values,
/// the result is a `NaN`.
///
/// Otherwise, if the vector contains `NaN` values, either the
/// largest element of the vector or a `NaN` is returned.
#[cfg(not(target_arch = "aarch64"))]
#[inline]
pub fn max(self) -> $elem_ty {
Expand All @@ -15,9 +21,16 @@ macro_rules! impl_minmax_reductions {
simd_reduce_max(self)
}
}

/// Largest vector value.
///
/// FIXME: document behavior for float vectors with NaNs.
/// # Floating-point behvior
///
/// If the vector contains only `NaN` values,
/// the result is a `NaN`.
///
/// Otherwise, if the vector contains `NaN` values, either the
/// largest element of the vector or a `NaN` is returned.
#[cfg(target_arch = "aarch64")]
#[allow(unused_imports)]
#[inline]
Expand All @@ -35,7 +48,13 @@ macro_rules! impl_minmax_reductions {

/// Smallest vector value.
///
/// FIXME: document behavior for float vectors with NaNs.
/// # Floating-point behvior
///
/// If the vector contains only `NaN` values,
/// the result is a `NaN`.
///
/// Otherwise, if the vector contains `NaN` values, either the
/// smallest element of the vector or a `NaN` is returned.
#[cfg(not(target_arch = "aarch64"))]
#[inline]
pub fn min(self) -> $elem_ty {
Expand All @@ -44,9 +63,14 @@ macro_rules! impl_minmax_reductions {
simd_reduce_min(self)
}
}
/// Smallest vector value.

/// # Floating-point behvior
///
/// If the vector contains only `NaN` values,
/// the result is a `NaN`.
///
/// FIXME: document behavior for float vectors with NaNs.
/// Otherwise, if the vector contains `NaN` values, either the
/// smallest element of the vector or a `NaN` is returned.
#[cfg(target_arch = "aarch64")]
#[allow(unused_imports)]
#[inline]
Expand Down
Loading