<?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 This behaviour is actually in in OpenCL* for CPU</title>
    <link>https://community.intel.com/t5/OpenCL-for-CPU/Blocking-clEnqueueWriteBuffer-returns-before-value-is-written/m-p/1088433#M4854</link>
    <description>&lt;P&gt;This behaviour is actually in line with the spec ( though it is very very confusing ).&lt;/P&gt;

&lt;P&gt;Blocking in terms of writeBuffer operation guards the "ptr" not the buffer update operation, that's why to make sure buffer is updated additional synchronization is needed ( through event or clFinish ).&lt;/P&gt;

&lt;P&gt;Here is a qoute from the spec:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;If blocking_write is CL_TRUE, the OpenCL implementation copies the data referred to by ptr and enqueues the write operation in the command-queue.The memory pointed to by ptr can be reused by the application after the clEnqueueWriteBuffer call returns.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Blocking EnqueueWriteBuffer may actually be split into 2 steps:&lt;/P&gt;

&lt;P&gt;- allocate temporary memory, copy the data under the "ptr", return from the blocking call.&lt;/P&gt;

&lt;P&gt;- copy the data from temporary memory into the buffer. ( this is done asynchronously )&lt;/P&gt;

&lt;P&gt;Other way to handle this is to actually perform the EnqueueWriteBuffer operation is to perform the actual data copy before leaving the call, that is what GPU driver does.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2017 17:09:31 GMT</pubDate>
    <dc:creator>Michal_M_Intel</dc:creator>
    <dc:date>2017-04-20T17:09:31Z</dc:date>
    <item>
      <title>Blocking clEnqueueWriteBuffer returns before value is written</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/Blocking-clEnqueueWriteBuffer-returns-before-value-is-written/m-p/1088432#M4853</link>
      <description>&lt;P&gt;&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;Hi,&lt;/SPAN&gt;&lt;BR style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;" /&gt;
	&lt;BR style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;" /&gt;
	&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;I've encountered a problem when using OpenCL and Intel CPU:&lt;/SPAN&gt;&lt;BR style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;" /&gt;
	&lt;BR style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;" /&gt;
	&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;When I do a blocking write (using clEnqueueWriteBuffer)&amp;nbsp;to a buffer&amp;nbsp;&lt;/SPAN&gt;&lt;I style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;b&lt;/I&gt;&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;&amp;nbsp;using command queue&amp;nbsp;&lt;/SPAN&gt;&lt;I style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;q1&lt;/I&gt;&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;, and right after that I enqueue a blocking read (using clEnqueueRead Buffer)&amp;nbsp;from buffer&amp;nbsp;&lt;/SPAN&gt;&lt;I style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;b&lt;/I&gt;&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;&amp;nbsp;using a different command queue&amp;nbsp;&lt;/SPAN&gt;&lt;I style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;q2&lt;/I&gt;&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;, what&amp;nbsp;I read is not what I'v just written (some garbage or previous value). I was writing and reading one integer value (4 bytes). I can read correct value if I wait on event associated with clEnqueueWriteBuffer operation, or if I perform clFinish() on&amp;nbsp;&lt;/SPAN&gt;&lt;I style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;q1&lt;/I&gt;&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;&amp;nbsp;after clEnqueueWriteBuffer. Also this problem does not occur when I use one commend queue.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;This problem does not occur on Intel iGPU I have, AMD platform (both CPU and dGPU), NVIDIA platform (GPU).&lt;/SPAN&gt;&lt;/P&gt;

&lt;DIV style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: small;"&gt;
	&lt;DIV&gt;
		&lt;DIV&gt;Environment:&amp;nbsp;&lt;BR /&gt;
			* i7 6700K (but also Intel(R) Xeon(R) CPU E5-2680 v3)&lt;BR /&gt;
			* latest Intel SDK and latest drivers, but older drivers behaves the same.&lt;/DIV&gt;
	&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 20 Apr 2017 16:19:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/Blocking-clEnqueueWriteBuffer-returns-before-value-is-written/m-p/1088432#M4853</guid>
      <dc:creator>Jakub_S_</dc:creator>
      <dc:date>2017-04-20T16:19:45Z</dc:date>
    </item>
    <item>
      <title>This behaviour is actually in</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/Blocking-clEnqueueWriteBuffer-returns-before-value-is-written/m-p/1088433#M4854</link>
      <description>&lt;P&gt;This behaviour is actually in line with the spec ( though it is very very confusing ).&lt;/P&gt;

&lt;P&gt;Blocking in terms of writeBuffer operation guards the "ptr" not the buffer update operation, that's why to make sure buffer is updated additional synchronization is needed ( through event or clFinish ).&lt;/P&gt;

&lt;P&gt;Here is a qoute from the spec:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;If blocking_write is CL_TRUE, the OpenCL implementation copies the data referred to by ptr and enqueues the write operation in the command-queue.The memory pointed to by ptr can be reused by the application after the clEnqueueWriteBuffer call returns.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Blocking EnqueueWriteBuffer may actually be split into 2 steps:&lt;/P&gt;

&lt;P&gt;- allocate temporary memory, copy the data under the "ptr", return from the blocking call.&lt;/P&gt;

&lt;P&gt;- copy the data from temporary memory into the buffer. ( this is done asynchronously )&lt;/P&gt;

&lt;P&gt;Other way to handle this is to actually perform the EnqueueWriteBuffer operation is to perform the actual data copy before leaving the call, that is what GPU driver does.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 17:09:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/Blocking-clEnqueueWriteBuffer-returns-before-value-is-written/m-p/1088433#M4854</guid>
      <dc:creator>Michal_M_Intel</dc:creator>
      <dc:date>2017-04-20T17:09:31Z</dc:date>
    </item>
    <item>
      <title>You're right. Thanks.</title>
      <link>https://community.intel.com/t5/OpenCL-for-CPU/Blocking-clEnqueueWriteBuffer-returns-before-value-is-written/m-p/1088434#M4855</link>
      <description>&lt;P&gt;You're right. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 17:32:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/OpenCL-for-CPU/Blocking-clEnqueueWriteBuffer-returns-before-value-is-written/m-p/1088434#M4855</guid>
      <dc:creator>Jakub_S_</dc:creator>
      <dc:date>2017-04-20T17:32:06Z</dc:date>
    </item>
  </channel>
</rss>

