Bug 91130

Summary: Mesa's cl.h defines CL_VERSION_1_2 even though it is missing some OpenCL 1.2 functions
Product: Mesa Reporter: Dennis Schridde <devurandom>
Component: OtherAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium    
Version: 10.5   
Hardware: Other   
OS: All   
See Also: https://github.com/magnumripper/JohnTheRipper/issues/1470
Whiteboard:
i915 platform: i915 features:

Description Dennis Schridde 2015-06-27 21:39:11 UTC
`clEnqueueFillBuffer` is part of OpenCL 1.2 [1] [2].

Mesa claims to support OpenCL 1.2:
```
# grep -B1 CL_VERSION /usr/include/CL/cl.h
/* OpenCL Version */
#define CL_VERSION_1_0                              1
#define CL_VERSION_1_1                              1
#define CL_VERSION_1_2                              1
```

It declares `clEnqueueFillBuffer`:
```
# grep -B1 -A8 clEnqueueFillBuffer /usr/include/CL/cl.h
extern CL_API_ENTRY cl_int CL_API_CALL
clEnqueueFillBuffer(cl_command_queue   /* command_queue */,
                    cl_mem             /* buffer */, 
                    const void *       /* pattern */, 
                    size_t             /* pattern_size */, 
                    size_t             /* offset */, 
                    size_t             /* size */, 
                    cl_uint            /* num_events_in_wait_list */, 
                    const cl_event *   /* event_wait_list */, 
                    cl_event *         /* event */) CL_API_SUFFIX__VERSION_1_2;
```

But does not define it:
```
# scanelf -s clEnqueueFillBuffer /usr/lib/libOpenCL.so
 TYPE   SYM FILE 
ET_DYN  -  /usr/lib/libOpenCL.so 
```

Logically, it also seems to be missing in the API dispatcher [1].

I assume Mesa should not claim to support OpenCL 1.2 via `CL_VERSION_1_2`, if at least one of the OpenCL 1.2 functions is not implemented.

[1]: https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueFillBuffer.html
[2]: https://www.khronos.org/registry/cl/specs/opencl-1.2.pdf#page=85
[3]: http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/state_trackers/clover/api/dispatch.cpp#n129
Comment 1 Dennis Schridde 2015-06-27 21:40:40 UTC
This issue turned up when trying to fix a linker error in JTR: https://github.com/magnumripper/JohnTheRipper/issues/1470
Comment 2 Serge Martin 2015-07-28 13:11:12 UTC
Hello

this should be mitigated with the "clover: allow the creation of Piglit tests for the missing CL 1.2 fonction" serie available on mesa-dev list.

However, even if the program will compile, those fonctions are stubs for the moment. Also applications should ensure that OpenCL 1.2 is available on the platform, for the moment CLover only claim "OpenCL 1.1". For exemple, the platform report currently report "OpenCL 1.2 MESA 10.7.0-devel" in ToT.

EdB
Comment 3 Serge Martin 2015-07-28 13:17:27 UTC
Sorry I mean "OpenCL 1.1 MESA 10.7.0-devel". 1.2 is only clain on my local tree
Comment 4 Dennis Schridde 2015-07-28 14:56:00 UTC
Just to make sure I understand. You say that:
1) Mesa should provide a shared library that actually implements all functions advertised in the header (which will be fixed in Mesa 10.7/11.0)
2) applications using OpenCL should still check at runtime which features are available

I believe JTR already does the latter (there are instances of `if (ocl_ver >= 120)` in the source). So once the patch for (1) is merged, this issue should be fixed.

For reference: The patch Serge mentioned can be found at: https://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg88849.html
Comment 5 Serge Martin 2015-09-01 08:03:32 UTC
This should by fix by a97f1b697b01dca9f72d8559f8269188d76dccc9 : clover: Stub missing CL 1.2 functions.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.