什么是 "set.eq.s32.b32" 程序集?

what is "set.eq.s32.b32" assembly?

我正在尝试从 this github repo 中读取一段 CUDA 代码并遇到了这个:

__device__ __forceinline__ bool isNegativeZero(float a) {
    int ret;
    asm volatile("{  set.eq.s32.b32 %0, %1, %2;}\n" : "=r"(ret) : "f"(a), "r"(0x80000000));
    return ret;
}

我不确定汇编指令是什么,但从整个文件的上下文来看,该函数似乎不仅仅是检查浮点数是否为负零。

非常感谢对该函数的高级解释。

I am not sure what the assembly instructions are...

说明来自here

set.eq.s32.b32 dest, valx, valy

表示"set the value of dest if valx is equal to valy"。这里 valx 是函数的输入值,valy0x80000000dest 是函数 ret 的 return 值。函数的其余部分只是标准的 gcc 派生的内联汇编语法,也记录在案 here.

您可以自己检查 here -0.0f 在 IEEE 754 binary32 表示中是 100000000000000000000000000000000x80000000

因此,如果 a 为负 0,则函数 return 为真,检查按位是否相等。

... but form [sic] the context of the entire file..the function seems to do more than merely checking if the float is negative zero.

希望事实并非如此。