Reputation: 2471
I've to write an OpenCL Marching Cubes implementation.
The Marching Cubes algorithm takes volumetric data and creates an isosurface from it. This process takes very long so I've to write it in OpenCL with n threads to increase performance.
I already have the code, but my problem is, to store the vertices. As far as I understand, I need to know how many vertices the algorithm will create to allocate enough memory, but this number is unknown. Is there any way to create a dynamic data structure like a vector or numpy.array with append function or anything like that.
I'm writing python code to load the OpenCL __kernel, and a have to do some other stuff with the vertices so it should be readable with python. The idea is to create a blender plugin.
Upvotes: 2
Views: 954
Reputation: 1796
As far as I know OpenCL does not allow for any kind of dynamic memory management. One of the reasons is the way a GPU works. Making OpenCL code just work on a CPU, but not on a GPU is not the idea behind OpenCL.
You can solve your problem in the following way:
Lets say you still run out of memory at some point. In that case you simply create a bigger buffer, copy the memory from the old one to the new one and delete the old one.
I hope this helped.
Upvotes: 1