OpenCL中重复调用enqueueNDRangeKernel
重复调用 enqueueNDRangeKernel 时还应该调用哪些其他 OpenCL 函数?
我无法找到以这种方式显示 enqueueNDRangeKernel 用法的教程,不幸的是,我的编码尝试导致了未处理的异常错误。以前曾问过类似的问题,但答案似乎不适用于我的情况。
我目前有一个按以下顺序调用 OpenCL 函数的循环:
- setArg
- enqueueNDRangeKernel
- enqueueMapBuffer
- enqueueUnmapMemObject
我调用 setArg 是因为每次调用 enqueueNDRangeKernel 之前内核的输入都会发生变化。我正在调用 enqueueMapBuffer 和 enqueueUnmapMemObject,因为内核的输出用于主机代码中。内核第一次运行正常(输出正确),但在第二次循环期间,在调用 enqueueMapBuffer 时出现未处理的异常错误。
我正在使用以下设置:
- 具有 CL_DEVICE_TYPE_CPU 的 Intel OpenCL SDK(在 Intel i7 CPU 上)
- Windows 7 主机上的 Visual Studio 2010 IDE
- 代码是使用 OpenCL C++ 绑定以 C++ 编写的。
谢谢。
What other OpenCL functions should be called when enqueueNDRangeKernel is called repeatedly?
I have not been able to find a tutorial that shows the use of enqueueNDRangeKernel in this fashion and my coding attempts have unfortunately resulted in an unhandled exception error. A similar question has been asked before but the responses don't seem to apply to my situation.
I currently have a loop in which I call the OpenCL functions in the following sequence:
- setArg
- enqueueNDRangeKernel
- enqueueMapBuffer
- enqueueUnmapMemObject
I am calling setArg because the input to the kernel changes before each call to enqueueNDRangeKernel. I am calling enqueueMapBuffer and enqueueUnmapMemObject since the output from the kernel is used in the host code. The kernel runs ok the first time (the output is correct) but during the second pass through the loop I get an unhandled exception error when calling enqueueMapBuffer.
I am using the following set-up:
- Intel OpenCL SDK with CL_DEVICE_TYPE_CPU (on an Intel i7 CPU)
- Visual Studio 2010 IDE on Windows 7
- Host Code is written in C++ with the OpenCL C++ bindings.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题已解决...事实证明我使用了正确的 OpenCL 函数调用顺序。我的内核中有一个问题,仅在循环的第一次迭代后才出现。
Problem Solved ... It turns out that I was using the correct sequence of OpenCL function calls. There was a problem in my kernel that only showed up after the first iteration of the loop.
我正在尝试做和你一样的事情,但我陷入了困境。我设法使 OpenCL 程序和内核都工作,但是当我尝试循环它几次时,只有当我循环从创建分配设备到释放所有 mem_ 的整个代码时,它才工作。
I am trying make same thing as you but I am stuck at one point. I managed to make OpenCL program and Kernel, both working, but when I try loop it several times it works only when i loop whole code from creating an assigning device to dealloc all mem_...