I know how to pass the structure from host to code, but the problem is push_back function (which is an inbuilt function for structure) not working in opencl.
I have a structure in my host like
struct MyKey
{
int x;
float y;
int scale;
MyKey(int x, float y, int scale) : x(x), y(y), scale(scale){ }
}
i created an object for this structure in host like
std :: vector<MyKey> obj;
i passed this to my kernel and i placed the structure definition there(in kernel), now when i try to call a push_back function its throwing an error.,
__kernel void test(ui32_t w, ui32_t h, constant struct MyKey* obj, i32_t thrd_size)
{
//toatl thread count is w*h
i32_t i = get_global_id(0);
if(i<thrd_size)
{
for (ui32_t i = 0; i < h; i++)
{
for (ui32_t j = 0; j < w; j++)
{
obj.push_back(MyKey(j,iw,h));
}
}
}
}
Thanks in advance..
AMD has a Static C++ Kernel Language extension which supports some C++ features such as classes.
You can find more information about it here: http://developer.amd.com/wordpress/media/2012/10/CPP_kernel_language.pdf
From the documentation:
Kernel code:
Host code: