Skip to content

call for new feature similar to function __clz() in cuda #43

@YilingQiao

Description

@YilingQiao

Similar to this issue taichi-dev/taichi#8212

We are implementing a data structure for simulation and encountered the same problem as described in this issue. Could you please take a look and see if we can simply add that? Thank you!

In taichi, the implementation is quite brute force

def clz(a):
    """Count the number of leading zeros for a 32bit integer"""

    def _clz(x):
        for i in range(32):
            if 2**i > x:
                return 32 - i
        return 0

    return _unary_operation(_ti_core.expr_clz, _clz, a)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions