I found the following 2 bugs / non-compliance cases:
Bug 1 ===== The OpenCL C compiler suppresses warnings unless there are build errors, The "-Werror" compile option is not recognized. (OpenCL 1.1 specification 5.6.3.4 pg. 116) An extra comma was introduced before the last parenthesis in kernel "bug1" to trigger the error, which also triggered the warnings. If the comma is removed the kernel compiles without errors or warnings. Bug 2 ===== In kernel "bug2" the constant expression used to dimension array x is not recognized as constant as per the C99 spec. When compiled as a C function (without the __kernel qualifier) with: gcc -c -std=c99 bug2.c the function compiles OK. All examples below were compiled with following statement: status = clBuildProgram(program, 1, &Device, "-Werror", NULL, NULL); *** Bug 1 ************************************************** __kernel void bug1(void) { float x = 0.0; , } Error in clBuildProgram: CL_BUILD_PROGRAM_FAILURE Warning: invalid option: -Werror /tmp/OCLpJs6Ll.cl(3): warning: double-precision constant is represented as single-precision constant because double is not enabled float x = 0.0; ^ /tmp/OCLpJs6Ll.cl(4): error: expected an expression , ^ /tmp/OCLpJs6Ll.cl(5): error: expected a ";" } ^ /tmp/OCLpJs6Ll.cl(3): warning: variable "x" was declared but never referenced float x = 0.0; ^ 2 errors detected in the compilation of "/tmp/OCLpJs6Ll.cl". *** Bug 2 ************************************************** __kernel void bug2(void) { const int maxnum = 8; float x[maxnum]; } Error in clBuildProgram: CL_BUILD_PROGRAM_FAILURE Warning: invalid option: -Werror /tmp/OCLrB9JQs.cl(4): error: expression must have a constant value float x[maxnum]; ^ 1 error detected in the compilation of "/tmp/OCLrB9JQs.cl".
Originally posted by: HarryH I found the following 2 bugs / non-compliance cases:
HarryH,
Bug1 : SDK2.2 supports only two compiler flags -I and -g.
Bug2 : It should be fixed.
genaganna,
Thanks for the response. Apropos Bug1 shouldn't warnings be on by default, the
specification describes a "-w" option to inhibit warnings, implying they should be
on by default. Another thing, the specification states that the build options
decribed in section 5.6.3 must be supported by an OpenCL compiler.
I really to compile with warnings on, because it helps me find sloppy code.
5.6.3 Build Options The build options are categorized as pre-processor options, options for math intrinsics, options that control optimization and miscellaneous options. This specification defines a standard set of options that must be supported by an OpenCL compiler when building program executables online or offline. These may be extended by a set of vendor- or platform-specific options.
Originally posted by: HarryH genaganna,
Thanks for the response. Apropos Bug1 shouldn't warnings be on by default, the
specification describes a "-w" option to inhibit warnings, implying they should be
on by default. Another thing, the specification states that the build options
decribed in section 5.6.3 must be supported by an OpenCL compiler.
I really to compile with warnings on, because it helps me find sloppy code.
More flags will be supported in upcoming releases.
Regarding second bug. As per C99, maxnum is not constant expression. Following code works only if compiler support variable arrays. Presently OpenCL does not say any thing about variable arrays.
__kernel void bug2(void)
{
const int maxnum = 8;
float x[maxnum];
}
maxnum
I was bit surprised that maxnum couldn't be used as an array declarator but after
diving into the C99 spec I see that it isn't a constant or a constant expression indeed.
Thanks for the clarification.