{"id":6167,"date":"2014-04-13T04:36:25","date_gmt":"2014-04-13T04:36:25","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/opencl-user-events-cant-release-objects-collection-of-common-programming-errors\/"},"modified":"2014-04-13T04:36:25","modified_gmt":"2014-04-13T04:36:25","slug":"opencl-user-events-cant-release-objects-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/13\/opencl-user-events-cant-release-objects-collection-of-common-programming-errors\/","title":{"rendered":"OpenCL User Events \/ Cant Release Objects?-Collection of common programming errors"},"content":{"rendered":"<p>Consider the example that they give.<\/p>\n<p>We have an in-order queue and we create a user event:<\/p>\n<pre><code>ev1 = clCreateUserEvent(ctx, NULL); \/\/ (1)\n<\/code><\/pre>\n<p>We then want to enqueue a write to a buffer, but we want it to wait for our event:<\/p>\n<pre><code>clEnqueueWriteBuffer(cq, buf1, CL_FALSE, ..., 1, &amp;ev1, NULL); \/\/ (2)\n<\/code><\/pre>\n<p>We want to write another buffer after the buffer in the previous one (which is waiting on our event):<\/p>\n<pre><code>clEnqueueWriteBuffer(cq, buf2, CL_FALSE,...); \/\/ (3)\n<\/code><\/pre>\n<p>We release the buffer from the second <code>clEnqueueWriteBuffer<\/code> which hasn&#8217;t gone through yet because we are still waiting for the user event. In this case (4) happens before (3), so we don&#8217;t know what will happen as the memory object is freed.<\/p>\n<pre><code>clReleaseMemObject(buf2); \/\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Consider the example that they give. We have an in-order queue and we create a user event: ev1 = clCreateUserEvent(ctx, NULL); \/\/ (1) We then want to enqueue a write to a buffer, but we want it to wait for our event: clEnqueueWriteBuffer(cq, buf1, CL_FALSE, &#8230;, 1, &amp;ev1, NULL); \/\/ (2) We want to write [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6167","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6167"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6167\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}