本文整理汇总了C++中boost::compute::command_queue::enqueue_nd_range_kernel方法的典型用法代码示例。如果您正苦于以下问题:C++ command_queue::enqueue_nd_range_kernel方法的具体用法?C++ command_queue::enqueue_nd_range_kernel怎么用?C++ command_queue::enqueue_nd_range_kernel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::compute::command_queue
的用法示例。
在下文中一共展示了command_queue::enqueue_nd_range_kernel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
decltype(auto) matrix_transpose(
InputRange const& input, OutputRange& output,
int row_size, int col_size,
boost::compute::command_queue& queue) {
NEU_ASSERT(row_size*col_size == range::distance(input));
static auto transpose_kernel =
neu::make_kernel(neu::layer::impl::matrix_transpose_kernel_source,
"matrix_transpose", queue.get_context());
transpose_kernel.set_args(
range::get_buffer(input),
static_cast<cl_int>(range::get_begin_index(input)),
range::get_buffer(output),
static_cast<cl_int>(range::get_begin_index(output)),
static_cast<cl_int>(row_size),
static_cast<cl_int>(col_size));
std::size_t global[2] = {
static_cast<std::size_t>(((col_size-1)/32+1)*32),
static_cast<std::size_t>(((row_size-1)/32+1)*32)
};
std::size_t local[2] = {
static_cast<std::size_t>(32),
static_cast<std::size_t>(32)
};
queue.enqueue_nd_range_kernel(transpose_kernel, 2, nullptr, global, local);
}
示例2: medianFilter2D_wrapper
void medianFilter2D_wrapper(compute::command_queue queue,boost::compute::program foo_program,compute::buffer gpu_in,compute::buffer gpu_out,compute::buffer gpu_histogram,int heightImage,int widthImage,int implementation)
{
try{
boost::compute::kernel foo_kernel;
switch(implementation)
{
case 1:
std::cout<<"running naive median filter"<<std::endl;
foo_kernel = foo_program.create_kernel("MedianFilter2D");
break;
case 2:
std::cout<<"running histogram median filter"<<std::endl;
foo_kernel = foo_program.create_kernel("MedianFilter2D_histogram");
break;
case 3:
std::cout<<"running median filter with partial selection"<<std::endl;
foo_kernel = foo_program.create_kernel("MedianFilter2D_partial");
break;
case 4:
std::cout<<"running median filter with forgetful selection"<<std::endl;
foo_kernel = foo_program.create_kernel("MedianFilter2D_forgetful");
break;
case 5:
std::cout<<"running median filter with fast histogram"<<std::endl;
foo_kernel = foo_program.create_kernel("histogram2d");
break;
}
if(implementation!=5)
{
// TODO these are the arguments for the first kernel
foo_kernel.set_arg(0,gpu_in);
foo_kernel.set_arg(1,gpu_out);
foo_kernel.set_arg(2,sizeof(int),&widthImage);
foo_kernel.set_arg(3,sizeof(int),&heightImage);
// foo_kernel.set_arg(4,sizeof(unsigned int),&window_size);
// Launch kernel
const size_t offset[] = { 0, 0 };
const size_t bounds[] = { heightImage, widthImage };
timer kernel_timer1;
queue.enqueue_nd_range_kernel(foo_kernel, 2,
offset,
bounds,
0);
double time_elapsed1=kernel_timer1.elapsed();
printf("total time elapsed for the kernel implementation %d is %f \n",implementation,time_elapsed1);
}
else
{
foo_kernel.set_arg(0,gpu_in);
foo_kernel.set_arg(1,gpu_out);
foo_kernel.set_arg(2,gpu_histogram);
foo_kernel.set_arg(3,sizeof(int),&widthImage);
foo_kernel.set_arg(4,sizeof(int),&heightImage);
// foo_kernel.set_arg(4,sizeof(unsigned int),&window_size);
// Launch kernel
timer kernel_timer;
queue.enqueue_1d_range_kernel(foo_kernel, 0,heightImage, 0);
double time_elapsed=kernel_timer.elapsed();
printf("total time elapsed for the kernel implementation %d is %f \n",implementation,time_elapsed);
}
}
catch(boost::compute::opencl_error &e){
std::cout<<"something went wrong with kernel execution"<<std::endl;
}
}
示例3: operator
/// Enqueue the kernel to the specified command queue.
void operator()(boost::compute::command_queue q) {
q.enqueue_nd_range_kernel(K, 3, NULL, g_size.dim, w_size.dim);
argpos = 0;
}