Anonymous
Как вывести буфер из цикла?
Сообщение
Anonymous » 10 окт 2024, 07:39
Краткое описание вызовов API. В этом блоке кода я хочу вывести буферы из цикла. Так что он не должен создавать буфер в каждом цикле. Но когда я это делаю, код ломается. Какая может быть замена буфера?
Код: Выделить всё
std::vector in_img_py1_Vec;
std::vector in_img_py2_Vec;
cl::Buffer flow_in_buf, flow_buf;
for (int l = NUM_LEVELS - 1; l >= 0; l--)
{
// compute current level height
int curr_height = pyr_h[l];
int curr_width = pyr_w[l];
in_img_py1_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
(pyr_h[l] * pyr_w[l] * CH_TYPE), (ap_uint *)imagepyr1[l].data);
in_img_py2_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE,
(pyr_h[l] * pyr_w[l] * CH_TYPE), (ap_uint *)imagepyr2[l].data);
in_img_py1_Vec.push_back(in_img_py1_buf);
in_img_py2_Vec.push_back(in_img_py2_buf);
q.enqueueMigrateMemObjects(in_img_py1_Vec, 0 /* 0 means from host*/);
q.enqueueMigrateMemObjects(in_img_py2_Vec, 0 /* 0 means from host*/);
flow_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, (pyr_h[l] * pyr_w[l] * 4),
(ap_uint *)flow.data);
flow.init(curr_height, curr_width, 0); // Resize or manage flow's data
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79070394/how-to-move-a-buffer-out-of-the-loop[/url]
1728535152
Anonymous
Краткое описание вызовов API. В этом блоке кода я хочу вывести буферы из цикла. Так что он не должен создавать буфер в каждом цикле. Но когда я это делаю, код ломается. Какая может быть замена буфера? [code]std::vector in_img_py1_Vec; std::vector in_img_py2_Vec; cl::Buffer flow_in_buf, flow_buf; for (int l = NUM_LEVELS - 1; l >= 0; l--) { // compute current level height int curr_height = pyr_h[l]; int curr_width = pyr_w[l]; in_img_py1_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, (pyr_h[l] * pyr_w[l] * CH_TYPE), (ap_uint *)imagepyr1[l].data); in_img_py2_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, (pyr_h[l] * pyr_w[l] * CH_TYPE), (ap_uint *)imagepyr2[l].data); in_img_py1_Vec.push_back(in_img_py1_buf); in_img_py2_Vec.push_back(in_img_py2_buf); q.enqueueMigrateMemObjects(in_img_py1_Vec, 0 /* 0 means from host*/); q.enqueueMigrateMemObjects(in_img_py2_Vec, 0 /* 0 means from host*/); flow_buf = cl::Buffer(context, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, (pyr_h[l] * pyr_w[l] * 4), (ap_uint *)flow.data); flow.init(curr_height, curr_width, 0); // Resize or manage flow's data std::cout Подробнее здесь: [url]https://stackoverflow.com/questions/79070394/how-to-move-a-buffer-out-of-the-loop[/url]