GetBitCount
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
√ |
|
x |
|
x |
Function Usage
Obtains the number of 0s or 1s in a binary number of the uint64_t type.
Prototype
1 2 | template <int countValue> __aicore__ inline int64_t GetBitCount(uint64_t valueIn) |
Parameters
Parameter |
Description |
|---|---|
countValue |
0 or 1 to be counted. Enter 0 or 1. |
Parameter |
Input/Output |
Description |
|---|---|---|
valueIn |
Input |
A binary number. |
Returns
Number of 0s or 1s in valueIn.
Constraints
None
Example
1 2 3 4 | uint64_t valueIn = 0xffff; // There are 16 1s in the binary format. constexpr int countValue = 1; // Count the number of 1s in the binary format of valueIn. // Output (oneCount): 16 int64_t oneCount = AscendC::GetBitCount<countValue>(valueIn); |
Parent topic: Scalar Computation