【发布时间】:2018-04-26 13:38:21
【问题描述】:
我想获得最大的全局工作大小。 我不希望内核 OpenCL 会尝试为您选择最好的内核,这可能是也可能不是最大尺寸。
为此,我想在调用clEnqueueNDRangeKernel 时指定大小。
例如:
clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &global_size, NULL, 0, NULL, NULL);
clGetKernelWorkGroupInfo documentation,表示:
CL_KERNEL_GLOBAL_WORK_SIZE :这为应用程序提供了一种机制来查询可用于在 device 给出的自定义设备或内置内核上执行内核的最大全局大小(即 clEnqueueNDRangeKernel 的 global_work_size 参数)一个由 device 提供的 OpenCL 设备。
如何通过 OpenCL C++ 绑定获得CL_KERNEL_GLOBAL_WORK_SIZE?
我这样做
cl::array<size_t, 3> kernel_global_work_size = my_kernel.getWorkGroupInfo<CL_KERNEL_GLOBAL_WORK_SIZE>(my_device);
但我得到了错误:
cl2.hpp:5771:12: note: candidate: template<class T> cl_int cl::Kernel::getWorkGroupInfo(const cl::Device&, cl_kernel_work_group_info, T*) const
cl_int getWorkGroupInfo(
^~~~~~~~~~~~~~~~
cl2.hpp:5771:12: note: template argument deduction/substitution failed:
cl2.hpp:5782:9: note: candidate: template<int name> typename cl::detail::param_traits<cl::detail::cl_kernel_work_group_info, name>::param_type cl::Kernel::getWorkGroupInfo(const cl::Device&, cl_int*) const
getWorkGroupInfo(const Device& device, cl_int* err = NULL) const
还有这段代码
cl::array<size_t, 3> kernel_global_work_size;
my_kernel.getWorkGroupInfo<cl::array<size_t, 3>>(my_device, CL_KERNEL_GLOBAL_WORK_SIZE, &kernel_global_work_size);
我收到 OpenCL 错误 -30(无效值)
my_kernel 不是内置内核
例如:cl::Kernel my_kernel = cl::Kernel(program, "my_kernel");
my_device 不是自定义设备。
例如:cl::Device device = myDevices[0];
【问题讨论】: