<font face="Arial">Hello, everyone,</font><div><font face="Arial"><br></font></div><div><font face="Arial">I have a problem when using CL_MEM_USE_HOST_PTR.</font></div><div><font face="Arial"><br></font></div><div><font face="Arial"><b>1.</b> I want to use CL_MEM_USE_HOST_PTR to create a buffer of self-defined structure. After operated by GPU, I will reuse the memory in host.</font></div><div><font face="Arial">The main method I use is:</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">      </span>... ...</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">      </span>clCreateBuffer(..., <span style="background-color: rgb(255, 255, 153);">(void*)<font color="#ff0000">p</font></span>, ...);</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">      </span>... ...</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">      </span>clSetKernelArg();</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">    </span>clEnqueueNDRangeKernel();</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">    </span>clFinish();</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">  </span>MyFunction(...,<font color="#ff0000"> <span style="background-color: rgb(255, 255, 153);">p</span></font>, ...); //reuse the memory derectly pointed by p</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">        </span>...</font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">  </span><font color="#ff0000">clReleaseContext(context); // Failed to release test userptr object! (9) i915 kernel driver may not be sane!</font></font></div><div><span style="line-height: 1.2;"><font face="Arial"><br></font></span></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">   </span>...</font></div><div><font face="Arial"><br></font></div><div><font face="Arial"><b>Problem:</b> <span style="line-height: 16.7999992370605px;">clReleaseContext() return CL_SUCCESS, but hints "</span><span style="line-height: 16.7999992370605px;">Failed to release test userptr object! (9) i915 kernel driver may not be sane!</span><span style="line-height: 16.7999992370605px;">", and then, continue to run.</span></font></div><div><font face="Arial"><br></font></div><div><font face="Arial"><b>2.</b> "./utest_run runtime_use_host_ptr_buffer" is OK, and I have read sample code runtime_use_host_ptr_buffer.cpp, main difference is:</font></div><div><div style="line-height: 16.7999992370605px;"><span class="Apple-tab-span" style="white-space:pre"><font face="Arial"><span class="Apple-tab-span" style="white-space:pre"> </span>mycode:<span class="Apple-tab-span" style="white-space:pre">     </span><span class="Apple-tab-span" style="white-space:pre">                                    </span>|<span class="Apple-tab-span" style="white-space:pre">   </span>sample of beignet:</font></span></div><div><font face="Arial"><span class="Apple-tab-span" style="line-height: 16.7999992370605px; white-space: pre;">                                                   </span><span class="Apple-tab-span" style="line-height: 16.7999992370605px; white-space: pre;"> </span>|<span class="Apple-tab-span" style="white-space:pre">           </span><span style="background-color: rgb(255, 255, 153);"><font color="#ff0000">pp</font></span> = clEnqueueMapBuffer()</font></div><div><font face="Arial"><span class="Apple-tab-span" style="line-height: 16.7999992370605px; white-space: pre;">                </span><span style="line-height: 16.7999992370605px;">clFinish();</span><span class="Apple-tab-span" style="line-height: 16.7999992370605px; white-space: pre;">                                  </span>|<span class="Apple-tab-span" style="white-space:pre">           </span><span style="line-height: 16.7999992370605px;">MyFunction(..., </span><span style="line-height: 16.7999992370605px; background-color: rgb(255, 255, 153);"><font color="#ff0000">pp</font></span><span style="line-height: 16.7999992370605px;">, ...);</span></font></div><div><font face="Arial"><span class="Apple-tab-span" style="white-space:pre">          </span><span style="line-height: 16.7999992370605px;">MyFunction(..., </span><span style="line-height: 16.7999992370605px; background-color: rgb(255, 255, 153);"><font color="#ff0000">p</font></span><span style="line-height: 16.7999992370605px;">, ...);</span><span class="Apple-tab-span" style="line-height: 1.2; white-space: pre;">              </span>|<span class="Apple-tab-span" style="white-space:pre">           </span><span style="line-height: 1.2;">clEnqueueUnmapMemObject(</span></font><span style="line-height: 16.7999992370605px; font-family: Arial;">..., </span><span style="line-height: 16.7999992370605px; font-family: Arial; background-color: rgb(255, 255, 153);"><font color="#ff0000">pp</font></span><span style="line-height: 16.7999992370605px; font-family: Arial;">, ...</span><span style="line-height: 1.2; font-family: Arial;">);</span></div></div><div><br></div><div><b>Question: </b></div><div>Does this shared buffer must be used in host program just by <font color="#ff0000">pp</font>, returned by map function, but not <font color="#ff0000">p</font>?  </div><div>Does this mean that, if I put the memory to GPU, I cannot control this memory again, but just via map function?</div><div>Does have some other methods, that I can get the right to control this memory in host again?</div><div><br></div><div>Hope for helps! Thank you very much!! :-) </div><div><font face="Arial"><br></font></div><div><font face="Arial"><br></font></div><div><br></div>