1
$\begingroup$

I'm new to opencl and I'm trying to figure out how to return a variable length array of numbers. (I'm using Cloo for C# .net)

I am doing image processing and I've written a program to look for bubbles in oil. I want to port some of the code to opencl to take advantage of the GPU. I want my opencl function to return a list of co-ordinates and a radius for each bubble. The problem is, since I don't know how many bubbles their will be ahead of time, I seem to need a variable length array. I'm not sure how this is done (or if this can be done) in opencl.

EDIT

Alternatively, if there is a way to exchange datastructures between the GPU and the host, this would work too. However from what I've read from other people's experiences, this doesn't sound like it has been a good option.

$\endgroup$
  • $\begingroup$ @Denis: We encourage programming questions here, as long as it is stated in the context of a computational science problem. This question mentions an image processing (which is part of computational science), so it seems on-topic to me. $\endgroup$ – Geoff Oxberry Nov 20 '13 at 22:25
  • $\begingroup$ @Geoff, sure, try both sites. Would a tag "programming" help programmer / mathematicians to search here ? $\endgroup$ – denis Nov 21 '13 at 13:41
  • $\begingroup$ @Denis: For a question marked "OpenCL", I don't think a programming tag is necessary, and a "programming" tag may be undesirable if it becomes a meta-tag. $\endgroup$ – Geoff Oxberry Nov 21 '13 at 22:44
2
$\begingroup$

Since buffer's sizes fixed at the moment they created, the only way is to simulate variable length arrays: Create an array of maximum size and use an extra variable so that OpenCL-kernel can store how much of this (max)array is in use.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.