如果程序有效,如何出现 OpenCL 错误代码 -44 CL_INVALID_PROGRAM? [英] How can the OpenCL error code -44 CL_INVALID_PROGRAM appear if program is valid?

查看:141
本文介绍了如果程序有效,如何出现 OpenCL 错误代码 -44 CL_INVALID_PROGRAM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一些看似随机但可重现的情况下,program.build(...) 返回错误 -44,这意味着 CL_INVALID_PROGRAM,所以program 应该是无效的.然而 program 在上面的行中声明,仅取决于 contextsource.我已检查 source 是否有效(kernel_code 中没有错误)并且 context 仅取决于 devicedevice 也是有效的(在 Nvidia Titan Xp 和 GTX 960M 上测试).program 怎么可能无效呢?

In some seemingly random, but reproducible occasions, program.build(...) returns error -44 which means CL_INVALID_PROGRAM, so program is supposed to be invalid. However program is declared in the line above, only depending on context and source. I have checked that source is valid (no errors in kernel_code) and context only depends on device and device is also valid (tested on Nvidia Titan Xp and GTX 960M). How can program not be valid then?

Context context = Context(device);
string kernel_code = opencl_code();
Program::Sources source;
source.push_back({ kernel_code.c_str(), kernel_code.length() });
Program program = Program(context, source);
int error = program.build("-cl-fast-relaxed-math -w");

推荐答案

通常是因为您已经在应用程序的早期阶段将驱动程序置于不稳定状态.在处理图形 API 时,您需要特别注意线程问题(包括哪些 API 保证是线程安全的,哪些不是)和潜在的堆损坏(释放后使用、缓冲区溢出),后面的实现很容易损坏.

Usually because you already brought the driver into an unstable state earlier in your application. You need to pay utmost attention to threading issues (including which APIs are guaranteed to be threadsafe and which are not) and potential heap corruptions (use after free, buffer overflows) when dealing with the graphic APIs, the implementations behind are easily corrupted.

CL_INVALID_PROGRAM 和其他错误通常具有误导性,并且发生在明显不相关的时间点.具体来说,它们只是表明任何内部错误检查都失败了,但很少以有意义的方式进行映射.

CL_INVALID_PROGRAM and other errors are often misleading, and occur at an apparently unrelated point in time. Specifically, they just indicate that any internal error check has failed, but are rarely mapped in a meaningful way.

如果您实际上可以在一个最小的、可重现的示例中重现这一点(这意味着:不是在完整应用程序的上下文中,也没有任何多线程),那么您最好的希望是向 NVidia 提交错误.

If you can actually reproduce this in a minimal, reproducible example (that means: not in the context of a full application, and without any multi threading) then your best hope is to file a bug with NVidia.

如果在最小示例中无法重现,那么几乎可以肯定您在应用程序的其他地方导致了未定义的行为.

If not reproducible in a minimal example, then it's almost certain that you caused undefined behavior somewhere else in your application.

这篇关于如果程序有效,如何出现 OpenCL 错误代码 -44 CL_INVALID_PROGRAM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆