Skip to content

Commit

Permalink
Implement barrier() builtin
Browse files Browse the repository at this point in the history
Reviewed and Tested-by: Aaron Watry <[email protected]>

llvm-svn: 185837
  • Loading branch information
tstellarAMD committed Jul 8, 2013
1 parent a4cadba commit 3a81b5d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libclc/r600/lib/SOURCES
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions libclc/r600/lib/synchronization/barrier.cl
Original file line number Diff line number Diff line change
@@ -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();
}
}
12 changes: 12 additions & 0 deletions libclc/r600/lib/synchronization/barrier_impl.ll
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 3a81b5d

Please sign in to comment.