[Libclc-dev] [PATCH 1/1] r600: Add fence implementation, rework barrier
j.ketema at imperial.ac.uk
Wed Apr 30 14:27:36 PDT 2014
>> My original approach implemented read/write fences by just calling
>> mem_fence(). That should take care of both using only seq_cst and
>> duplicate labels. I can post is as a v2 if you are ok with a patch that
>> is not really useful on its own.
> You can't use the LLVM atomic fence instruction for this. For reasons I do not understand, the atomic fence LLVM instruction only impacts the ordering of other atomic instructions, but OpenCL mem_fence is for all memory accesses
I don’t think this is totally accurate, as the LLVM atomic orderings — and the fence takes an ordering argument — are intended to implement C++11 atomic orderings and those put requirements on the writes to non-atomic memory locations. The IR language reference heavily leans on the C++11 spec for this reason . However, the OpenCL mem_fence also has a requirement on the reads that were issued before the fence, which is something that is not required by any of the C++11 orderings. I’m not totally confident in stating this, but because of this read “issue” it seems that the llvm fence cannot be used to implement OpenCL’s mem_fence.
More information about the Libclc-dev