[libclc] 48/92: Implement mem_fence on ptx

Andreas Boll aboll-guest at moszumanska.debian.org
Mon Nov 6 15:12:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

aboll-guest pushed a commit to branch master
in repository libclc.

commit 7b3a840998e78af1066387b9f3308715b8f0619c
Author: Jeroen Ketema <j.ketema at xs4all.nl>
Date:   Mon Oct 9 19:43:04 2017 +0000

    Implement mem_fence on ptx
    
    PTX does not differentiate between read and write fences. Hence, these a
    lowered to a mem_fence call. The mem_fence function compiles to the
    “member.cta” instruction, which commits all outstanding reads and writes
    of a thread such that these become visible to all other threads in the same
    CTA (i.e., work-group). The instruction does not differentiate between
    global and local memory. Hence, the flags parameter is ignored, except
    for deciding whether a “member.cta” instruction should be issued at all.
    
    Reviewed-by: Jan Vesely <jan.vesely at rutgers.edu>
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@315235 91177308-0d34-0410-b5e6-96231b3b80d8
---
 ptx-nvidiacl/lib/SOURCES            |  1 +
 ptx-nvidiacl/lib/mem_fence/fence.cl | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/ptx-nvidiacl/lib/SOURCES b/ptx-nvidiacl/lib/SOURCES
index ce26bcb..c92c2a6 100644
--- a/ptx-nvidiacl/lib/SOURCES
+++ b/ptx-nvidiacl/lib/SOURCES
@@ -1,3 +1,4 @@
+mem_fence/fence.cl
 synchronization/barrier.cl
 workitem/get_global_id.cl
 workitem/get_group_id.cl
diff --git a/ptx-nvidiacl/lib/mem_fence/fence.cl b/ptx-nvidiacl/lib/mem_fence/fence.cl
new file mode 100644
index 0000000..16b0391
--- /dev/null
+++ b/ptx-nvidiacl/lib/mem_fence/fence.cl
@@ -0,0 +1,15 @@
+#include <clc/clc.h>
+
+_CLC_DEF void mem_fence(cl_mem_fence_flags flags) {
+   if (flags & (CLK_GLOBAL_MEM_FENCE | CLK_LOCAL_MEM_FENCE))
+     __nvvm_membar_cta();
+}
+
+// We do not have separate mechanism for read and write fences.
+_CLC_DEF void read_mem_fence(cl_mem_fence_flags flags) {
+  mem_fence(flags);
+}
+
+_CLC_DEF void write_mem_fence(cl_mem_fence_flags flags) {
+  mem_fence(flags);
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/libclc.git



More information about the Pkg-opencl-commits mailing list