简体   繁体   English

clSetKernelArg抛出EXC_BAD_ACCESS

[英]clSetKernelArg throwing EXC_BAD_ACCESS

I'm working through the HelloWorld example in the OpenCl Programming Guide and I keep getting an EXC_BAD_ACCESS when I try to run this function (clSetKernelArg). 我正在通过《 OpenCl编程指南》中的HelloWorld示例进行操作,尝试运行此函数(clSetKernelArg)时,我一直得到EXC_BAD_ACCESS。 The look of my function is basically... 我的功能看起来基本上是...

clSetKernelArg(mKernel, 0, sizeof(cl_mem), mMemObject[0]);

In the debugger everything looks to be instantiated. 在调试器中,所有内容看起来都需要实例化。 There's nothing null inside of the parenthesis and I'm all out of ideas. 括号内没有空,我全都没有想法。 Any help would be greatly appreciated. 任何帮助将不胜感激。

If you are going trough an OpenCL Hello World example I am almost certain that you do not have 如果您正在研究OpenCL Hello World示例,我几乎可以肯定您没有

cl_mem * mMemObject[foo]

That would be the only thing that would make the mMemObject[0] declaration legal. 这将使mMemObject [0]声明合法。 EXC_BAD_ACCESS implies that you are dereferencing an invalid pointer, and this implies that your mMemObject is just cl_mem. EXC_BAD_ACCESS意味着您正在取消引用无效的指针,这意味着您的mMemObject只是cl_mem。

This works if you have declared mMemObject simply with cl_mem mMemObject: 如果仅使用cl_mem mMemObject声明了mMemObject,则此方法有效:

clSetKernelArg(mKernel, 0, sizeof(cl_mem), &mMemObject);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM