Author: jvesely Date: Wed Aug 16 10:09:00 2017 New Revision: 311022 URL: http://llvm.org/viewvc/llvm-project?rev=311022&view=rev Log: 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.ves...@rutgers.edu> Reviewed-by: Aaron Watry <awa...@gmail.com> Tested-by: Aaron Watry <awa...@gmail.com> Added: libclc/trunk/amdgcn/lib/synchronization/barrier.cl Removed: libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll Modified: libclc/trunk/amdgcn/lib/SOURCES Modified: libclc/trunk/amdgcn/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/SOURCES?rev=311022&r1=311021&r2=311022&view=diff ============================================================================== --- libclc/trunk/amdgcn/lib/SOURCES (original) +++ libclc/trunk/amdgcn/lib/SOURCES Wed Aug 16 10:09:00 2017 @@ -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 Added: libclc/trunk/amdgcn/lib/synchronization/barrier.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/synchronization/barrier.cl?rev=311022&view=auto ============================================================================== --- libclc/trunk/amdgcn/lib/synchronization/barrier.cl (added) +++ libclc/trunk/amdgcn/lib/synchronization/barrier.cl Wed Aug 16 10:09:00 2017 @@ -0,0 +1,7 @@ +#include <clc/clc.h> + +_CLC_DEF void barrier(cl_mem_fence_flags flags) +{ + mem_fence(flags); + __builtin_amdgcn_s_barrier(); +} Removed: libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll?rev=311021&view=auto ============================================================================== --- libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll (original) +++ libclc/trunk/amdgcn/lib/synchronization/barrier_impl.ll (removed) @@ -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 } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits