__brev

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Reverses the bit order of the input data and returns the reversed value.

Prototype

1
unsigned int __brev(unsigned int x)
1
unsigned long long __brev(unsigned long long x)
1
unsigned long __brev(unsigned long x)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

x

Input

Source operand.

Returns

Reversed value of the bit order of the input data. If the input type is uint32_t, the nth bit of the return value corresponds to the 31–nth bit of the input data. If the input type is uint64_t, the nth bit of the return value corresponds to the 63–nth bit of the input data.

  • If x is 0 and the type is uint32_t, the return value is 0.
  • If x is 0 and the type is uint64_t, the return value is 0.
  • If x is 1 and the type is uint32_t, the return value is 2147483648.
  • If x is 1 and the type is uint64_t, the return value is 9223372036854775808.

Restrictions

For SIMT programming, this API is not supported.

Header File to Be Included

To use this API, the simt_api/device_functions.h header file must be included.

Examples

For SIMD and SIMT programming:
1
2
3
4
5
__simt_vf__ __launch_bounds__(1024) inline void KernelBrev(__gm__ unsigned int* dst, __gm__ unsigned int* x)
{
    int idx = threadIdx.x + blockIdx.x * blockDim.x;
    dst[idx] = __brev(x[idx]);
}
1
2
3
4
5
__simt_vf__ __launch_bounds__(1024) inline void KernelBrev(__gm__ unsigned long long* dst, __gm__ unsigned long long* x)
{
    int idx = threadIdx.x + blockIdx.x * blockDim.x;
    dst[idx] = __brev(x[idx]);
}