CANN/asc-devkit __popc函数文档 __popc【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit产品支持情况Ascend 950PR/Ascend 950DT支持Atlas A3 训练系列产品/Atlas A3 推理系列产品不支持Atlas A2 训练系列产品/Atlas A2 推理系列产品不支持Atlas 200I/500 A2 推理产品不支持Atlas 推理系列产品AI Core不支持Atlas 推理系列产品Vector Core不支持Atlas 训练系列产品不支持功能说明统计输入数据从二进制的高位到低位比特位为1的数量。函数原型int __popc(unsigned int x)int __popc(unsigned long long x)int __popc(unsigned long x)参数说明表1参数说明参数名输入/输出描述x输入源操作数。返回值说明输入数据二进制中比特位为1的数量。约束说明无需要包含的头文件使用该接口需要包含simt_api/device_functions.h头文件。#include simt_api/device_functions.h调用示例SIMT编程场景__global__ __launch_bounds__(1024) void KernelPopc(int* dst, unsigned int* x) { int idx threadIdx.x blockIdx.x * blockDim.x; dst[idx] __popc(x[idx]); }__global__ __launch_bounds__(1024) void KernelPopc(int* dst, unsigned long long* x) { int idx threadIdx.x blockIdx.x * blockDim.x; dst[idx] __popc(x[idx]); }SIMD与SIMT混合编程场景__simt_vf__ __launch_bounds__(1024) inline void KernelPopc(__gm__ int* dst, __gm__ unsigned int* x) { int idx threadIdx.x blockIdx.x * blockDim.x; dst[idx] __popc(x[idx]); }__simt_vf__ __launch_bounds__(1024) inline void KernelPopc(__gm__ int* dst, __gm__ unsigned long long* x) { int idx threadIdx.x blockIdx.x * blockDim.x; dst[idx] __popc(x[idx]); }【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考