OpenCL: Second kernel call generates strange output

Hi everyone,

I’m new to this Forum and also OpenCL, so I apologize in advance for things like this post being in the wrong section or trivial questions. :slight_smile:

Background:
Currently I’m trying to write an OpenCL implementation of a 2d-line-detection algorithm using Hough Transformation.
My Basic idea was that the frist kernel should just genearte, for all Points, all the possible radii and angles that represent the lines through a point in
Hough space.
Then the second kernel is responsible for detecting all the intersection in Hough space and thus finding points which are on the same straight line.
So the Output from the first kernel is used as an Input for the second.

Code:
[ul]
[li]Main: [ATTACH]53[/ATTACH]
[/li][li]Kernel 1: [ATTACH]54[/ATTACH]
[/li][li]Kernel 2: [ATTACH]55[/ATTACH]
[/li][/ul]

Now, to my actual Problem:
If I call the second kernel it either writes random integer values into some of the first few entries
of the Output Array or does nothing(leaves the Output Array empty).
Whether it does the first or the latter depends on whether the Output buffer of the first kernel is directly used or recreated from scratch.
So, I can switch between the two cases by writing the following line(Line 268 in the attached main code) or not:

buffAllLines = clCreateBuffer(context, CL_MEM_READ_WRITE, numPoints*(3 + numAngles)*sizeof(double), NULL, &err);

buffAllLines being the Output buffer of the first kernel.

What confuses me now is first, that the output(both cases) don’t depend on the Content of the kernel even though the kernel is loaded
and built without error.
And secondly, that I thought once a buffer Object sits in the device’s (main-)Memory it will stay there until resleased,
so it shouldn’t be necessary (much less make any difference) to create it anew?!

So, now I’m out of Debugging Options and confused. :slight_smile:
I would be really glad about any help or guidance in finding out what is the cause of this.

Looking forward to a reply,
Matthiase

P.S.: I know that the code I wrote is by no means efficient or opitmised, it was just the first try in seeing if the concept worked! :slight_smile: