I need to use polymorphism in my kernels. The only way of doing this is to create those objects on the device (to make a virtual mehod table available at the device). Here's the object being created
class Production {
Vertex * boundVertex;
}
class Vertex {
Vertex * leftChild;
Vertex * rightChild;
}
Then on the host I do:
Production* dProd;
cudaMalloc(&dProd, sizeof(Production *));
createProduction<<<1,1>>>(dProd);
where
__global__ void createProduction(Production * prod) {
prod = new Production();
prod->leftChild = new Vertex();
prod->rightChild = new Vertex();
}
The question is how do I get both left and right vertices of the production created on the device back on the host? I know using pointers in classes makes them very hard to handle but... no other way of creating such tree structure.
dProdis a little odd, but that doesn't seem to be impacting anything.