使用 dp4a() 开始使用 int8 算法

Getting started with int8 arithmetic using dp4a()

我正在尝试使用 post 中所述的 8 位整数内在函数:https://devblogs.nvidia.com/parallelforall/mixed-precision-programming-cuda-8/

在内核中我只是尝试调用

D = __dp4a(A, B, C);

这会导致编译器错误

error: identifier "__dp4a" is undefined

接下来我尝试添加头文件

#include <sm_61_intrinsics.h>

但是没有效果。最后,我添加了这一行:

__device__ int __dp4a(char4 srcA, char4 srcB, int c);

然后我得到另一个编译器错误:

Error using mex

ptxas fatal : Unresolved extern function '_Z6__dp4a5char4S_i'

我在 GeForce GTX 1080 Ti 上安装了 CUDA v8.0 运行,计算能力为 6.1,它应该支持 dp4a。我错过了什么吗?这可能是 Mex/Matlab/Visual Studio 问题吗?

原来这是一个Matlab 2017a and/or Visual Studio 2012问题。在我的例子中,我通过

修复了它

C:\Program Files\MATLAB\R2017a\toolbox\distcomp\gpu\extern\src\mex\win64\nvcc_msvcpp2012.xml

文件,编译器设置所在的位置,并修改此行:

ARCHFLAGS="-gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_61,code=compute_61 $NVCC_FLAGS"

我从 this guide 复制的。默认设置只有 sm_60 作为最高架构,我们需要 sm_61 才能使 __dp4a() 工作。