[libclc] r185837 - Implement barrier() builtin

Tom Stellard thomas.stellard at amd.com
Mon Jul 8 10:26:40 PDT 2013


Author: tstellar
Date: Mon Jul  8 12:26:39 2013
New Revision: 185837

URL: http://llvm.org/viewvc/llvm-project?rev=185837&view=rev
Log:
Implement barrier() builtin

Reviewed and Tested-by: Aaron Watry <awatry at gmail.com>

Added:
    libclc/trunk/r600/lib/synchronization/
    libclc/trunk/r600/lib/synchronization/barrier.cl
    libclc/trunk/r600/lib/synchronization/barrier_impl.ll
Modified:
    libclc/trunk/r600/lib/SOURCES

Modified: libclc/trunk/r600/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/SOURCES?rev=185837&r1=185836&r2=185837&view=diff
==============================================================================
--- libclc/trunk/r600/lib/SOURCES (original)
+++ libclc/trunk/r600/lib/SOURCES Mon Jul  8 12:26:39 2013
@@ -2,3 +2,5 @@ workitem/get_group_id.ll
 workitem/get_local_size.ll
 workitem/get_local_id.ll
 workitem/get_global_size.ll
+synchronization/barrier.cl
+synchronization/barrier_impl.ll

Added: libclc/trunk/r600/lib/synchronization/barrier.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/synchronization/barrier.cl?rev=185837&view=auto
==============================================================================
--- libclc/trunk/r600/lib/synchronization/barrier.cl (added)
+++ libclc/trunk/r600/lib/synchronization/barrier.cl Mon Jul  8 12:26:39 2013
@@ -0,0 +1,15 @@
+
+#include <clc/clc.h>
+
+void barrier_local(void);
+void barrier_global(void);
+
+void barrier(cl_mem_fence_flags flags) {
+  if (flags & CLK_LOCAL_MEM_FENCE) {
+    barrier_local();
+  }
+
+  if (flags & CLK_GLOBAL_MEM_FENCE) {
+    barrier_global();
+  }
+}

Added: libclc/trunk/r600/lib/synchronization/barrier_impl.ll
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/r600/lib/synchronization/barrier_impl.ll?rev=185837&view=auto
==============================================================================
--- libclc/trunk/r600/lib/synchronization/barrier_impl.ll (added)
+++ libclc/trunk/r600/lib/synchronization/barrier_impl.ll Mon Jul  8 12:26:39 2013
@@ -0,0 +1,12 @@
+declare void @llvm.AMDGPU.barrier.local() nounwind
+declare void @llvm.AMDGPU.barrier.global() nounwind
+
+define void @barrier_local() nounwind alwaysinline {
+  call void @llvm.AMDGPU.barrier.local()
+  ret void
+}
+
+define void @barrier_global() nounwind alwaysinline {
+  call void @llvm.AMDGPU.barrier.global()
+  ret void
+}





More information about the cfe-commits mailing list