IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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 struct

ReduceOp

struct ReduceOp

Represents reduction operations for parallel reduction algorithms.

This struct defines different reduction operations that can be performed across multiple threads in parallel. These operations are commonly used in parallel reduction algorithms on GPUs.

Implemented traits

AnyType, Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable, Writable

comptime members

ADD

comptime ADD = ReduceOp(Int(0))

Addition reduction operation.

Combines values by adding them together.

AND

comptime AND = ReduceOp(Int(3))

Bitwise AND reduction operation.

Performs bitwise AND across all inputs.

MAX

comptime MAX = ReduceOp(Int(2))

Maximum reduction operation.

Finds the maximum value across all inputs.

MIN

comptime MIN = ReduceOp(Int(1))

Minimum reduction operation.

Finds the minimum value across all inputs.

OR

comptime OR = ReduceOp(Int(4))

Bitwise OR reduction operation.

Performs bitwise OR across all inputs.

XOR

comptime XOR = ReduceOp(Int(5))

Bitwise XOR reduction operation.

Performs bitwise XOR across all inputs.

Methods

__eq__

def __eq__(self, other: Self) -> Bool

Tests if two ReduceOp instances are equal.

Args:

  • other (Self): The ReduceOp instance to compare against.

Returns:

Bool: True if the reduction operations are equal, False otherwise.

__is__

def __is__(self, other: Self) -> Bool

Tests if two ReduceOp instances are identical.

Args:

  • other (Self): The ReduceOp instance to compare against.

Returns:

Bool: True if the reduction operations are identical, False otherwise.

write_to

def write_to(self, mut writer: T)

Writes a string representation of the reduction operation.

Args:

  • writer (T): The object to write to.

write_repr_to

def write_repr_to(self, mut writer: T)

Writes a string representation of the reduction operation.

Args:

  • writer (T): The object to write to.

mnemonic

def mnemonic(self) -> StaticString

Returns the mnemonic string for the reduction operation.

Returns:

StaticString: A string literal containing the reduction operation mnemonic.

Was this page helpful?