Invalid Operation using clBuildProgram

Hi,

I came across an issue when compiling OpenCL programs. I’m working on a compiler that supports moving operations to OpenCL. I implemented a method that first calls clCreateProgramWithSource and then, given that the errcode_ret was CL_SUCCESS, calls clBuildProgram immediately after, passing null for pfn_notify.

For certain operations, the second call results in CL_INVALID_OPERATION. According to the spec, this is due to one of the following reasons:
[ol]
[li]if the build of a program executable for any of the devices listed in device_list by a previous call to clBuildProgram for program has not completed.[/:m:1y7oevow][/li][li]if there are kernel objects attached to program.[/:m:1y7oevow][/ol][/li]
I don’t see how any of the two conditions might be satisfied. There cannot be any uncompleted calls to clBuildProgram for program, because program was just created from the source before. By the same reasoning, there can also not be any kernels attached to program.

What could I be missing here?

I have found the source of the problem. It seems ATI does not accept the read_write modifier for buffer objects.

And then it outputs CL_INVALID_OPERATION. So if you get this error, double check whether you’re using an ATI card and read_write for a buffer object.

There is only one thing that is worse than not returning an error: returning the wrong one.

It seems ATI does not accept the read_write modifier for buffer objects.

Correction: the standard does not allow the read_only qualifier for buffer objects.

I have used read_only successfully many times. It is read_write that makes the compilation for an ATI card fail and output the wrong error.

Where would that be detailed in the spec?

Check the The OpenCL Specification document, section “6.6 Access qualifiers”. read_only, write_only and read_write don’t apply to buffers, they apply to images only. The fact that you used read_only qualifier for buffers and ATI compiler processed it just means that their compiler allowed you to step aside from standard.

Thanks for correcting that.

Could you maybe try to be more specific when you write stuff like this:

In the end, it is correct, but suggests that other modifiers are valid. And now they are not.

In the end, it is correct, but suggests that other modifiers are valid. And now they are not.[/quote]

Banjobeni, you cited david.garcia’s words, not mine.

Oh, sorry, my bad. It seems I got used to the fact that only David Garcia answers my questions :slight_smile:

Sorry again, I did not mean to be rude in any way.

Could you maybe try to be more specific when you write stuff like this

Sure. It takes time to find the exact section and it seemed to me like most people didn’t care about the details and simply took my word for it, so sometimes I don’t bother.