Skip to main content

## inverse_ballot

# Function inverse_ballot

Source

    pub fn inverse_ballot(value: u64) -> bool

🔬This is a nightly-only experimental API. (`stdarch_amdgpu` #149988)
Available on AMD GPU only.
Expand description

Indexes into the `value` with the current lane id and returns for each lane if the corresponding bit is set.

While `ballot` converts a `bool` to a mask, `inverse_ballot` converts a mask back to a `bool`. This means `inverse_ballot(ballot(b)) == b`. The inverse of `ballot(inverse_ballot(value)) ~= value` is not always true as inactive lanes are set to zero by `ballot`.

This intrinsic does not behave like a normal function call; it is a “convergent” operation and as such has non-standard control-flow effects which need special treatment by the language. Rust currently does not properly support convergent operations. This operation is hence provided on a best-effort basis. Using it may result in incorrect code under some circumstances.