我正在探索boost_compute.不幸的是,文档页面和示例比我需要了解的更少.
鉴于以下缩小的代码:
BOOST_COMPUTE_FUNCTION(bool, add, (int* values, int* results, int constant), { // Whats the indexing variable? // In opencl it would be get_global_id(0) int index = // ? results[index] = values[index] + values[index + 1] + values[index + 2] + constant; }); void compute(float* results, compute::context* ctx, compute::command_queue* queue) { compute::vectordevice_values(100, *ctx); compute::vector device_results(98, *ctx); compute::copy( parameters->values.begin(), parameters->values.end(), device_values.begin(), *queue ); // Actual computation // HOW TO CALL 'add' for every device_results element? compute::copy( device_results.begin(), device_results.end(), results, *queue ); }
如何调用'add'函数以及这个函数内部的迭代变量是什么?此外,我需要这种代码结构来进行更复杂的计算.
亲切的问候,托尼