On 01/11/2013 10:44 AM, Vincent Danjean wrote: > For such simple task, an atomic operation when available would be > far more efficient (new __atomic... or old __sync... operations of > gcc to avoid to code assembly for each processor)
Sure, if the refcounting was a bottleneck we should use the atomic instructions, if available. But I think it will never be one in a realistic OpenCL app so I wouldn't worry about this. >> If your two threads release the same object "handle" more times than they >> have called the retain functions, it is a bug in your OpenCL application, >> isn't it? > > I agree. > If the lock is extented to include the test that release the data, > you will then always release the data. But the final refcount will still > be -1, something that indicate a bug from my point of view. Yes, we can add a min() or a saturating decrement there if this is problem. However, I fail to see the issue: when the refcount reaches 0 the object is freed by the clReleaseXXX(objecT). If your other thread again decrements the refcount (of the free'd object) and manages to decrement it to -1 without crashing, then your buggy OpenCL app has just made an invalid OpenCL object more invalid. -- Pekka ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ pocl-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pocl-devel
