I need to pass a C++ vector of vectors to OpenCL kernel, for exemple, I have the follow data:
3 1 9 1 3 8 5 1 3 8 4
3 9 4 0 7 4 3
1 0 4 8 2 8 3 1 2
1 9 3 2
8 3 9 4
4 9 3 9 5 4 3
My structure of data in C++ is a vector of vectors:
So, my structure is a vector of vectos with size 6 and the size of the vector 'i' is dynamic.
How can I pass the data to OpenCL kernel?
Any idea?
Thank you.
答案 0 :(得分:1)
如果您仍然感兴趣:
在主机端创建矢量:
std::vector<std::vector <float> > yourVector;
然后在您的主机上,将您的向量传递给内核
std::vector<std::vector <float>& >& yourVector
在内核的输入参数中,使用
__global float (*yourVector)[6]
您现在可以使用例如
访问内核中的元素yourVector[0][0]
没有测试它,但它应该工作。也许你必须适应它。