CountLeadingZero

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Computes the number of leading 0s of an uint64_t number (number of 0s from the most significant bit to the first 1 in the binary number).

Prototype

1
__aicore__ inline int64_t CountLeadingZero(uint64_t valueIn)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

valueIn

Input

A binary number.

Returns

Return the number of leading zeros in valueIn.

Constraints

None

Example

1
2
3
uint64_t valueIn = 0x0fffffffffffffff;
// Output (ans): 4 There are four 0s from the most significant bit to the first 1 in the binary number.
int64_t ans = AscendC::CountLeadingZero(valueIn);