Sternenprinz

Proposal for better CL Headers / bug reports

Discussion created by Sternenprinz on Oct 22, 2009
Latest reply on Nov 3, 2009 by omkaranathan

1) I would like to propose a better format for the standard header cl.h.

Reason: The usual building and running problems, including the issue having to depent on OpenCL.dll (/.so/whatever lib format) statically, unable to support more than one platform.

Solution: Minor changes in the way 'cl.h' declares the functions. Simply declare function pointers instead of function prototypes. Additionally there has to be a 'cl.c' that is able to fill the pointers. 

Example:

instead of

 

extern CL_API_ENTRY cl_int CL_API_CALL

fn_clReleaseEvent(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;

a)


typedef CL_API_ENTRY cl_int 

(CL_API_CALL *fn_clReleaseEvent)(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;

extern fn_clSomeProc clReleaseEvent;

or the direct way b)

 

extern CL_API_ENTRY cl_int 

(CL_API_CALL *clReleaseEvent)(cl_event /* event */) CL_API_SUFFIX__VERSION_1_0;

// small changes, big impact...

// Working on the VC series, it should be no problem to get this working

// on other major compilers, at least with minor changes

<IMHO>



There is no good reason that in the year 2009 Headers have to look like in times of K&R. Nearly all compilers will eat function pointer, i guess that those who dont wont get a special lib from Khronos to link to - i.e. those are out the game anyway. So everybody who is not happy with static linking or with using some specific toolchain has to write its own import header. Is this really nescessary?

Maybe there is a additional overhead with calling function pointers, but this overhead is a) small and b) inevitable for dynamic binding. On the other hand there is no problem to circumvent this with some preprocessor magic.

 

</IMHO>

2) The vector class from cl.hpp has a trivial bug, example:

 

 

This works

for (vector = begin,vector!=end;++vector) // <-- note the prefix op

this not

for (vector = begin,vector!=end;vector++) // <-- note the postfix op

Semantically both versions do the same. At least a note that the postfix op is broken would be nice.

3) The whole SDK does not work with VC90 due to 'Library Hell' reasons. What does work are the prebuilt demos/examples. Solution is -surprise- dynamically linking to OpenCL.dll and throwing away the whole SDK.
4) I could provide patches/mods for 1 & 2, if -and only if- someone in charge is actually willing to test them and maybe propose them to the committe.

 

Outcomes