Tôi hiện đang khám phá boost_compute. Thật không may là có ít trang tài liệu và ví dụ hơn là tôi cần phải hiểu phải làm gì.Làm cách nào để gọi hàm boost_compute 'BOOST_COMPUTE_FUNCTION'?
Với mã được rút gọn như sau:
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::vector<float> device_values(100, *ctx);
compute::vector<float> 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
);
}
Làm thế nào để gọi 'thêm' chức năng và biến iterating bên trong của chức năng này là những gì? Hơn nữa tôi cần cấu trúc mã này để thực hiện phép tính phức tạp hơn.
Kind Regards, Toni
Sử dụng 'tính toán :: transform', như trong ví dụ ở đây: http://www.boost.org/doc/libs/1_63_0/libs/compute/doc/html/boost_compute/advanced_topics.html# boost_compute.advanced_topics.custom_functions – ddemidov
Một hàm trong boost :: compute được áp dụng cho một phần tử vector đơn. Những gì bạn có thể tìm kiếm là một hạt nhân tùy chỉnh. – ddemidov
Thật không may là tôi không thể tưởng tượng việc gọi điện chuyển đổi đúng cách. Ví dụ này không trả lời cho tôi bất kỳ câu hỏi nào:/ – infotoni91