asc_all

产品支持情况

  • Ascend 950PR/Ascend 950DT:支持
  • Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持
  • Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持
  • Atlas 200I/500 A2 推理产品:不支持
  • Atlas 推理系列产品AI Core:不支持
  • Atlas 推理系列产品Vector Core:不支持
  • Atlas 训练系列产品:不支持

功能说明

判断是否所有活跃线程的输入均不为0。

当Warp内所有活跃线程执行本接口后,对所有活跃线程的输入操作数predicate进行判断,所有活跃线程的predicate均不为0,返回1,否则返回0。Warp内所有活跃线程返回相同的结果。

函数原型

inline int32_t asc_all(int32_t predicate)

参数说明

表1 参数说明

参数名 输入/输出 描述
predicate 输入 操作数。

返回值说明

当Warp内所有活跃线程的输入均不为0,返回1,否则返回0。

约束说明

需要包含的头文件

使用该接口需要包含"simt_api/device_warp_functions.h"头文件。

#include "simt_api/device_warp_functions.h"

调用示例

  • SIMT编程场景:

    __global__ __launch_bounds__(1024) void kernel_asc_all(int32_t* dst)
    {
        int idx = threadIdx.x + blockIdx.x * blockDim.x;
        int32_t lane_id= idx % 32;
        dst[idx] = asc_all(lane_id); // 返回值为0
    }
    
  • SIMD与SIMT混合编程场景:

    __simt_vf__ __launch_bounds__(1024) inline void kernel_asc_all(__gm__ int32_t* dst)
    {
        // asc_vf_call参数:dim3{1024, 1, 1}
        int idx = threadIdx.x + blockIdx.x * blockDim.x;
        int32_t lane_id = idx % 32;
        dst[idx] = asc_all(lane_id); // 返回值为0
    }