atom_inc/atomic_inc 中的 cl_out_of_resources 错误

发布于 2024-09-29 12:33:31 字数 711 浏览 0 评论 0原文

我在我的一个内核中使用atom_inc。或多或少像这样:

kernel exampleKernel(
  global volatile int * x, 
  global const int   maxX,
  global const int * buf1, 
  global const int * buf2
  )
{
  if(x < maxX)
  {
    int y = atom_inc(x);
    buf2[y] = buf1[get_global_id(0)];
  }
}

但是当我调用它时,它给了我一个 CL_OUT_OF_RESOURCES 错误。 将atom_inc(x) 替换为0 可以解决这个问题……但会使内核变得无用。

有什么想法会导致该错误吗?

编辑:我已经在程序中包含了这些扩展:

#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable

Edit2:实际上我用以下内容初始化x:

kernel.setArgs(0,0);

我必须在这个地方使用内存对象吗?

亲切的问候, 弗洛里安

i am using atom_inc in one of my kernels. More or less like this:

kernel exampleKernel(
  global volatile int * x, 
  global const int   maxX,
  global const int * buf1, 
  global const int * buf2
  )
{
  if(x < maxX)
  {
    int y = atom_inc(x);
    buf2[y] = buf1[get_global_id(0)];
  }
}

But it gives me an CL_OUT_OF_RESOURCES error when i call it.
Replacing atom_inc(x) with 0 resolves this problem ... but makes the kernel useless.

Any ideas what can cause that error?

Edit: i have included these extensions in the program:

#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
#pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable

Edit2: actually i initialize x with:

kernel.setArgs(0,0);

Do i have to use a memory object in this place?

Kind Regards,
Florian

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

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

发布评论

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

评论(1

我很OK 2024-10-06 12:33:31

啊...好吧...看来在这种情况下你必须使用内存对象。

这里的解决方案是创建一个单元素 OpenCL 缓冲区并将其设置为第一个参数。

我将这个问题和答案留在这里,以免其他人犯同样的错误。

Ah ... ok ... it looks like you have to use memory objects in this case.

The solution here was to create a one element OpenCL buffer and set it as the first argument.

I'll leave this question and answer here so that others might not make the same fault.

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