本文整理汇总了C++中cl::Kernel::getInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ Kernel::getInfo方法的具体用法?C++ Kernel::getInfo怎么用?C++ Kernel::getInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::Kernel
的用法示例。
在下文中一共展示了Kernel::getInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fprintf
void CloverChunk::enqueueKernel
(cl::Kernel const& kernel,
int line, const char* file,
const cl::NDRange offset_range,
const cl::NDRange global_range,
const cl::NDRange local_range,
const std::vector< cl::Event > * const events,
cl::Event * const event)
{
try
{
if (profiler_on)
{
// time it
cl::Event *prof_event;
cl_ulong start, end;
// used if no event was passed
static cl::Event no_event_passed = cl::Event();
if (event != NULL)
{
prof_event = event;
}
else
{
prof_event = &no_event_passed;
}
std::string func_name;
kernel.getInfo(CL_KERNEL_FUNCTION_NAME, &func_name);
#if 0
fprintf(stdout, "Enqueueing kernel: %s\n", func_name.c_str());
fprintf(stdout, "%zu global dimensions\n", global_range.dimensions());
fprintf(stdout, "%zu local dimensions\n", local_range.dimensions());
fprintf(stdout, "%zu offset dimensions\n", offset_range.dimensions());
fprintf(stdout, "Global size: [%zu %zu %zu]\n", global_range[0],global_range[1], global_range[2]);
fprintf(stdout, "Local size: [%zu %zu %zu]\n", local_range[0], local_range[1], local_range[2]);
fprintf(stdout, "Offset size: [%zu %zu %zu]\n", offset_range[0],offset_range[1], offset_range[2]);
fprintf(stdout, "\n");
fflush(stdout);
#endif
queue.enqueueNDRangeKernel(kernel,
offset_range,
global_range,
local_range,
events,
prof_event);
prof_event->wait();
prof_event->getProfilingInfo(CL_PROFILING_COMMAND_START, &start);
prof_event->getProfilingInfo(CL_PROFILING_COMMAND_END, &end);
double taken = static_cast<double>(end-start)*1.0e-6;
if (kernel_times.end() != kernel_times.find(func_name))
{
kernel_calls.at(func_name) += 1;
kernel_times.at(func_name) += taken;
}
else
{
kernel_calls[func_name] = 1;
kernel_times[func_name] = taken;
}
}
else
{
// just launch kernel
queue.enqueueNDRangeKernel(kernel,
offset_range,
global_range,
local_range,
events,
event);
}
}
catch (cl::Error e)
{
std::string func_name;
kernel.getInfo(CL_KERNEL_FUNCTION_NAME, &func_name);
// invalid work group size
if (e.err() == -54)
{
std::stringstream errstr;
errstr << "Error in enqueueing kernel " << func_name;
errstr << " at line " << line << " in " << file << std::endl;
errstr << errToString(e.err()).c_str() << std::endl;
errstr << "Launched with ";
errstr << global_range.dimensions() << " global dimensions, ";
errstr << local_range.dimensions() << " local dimensions." << std::endl;
for (unsigned int ii = 0; ii < global_range.dimensions(); ii++)
{
errstr << "Launch dimension " << ii << ": ";
errstr << "global " << global_range[ii] << ", ";
errstr << "local " << local_range[ii] << " ";
//.........这里部分代码省略.........