OpenCL本地内存是否有限制? [英] Is there a limit to OpenCL local memory?

查看:119
本文介绍了OpenCL本地内存是否有限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我在内核中添加了另外四个__local变量以转储中间结果.但是,仅将另外四个变量添加到内核的签名中并添加相应的Kernel参数会将内核的所有输出渲染为"0". cl函数均未返回错误代码.

Today I added four more __local variables to my kernel to dump intermediate results in. But just adding the four more variables to the kernel's signature and adding the corresponding Kernel arguments renders all output of the kernel to "0"s. None of the cl functions returns an error code.

我进一步尝试仅添加两个较小的变量之一.如果我仅添加其中一个,则可以使用,但是如果我同时添加它们,则将无法使用.

I further tried only to add one of the two smaller variables. If I add only one of them, it works, but if I add both of them, it breaks down.

那么OpenCL的这种行为是否意味着我分配了很多__local内存?我如何找出我可以使用多少__local内存?

So could this behavior of OpenCL mean, that I allocated to much __local memory? How do I find out, how much __local memory is usable by me?

推荐答案

可以使用带clGetDeviceInfo功能的CL_DEVICE_LOCAL_MEM_SIZE标志来查询设备在每个计算单元上提供的本地内存量: /p>

The amount of local memory which a device offers on each of its compute units can be queried by using the CL_DEVICE_LOCAL_MEM_SIZE flag with the clGetDeviceInfo function:

cl_ulong size;
clGetDeviceInfo(deviceID, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), &size, 0);

返回的大小以字节为单位.每个工作组都可以严格为自己分配这么多的内存.但是请注意,如果它确实分配了最大值,则可能会阻止在同一计算单元上同时调度其他工作组.

The size returned is in bytes. Each workgroup can allocate this much memory strictly for itself. Note, however, that if it does allocate maximum, this may prevent scheduling other workgrups concurrently on the same compute unit.

这篇关于OpenCL本地内存是否有限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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