<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Multiple Map/Unmap buffer in OpenCL* for CPU</title>
    <link>https://community.intel.com/t5/OpenCL-for-CPU/Multiple-Map-Unmap-buffer/m-p/1000805#M2855</link>
    <description>&lt;P&gt;According to &lt;A href="https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueMapBuffer.html"&gt;OpenCL 1.2 spec&lt;/A&gt;:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;​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.​&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But it happens that the 2nd mapping attempt returns an error code (-59).&lt;/P&gt;

&lt;P&gt;I've prepared a simple reproducer for the problem (attached), it's output is:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Using device: Intel(R) HD Graphics 4600 (iGPU), ver OpenCL 1.2&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Using platform: Intel(R) OpenCL, ver OpenCL 1.2&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Creating cl::Buffer(CL_MEM_USE_HOST_&lt;WBR /&gt;PTR, 00000083B8E33430)&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Performing multiple mappings (should use internal OpenCL counter as per Khronos)&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Mapping buffer #1... returned 00000083B8E33430&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Mapping buffer #2...&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;*****&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;OpenCL runtime error: clEnqueueMapBuffer(-59)&lt;/FONT&gt;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;while the expected output is:&lt;/SPAN&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Creating cl::Buffer(CL_MEM_USE_HOST_&lt;WBR /&gt;PTR, 0000004AD96DE160)&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Performing multiple mappings (should use internal OpenCL counter as per Khronos)&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Mapping buffer #1... returned 0000004AD96DE160&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Mapping buffer #2... returned 0000004AD96DE160&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Mapping buffer #3... returned 0000004AD96DE160&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Unmapping buffer #1&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Unmapping buffer #2&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Unmapping buffer #3&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;All done.&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;

&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Thu, 27 Aug 2015 09:49:04 GMT</pubDate>
    <dc:creator>Andrey_P_1</dc:creator>
    <dc:date>2015-08-27T09:49:04Z</dc:date>
    <item>
      <title>Multiple Map/Unmap buffer</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/Multiple-Map-Unmap-buffer/m-p/1000805#M2855</link>
      <description>&lt;P&gt;According to &lt;A href="https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clEnqueueMapBuffer.html"&gt;OpenCL 1.2 spec&lt;/A&gt;:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;​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.​&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But it happens that the 2nd mapping attempt returns an error code (-59).&lt;/P&gt;

&lt;P&gt;I've prepared a simple reproducer for the problem (attached), it's output is:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Using device: Intel(R) HD Graphics 4600 (iGPU), ver OpenCL 1.2&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Using platform: Intel(R) OpenCL, ver OpenCL 1.2&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Creating cl::Buffer(CL_MEM_USE_HOST_&lt;WBR /&gt;PTR, 00000083B8E33430)&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Performing multiple mappings (should use internal OpenCL counter as per Khronos)&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Mapping buffer #1... returned 00000083B8E33430&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;Mapping buffer #2...&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;*****&lt;/FONT&gt;&lt;/DIV&gt;

	&lt;DIV class="gmail_default" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&lt;FONT color="#000000" face="arial, helvetica, sans-serif"&gt;OpenCL runtime error: clEnqueueMapBuffer(-59)&lt;/FONT&gt;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;while the expected output is:&lt;/SPAN&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Creating cl::Buffer(CL_MEM_USE_HOST_&lt;WBR /&gt;PTR, 0000004AD96DE160)&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Performing multiple mappings (should use internal OpenCL counter as per Khronos)&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Mapping buffer #1... returned 0000004AD96DE160&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Mapping buffer #2... returned 0000004AD96DE160&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Mapping buffer #3... returned 0000004AD96DE160&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Unmapping buffer #1&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Unmapping buffer #2&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;Unmapping buffer #3&lt;/DIV&gt;

	&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;All done.&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;

&lt;DIV class="gmail_extra" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 12.8000001907349px; line-height: normal;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 27 Aug 2015 09:49:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/Multiple-Map-Unmap-buffer/m-p/1000805#M2855</guid>
      <dc:creator>Andrey_P_1</dc:creator>
      <dc:date>2015-08-27T09:49:04Z</dc:date>
    </item>
    <item>
      <title>Hi Andrey,</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/Multiple-Map-Unmap-buffer/m-p/1000806#M2856</link>
      <description>&lt;P&gt;Hi Andrey,&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2015 18:34:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/Multiple-Map-Unmap-buffer/m-p/1000806#M2856</guid>
      <dc:creator>Robert_I_Intel</dc:creator>
      <dc:date>2015-08-27T18:34:20Z</dc:date>
    </item>
    <item>
      <title>Hi Andrey,</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/Multiple-Map-Unmap-buffer/m-p/1000807#M2857</link>
      <description>&lt;P&gt;Hi Andrey,&lt;/P&gt;

&lt;P&gt;After consulting with our driver architect, we think that you program is actually operating correctly. According to &lt;SPAN style="color: rgb(31, 73, 125); font-family: &amp;quot;Calibri&amp;quot;,sans-serif; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: &amp;quot;Times New Roman&amp;quot;; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;"&gt;rev19 of the 1.2 spec, page 123, section 5.4.3. &lt;/SPAN&gt;&lt;FONT size="2"&gt;&lt;A href="https://www.khronos.org/registry/cl/specs/opencl-1.2.pdf"&gt;https://www.khronos.org/registry/cl/specs/opencl-1.2.pdf&lt;/A&gt; &lt;/FONT&gt;&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="color: rgb(31, 73, 125);"&gt;&lt;FONT face="Calibri" size="3"&gt;“Mapping (and unmapping) overlapped regions in a memory object and/or associated memory &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="color: rgb(31, 73, 125);"&gt;&lt;FONT face="Calibri" size="3"&gt;objects (sub-buffer objects or 1D image buffer objects that overlap this region) for writing is an &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="color: rgb(31, 73, 125);"&gt;&lt;FONT face="Calibri" size="3"&gt;error and will result in CL_INVALID_OPERATION error returned by&amp;nbsp; clEnqueueMapBuffer, or &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="color: rgb(31, 73, 125);"&gt;&lt;FONT face="Calibri" size="3"&gt;clEnqueueMapImage.”&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="color: rgb(31, 73, 125);"&gt;&lt;FONT face="Calibri" size="3"&gt;-59 is CL_INVALID_OPERATION, so you are getting expected behavior.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;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:&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;FONT size="2"&gt;&lt;A href="https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueMapBuffer.html"&gt;https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueMapBuffer.html&lt;/A&gt; &lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;FONT size="2"&gt;&lt;A href="https://www.khronos.org/registry/cl/sdk/2.0/docs/man/xhtml/clEnqueueMapBuffer.html"&gt;https://www.khronos.org/registry/cl/sdk/2.0/docs/man/xhtml/clEnqueueMapBuffer.html&lt;/A&gt; &lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;Please correct your program accordingly.&lt;/P&gt;

&lt;P style="margin: 0in 0in 0pt;"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2015 21:44:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/Multiple-Map-Unmap-buffer/m-p/1000807#M2857</guid>
      <dc:creator>Robert_I_Intel</dc:creator>
      <dc:date>2015-08-27T21:44:07Z</dc:date>
    </item>
  </channel>
</rss>

