asc_ballot

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

Checks whether the input of each active thread in a warp is not 0.

This API is executed by all active threads in the warp to check the input operand predicate of all active threads and returns a 32-bit unsigned integer. If predicate input by the active threads in the warp is not 0, the bit corresponding to the thread lane ID in the return value is 1. Otherwise, the bit is 0. All active threads in the warp return the same result.

Prototype

1
inline uint32_t asc_ballot(int32_t predicate)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

predicate

Input

Operand.

Returns

32-bit unsigned integer. If predicate input by the active threads in the warp is not 0, the bit corresponding to the thread lane ID in the return value is 1. Otherwise, the bit is 0.

Restrictions

None

Header File to Be Included

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

1
#include "simt_api/device_warp_functions.h"

Examples

For SIMD and SIMT programming:
1
2
3
4
5
6
7
8
__simt_vf__ __launch_bounds__(1024) inline void KernelBallot(__gm__ uint32_t* dst)
{
    // asc_vf_call parameter: dim3{1024, 1, 1}
    int idx = threadIdx.x + blockIdx.x * blockDim.x;
    int32_t laneId = idx % 32;
    uint32_t result = asc_ballot(laneId); // The return value is 0xfffffffe.
    dst[idx] = result;
}