- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
According to OpenCL 1.2 spec:
clEnqueueMapBuffer and clEnqueueMapImage increment the mapped count of the memory object. The initial mapped count value of a memory object is zero. Multiple calls to clEnqueueMapBuffer or clEnqueueMapImage on the same memory object will increment this mapped count by appropriate number of calls. clEnqueueUnmapMemObject decrements the mapped count of the memory object.
But it happens that the 2nd mapping attempt returns an error code (-59).
I've prepared a simple reproducer for the problem (attached), it's output is:
Using device: Intel(R) HD Graphics 4600 (iGPU), ver OpenCL 1.2Using platform: Intel(R) OpenCL, ver OpenCL 1.2Creating cl::Buffer(CL_MEM_USE_HOST_PTR, 00000083B8E33430) Performing multiple mappings (should use internal OpenCL counter as per Khronos)Mapping buffer #1... returned 00000083B8E33430Mapping buffer #2...*****OpenCL runtime error: clEnqueueMapBuffer(-59)
while the expected output is:
Creating cl::Buffer(CL_MEM_USE_HOST_PTR, 0000004AD96DE160) Performing multiple mappings (should use internal OpenCL counter as per Khronos)Mapping buffer #1... returned 0000004AD96DE160Mapping buffer #2... returned 0000004AD96DE160Mapping buffer #3... returned 0000004AD96DE160Unmapping buffer #1Unmapping buffer #2Unmapping buffer #3All done.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Andrey,
Yes, this looks like a bug to me. I can reproduce it on my side as well. Thanks for reporting the issue! I will file a bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Andrey,
After consulting with our driver architect, we think that you program is actually operating correctly. According to rev19 of the 1.2 spec, page 123, section 5.4.3. https://www.khronos.org/registry/cl/specs/opencl-1.2.pdf
“Mapping (and unmapping) overlapped regions in a memory object and/or associated memory
objects (sub-buffer objects or 1D image buffer objects that overlap this region) for writing is an
error and will result in CL_INVALID_OPERATION error returned by clEnqueueMapBuffer, or
clEnqueueMapImage.”
-59 is CL_INVALID_OPERATION, so you are getting expected behavior.
The problem here is in the 1.2 man pages, which don't have the above wording. The spec takes precedence, though :) Both 1.1 and 2.0 man pages have this wording:
https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueMapBuffer.html
https://www.khronos.org/registry/cl/sdk/2.0/docs/man/xhtml/clEnqueueMapBuffer.html
Please correct your program accordingly.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page