For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
match_all
def match_all[dtype: DType, //, mask_type: DType = DType.uint32 if (DefaultMaxPlugin if (xor _index_lt[PluginSelector._find[_current_target(), 0, trap_if_missing=False](), 0](), True) else [PluginSelector._find[_current_target(), 0, trap_if_missing=False]()] if (xor _index_lt[PluginSelector._find[_current_target(), 0, trap_if_missing=False](), 3](), True) else CudaMaxPlugin, HipMaxPlugin, MetalMaxPlugin[PluginSelector._find[_current_target(), 0, trap_if_missing=False]()] if identical(_NoMaxPlugin if (xor _index_lt[TargetPluginSelector._find[0](), len(#kgen.get_target_plugin<apply(:!lit.generator<() -> !kgen.target> @std::@sys::@info::@"_current_target()"), :param_list<trait<@std::@traits::@anytype::@AnyType>> [@max::@_plugin::@_impl::@_NoMaxPlugin]>)](), True) else #kgen.get_target_plugin<apply(:!lit.generator<() -> !kgen.target> @std::@sys::@info::@"_current_target()"), :param_list<trait<@std::@traits::@anytype::@AnyType>> [@max::@_plugin::@_impl::@_NoMaxPlugin]>[TargetPluginSelector._find[0]()](MaxPlugin), _NoMaxPlugin) else _NoMaxPlugin if (xor _index_lt[TargetPluginSelector._find[0](), len(#kgen.get_target_plugin<apply(:!lit.generator<() -> !kgen.target> @std::@sys::@info::@"_current_target()"), :param_list<trait<@std::@traits::@anytype::@AnyType>> [@max::@_plugin::@_impl::@_NoMaxPlugin]>)](), True) else #kgen.get_target_plugin<apply(:!lit.generator<() -> !kgen.target> @std::@sys::@info::@"_current_target()"), :param_list<trait<@std::@traits::@anytype::@AnyType>> [@max::@_plugin::@_impl::@_NoMaxPlugin]>[TargetPluginSelector._find[0]()](MaxPlugin).HookFor[CompilationTarget(Int(0))].warp_size <= Int(32)) else DType.uint64](value: Scalar[dtype]) -> Scalar[mask_type]
Returns the warp's active-lane mask if all lanes share value, else 0.
When every active lane holds the same bits as the calling lane, returns the
mask of those lanes (so a non-zero result is the "all agree" predicate that
NVIDIA's match.all.sync also exposes); otherwise returns 0. The comparison
is on the bits, so 0.0 and -0.0 are treated as different. This is the
dual of match_any: it reports warp-wide agreement on a key.
All WARP_SIZE lanes must reach the call converged.
Example:
from max.gpu.primitives.warp import match_all
# `agreed` is non-zero (the active-lane mask) iff every lane passed the
# same `key`.
var key = Int32(42)
var agreed = match_all(key)Constraints:
Requires a GPU target with warp shuffles. dtype must be a 32- or
64-bit type and mask_type must be DType.uint32 or DType.uint64
(NVIDIA returns a 32-bit mask, so mask_type must be DType.uint32
there).
Parameters:
- โdtype (
DType): The element type ofvalue(inferred from the argument). - โmask_type (
DType): The lane-mask return type,DType.uint32orDType.uint64(defaults to the type matchingWARP_SIZE).
Args:
- โvalue (
Scalar[dtype]): The calling lane's value to compare against the rest of the warp.
Returns:
Scalar[mask_type]: A mask_type lane mask of the active lanes when they all hold a
bit-equal value, otherwise 0.