CANN/asc-devkit:remainderf浮点余数函数

发布时间:2026/7/17 17:44:19
CANN/asc-devkit:remainderf浮点余数函数 remainderf【免费下载链接】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 训练系列产品不支持功能说明获取输入数据x除以y的余数。求余数时商取最接近x除以y浮点数结果的整数当x除以y的浮点数结果与左右最接近的整数距离相等时商取偶数。函数原型inline float remainderf(float x, float y)参数说明表1参数说明参数名输入/输出描述x输入源操作数。y输入源操作数。返回值说明输入数据x除以y的余数。y为0时返回值为nan。x为inf或-inf时返回值为nan。x为有限数y为inf或-inf时返回值为x。xy任意一个为nan时返回值为nan。约束说明无需要包含的头文件使用该接口需要包含simt_api/math_functions.h头文件。#include simt_api/math_functions.h调用示例SIMT编程场景__global__ __launch_bounds__(256) void compute_remainderf(float *result, const float *x, const float *y, uint32_t count) { const uint32_t idx blockIdx.x * blockDim.x threadIdx.x; if (idx count) { return; } result[idx] remainderf(x[idx], y[idx]); }SIMD与SIMT混合编程场景__simt_vf__ __launch_bounds__(256) inline void compute_remainderf_vf(__gm__ float *result, __gm__ const float *x, __gm__ const float *y, uint32_t count) { const uint32_t idx blockIdx.x * blockDim.x threadIdx.x; if (idx count) { return; } result[idx] remainderf(x[idx], y[idx]); } __global__ __vector__ void run_remainderf(__gm__ float *result, __gm__ const float *x, __gm__ const float *y, uint32_t count) { asc_vf_callcompute_remainderf_vf(dim3(256), result, x, y, count); }输入输出示例如下x0.25, 0.75, 1.25, 1.75 y1.25, 2.25, 3.25, 4.25 result: 0.25 0.75 1.25 1.75【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考