OpenCL 事件和命令队列

发布于 2024-09-15 15:47:49 字数 755 浏览 2 评论 0原文

我正在致力于将 CUDA 应用程序(如果您必须知道的话)转换为 OpenCL。原始应用程序使用C风格的CUDA API,使用单个流只是为了避免读取结果时的自动忙等待。

现在我注意到 OpenCL 命令队列看起来很像 CUDA 流。但在设备读取命令中,同样,在写入和内核执行命令中,我也注意到事件的参数。所以我想知道,依次执行设备写入、多个内核(例如对一个内核的一次调用,然后对另一个内核的 100 次调用)和设备读取需要什么?

  1. 如果我只是将它们按顺序排列到同一个队列中,它们会像在 CUDA 中那样按顺序执行吗?
  2. 如果这不起作用,我可以/应该菊花链事件,使每个呼叫的等待列表都是前一个呼叫的事件吗?
  3. 或者我应该将所有以前的事件添加到每个呼叫的等待列表中,例如是否有 N^2 搜索依赖项或其他内容?
  4. 或者我只需要为每个调用单独使用 event.wait() ,就像它在 AMD 的教程

谢谢!

I'm working on translating a CUDA application (this if you must know) to OpenCL. The original application uses the C-style CUDA API, with a single stream just to avoid the automatic busy-wait when reading the results.

Now I notice that OpenCL command queues look a lot like CUDA streams. But in the device read command, and likewise in the write and kernel execute commands, I notice parameters for events too. So I'm wondering, what does it take to execute a device write, a number of kernels (e.g. one call to one kernel then 100 calls to another kernel), and a device read, all sequentially?

  1. If I just enqueue them sequentially into the same queue, will they execute sequentially like they do in CUDA?
  2. If that doesn't work, can/should I daisy-chain events, making each call's wait list the previous call's event?
  3. Or should I add all previous events to each call's wait list, like if there's an N^2 search for dependencies or something?
  4. Or do I just have to event.wait() for each call individually, like it says to in AMD's tutorial?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清晰传感 2024-09-22 15:47:49

这取决于您如何创建命令队列。在 clCreateCommandQueue 中有一个属性参数,可以包含 CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE,它允许在命令队列中非顺序执行。

如果设置了该属性,命令可能会无序或并行执行,同步它们的唯一方法是使用事件。

如果未设置该属性,命令将在队列中按顺序执行。

That depends on how you create the command queue. in clCreateCommandQueue there's a properties parameter that can contain CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, which enables non-sequential execution in the command queue.

If that property is set, commands might execute out of order or in parallel, and the only way of synchronize them is using events.

When that property is not set, commands execute sequentially in the queue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文