本文整理汇总了C++中DeviceInterface::info方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceInterface::info方法的具体用法?C++ DeviceInterface::info怎么用?C++ DeviceInterface::info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceInterface
的用法示例。
在下文中一共展示了DeviceInterface::info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/*
* Kernel event
*/
KernelEvent::KernelEvent(CommandQueue *parent,
Kernel *kernel,
cl_uint work_dim,
const size_t *global_work_offset,
const size_t *global_work_size,
const size_t *local_work_size,
cl_uint num_events_in_wait_list,
const Event **event_wait_list,
cl_int *errcode_ret)
: Event(parent, Queued, num_events_in_wait_list, event_wait_list, errcode_ret),
p_work_dim(work_dim), p_kernel(kernel)
{
// TODO This is where everything else needs to be handled. Need to try to use
// device specific methods though.
#ifdef DBG_EVENT
std::cerr << "Entering KernelEvent::KernelEvent\n";
#endif
if (*errcode_ret != CL_SUCCESS) return;
*errcode_ret = CL_SUCCESS;
// Sanity checks
if (!kernel)
{
*errcode_ret = CL_INVALID_KERNEL;
return;
}
// Check that the kernel was built for parent's device.
DeviceInterface *device;
Context *k_ctx, *q_ctx;
size_t max_work_group_size;
cl_uint max_dims = 0;
*errcode_ret = parent->info(CL_QUEUE_DEVICE, sizeof(DeviceInterface *),
&device, 0);
if (*errcode_ret != CL_SUCCESS)
return;
*errcode_ret = parent->info(CL_QUEUE_CONTEXT, sizeof(Context *), &q_ctx, 0);
*errcode_ret |= kernel->info(CL_KERNEL_CONTEXT, sizeof(Context *), &k_ctx, 0);
*errcode_ret |= device->info(CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(size_t),
&max_work_group_size, 0);
*errcode_ret |= device->info(CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(size_t),
&max_dims, 0);
*errcode_ret |= device->info(CL_DEVICE_MAX_WORK_ITEM_SIZES,
max_dims * sizeof(size_t), p_max_work_item_sizes, 0);
if (*errcode_ret != CL_SUCCESS)
return;
p_dev_kernel = kernel->deviceDependentKernel(device);
#ifdef DBG_EVENT
std::cerr << "got deviceDependentKernel\n";
#endif
if (!p_dev_kernel)
{
*errcode_ret = CL_INVALID_PROGRAM_EXECUTABLE;
#ifdef DBG_EVENT
std::cerr << "ERROR: deviceDependentKernel failed\n";
#endif
return;
}
// Check that contexts match
if (k_ctx != q_ctx)
{
#ifdef DBG_EVENT
std::cerr << "ERROR: contexts don't match!\n";
#endif
*errcode_ret = CL_INVALID_CONTEXT;
return;
}
// Check args
if (!kernel->argsSpecified())
{
#ifdef DBG_EVENT
std::cerr << "ERROR: kernel args aren't specifed\n";
#endif
*errcode_ret = CL_INVALID_KERNEL_ARGS;
return;
}
// Check dimension
if (work_dim == 0 || work_dim > max_dims)
{
#ifdef DBG_EVENT
std::cerr << "ERROR: invalid work dimension\n";
#endif
*errcode_ret = CL_INVALID_WORK_DIMENSION;
return;
}
// Initialise kernel attributes
//.........这里部分代码省略.........
示例2: void
/*
* Native kernel
*/
NativeKernelEvent::NativeKernelEvent(CommandQueue *parent,
void (*user_func)(void *),
void *args,
size_t cb_args,
cl_uint num_mem_objects,
const MemObject **mem_list,
const void **args_mem_loc,
cl_uint num_events_in_wait_list,
const Event **event_wait_list,
cl_int *errcode_ret)
: Event (parent, Queued, num_events_in_wait_list, event_wait_list, errcode_ret),
p_user_func((void *)user_func), p_args(0)
{
if (*errcode_ret != CL_SUCCESS) return;
// Parameters sanity
if (!user_func)
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
if (!args && (cb_args || num_mem_objects))
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
if (args && !cb_args)
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
if (num_mem_objects && (!mem_list || !args_mem_loc))
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
if (!num_mem_objects && (mem_list || args_mem_loc))
{
*errcode_ret = CL_INVALID_VALUE;
return;
}
// Check that the device can execute a native kernel
DeviceInterface *device;
cl_device_exec_capabilities caps;
*errcode_ret = parent->info(CL_QUEUE_DEVICE, sizeof(DeviceInterface *),
&device, 0);
if (*errcode_ret != CL_SUCCESS)
return;
*errcode_ret = device->info(CL_DEVICE_EXECUTION_CAPABILITIES,
sizeof(cl_device_exec_capabilities), &caps, 0);
if (*errcode_ret != CL_SUCCESS)
return;
if ((caps & CL_EXEC_NATIVE_KERNEL) == 0)
{
*errcode_ret = CL_INVALID_OPERATION;
return;
}
// Copy the arguments in a new list
if (cb_args)
{
p_args = std::malloc(cb_args);
if (!p_args)
{
*errcode_ret = CL_OUT_OF_HOST_MEMORY;
return;
}
std::memcpy((void *)p_args, (void *)args, cb_args);
// Replace memory objects with global pointers
for (cl_uint i=0; i<num_mem_objects; ++i)
{
const MemObject *buffer = mem_list[i];
const char *loc = (const char *)args_mem_loc[i];
if (!buffer)
{
*errcode_ret = CL_INVALID_MEM_OBJECT;
return;
}
// We need to do relocation : loc is in args, we need it in p_args
size_t delta = (char *)p_args - (char *)args;
loc += delta;
//.........这里部分代码省略.........