[libclc] 06/92: amdgcn: rewrite barrier() using fence and clang __builtin_amdgcn_s_barrier

Andreas Boll aboll-guest at moszumanska.debian.org
Mon Nov 6 15:11:55 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 7d4c1a3b06565fa7b102773da31f056ffe7fc264
Author: Jan Vesely <jan.vesely at rutgers.edu>
Date:   Wed Aug 16 17:09:00 2017 +0000

    amdgcn: rewrite barrier() using fence and clang __builtin_amdgcn_s_barrier
    
    Specs require using fences when barrier() is invoked:
    "The barrier function will either flush any variables stored in local memory
    or queue a memory fence to ensure correct ordering of memory operations to local memory."
    and
    "The barrier function will queue a memory fence to ensure correct ordering
    of memory operations to global memory."
    
    Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
    Reviewed-by: Aaron Watry <awatry at gmail.com>
    Tested-by: Aaron Watry <awatry at gmail.com>
    
    git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@311022 91177308-0d34-0410-b5e6-96231b3b80d8
---
 amdgcn/lib/SOURCES                         |  2 +-
 amdgcn/lib/synchronization/barrier.cl      |  7 +++++++
 amdgcn/lib/synchronization/barrier_impl.ll | 32 ------------------------------
 3 files changed, 8 insertions(+), 33 deletions(-)

diff --git a/amdgcn/lib/SOURCES b/amdgcn/lib/SOURCES
index 24f5949..a1f9483 100644
--- a/amdgcn/lib/SOURCES
+++ b/amdgcn/lib/SOURCES
@@ -1,7 +1,7 @@
 math/ldexp.cl
 mem_fence/fence.cl
 mem_fence/waitcnt.ll
-synchronization/barrier_impl.ll
+synchronization/barrier.cl
 workitem/get_global_offset.cl
 workitem/get_group_id.cl
 workitem/get_global_size.ll
diff --git a/amdgcn/lib/synchronization/barrier.cl b/amdgcn/lib/synchronization/barrier.cl
new file mode 100644
index 0000000..e2f3c13
--- /dev/null
+++ b/amdgcn/lib/synchronization/barrier.cl
@@ -0,0 +1,7 @@
+#include <clc/clc.h>
+
+_CLC_DEF void barrier(cl_mem_fence_flags flags)
+{
+	mem_fence(flags);
+	__builtin_amdgcn_s_barrier();
+}
diff --git a/amdgcn/lib/synchronization/barrier_impl.ll b/amdgcn/lib/synchronization/barrier_impl.ll
deleted file mode 100644
index 1809edd..0000000
--- a/amdgcn/lib/synchronization/barrier_impl.ll
+++ /dev/null
@@ -1,32 +0,0 @@
-declare i32 @__clc_clk_local_mem_fence() #1
-declare i32 @__clc_clk_global_mem_fence() #1
-declare void @llvm.amdgcn.s.barrier() #0
-
-define void @barrier(i32 %flags) #2 {
-barrier_local_test:
-  %CLK_LOCAL_MEM_FENCE = call i32 @__clc_clk_local_mem_fence()
-  %0 = and i32 %flags, %CLK_LOCAL_MEM_FENCE
-  %1 = icmp ne i32 %0, 0
-  br i1 %1, label %barrier_local, label %barrier_global_test
-
-barrier_local:
-  call void @llvm.amdgcn.s.barrier()
-  br label %barrier_global_test
-
-barrier_global_test:
-  %CLK_GLOBAL_MEM_FENCE = call i32 @__clc_clk_global_mem_fence()
-  %2 = and i32 %flags, %CLK_GLOBAL_MEM_FENCE
-  %3 = icmp ne i32 %2, 0
-  br i1 %3, label %barrier_global, label %done
-
-barrier_global:
-  call void @llvm.amdgcn.s.barrier()
-  br label %done
-
-done:
-  ret void
-}
-
-attributes #0 = { nounwind convergent }
-attributes #1 = { nounwind alwaysinline }
-attributes #2 = { nounwind convergent alwaysinline }

-- 
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