【发布时间】:2014-10-09 22:19:00
【问题描述】:
所以我的一个设备(Nvidia GeForce GT 650m GPU)一直给我这个奇怪的 ptxas 应用程序错误,说“当我尝试在该设备上构建 cl_program 时,指令 'mov' 的参数不匹配。这是我唯一的一个3 台设备给我这个错误。我的 CPU 和其他 GPU (Intel HD 4000) 根本没有给我这个错误。
以下是导致此错误发生的函数示例。这是我在其中一个内核中使用的辅助函数:
//Calculate the dot product of two vectors
float Dot(Vector v1, Vector v2)
{
return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
}
首先我尝试将工作拆分成这样:
//Calculate the dot product of two vectors)
float Dot(Vector v1, Vector v2)
{
float a = v1.x*v2.x;
float b = v1.y*v2.y;
float c = v1.z*v2.z;
float result = a + b + c;
return result;
}
但这也给了我同样的错误。有趣的是,如果我简单地设置 result = 5.0f 并返回它会神奇地编译并运行:
//THIS WILL COMPILE AND RUN
float Dot(Vector v1, Vector v2)
{
float a = v1.x*v2.x;
float b = v1.y*v2.y;
float c = v1.z*v2.z;
float result = 5.0f; //IGNORE THE CALCULATION. JUST MAKE IT 5
return result;
}
所以我不知道发生了什么。我的“点”功能不是唯一受影响的功能,而是几个功能之一。我的 Nvidia 卡有缺陷吗?
EDIT 这是构建失败后我从 clGetProgramBuildInfo 获得的日志:
ptxas application ptx input, line 703; error : Arguments mismatch for instruction 'mov'
ptxas application ptx input, line 703; error : Unknown symbol 'LIntersection_2E_n'
ptxas application ptx input, line 703; error : Label expected for forward reference of 'LIntersection_2E_n'
ptxas fatal : Ptx assembly aborted due to errors
虽然打印的错误比我描述的 'mov' 还多,但当我对 result = 5.0f 进行上述更改时,它们都消失了;
【问题讨论】:
-
看起来编译器可能生成了不正确的 PTX 代码。你能粘贴生成的 PTX 吗?
-
@Cicada,我发布了 PTX
-
如果您将其设置为 5,则编译器足够智能,可以将您的代码简化为
float Dot(Vector v1, Vector v2){return 5.0f;};,因此错误消失是合乎逻辑的。如果禁用编译器优化,错误可能会保留。但是,你的“向量”是什么?你能发布它的定义吗?
标签: error-handling compilation opencl gpu nvidia