comparison libclc/amdgcn/lib/mem_fence/fence.cl @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
15 #else 15 #else
16 # define __waitcnt(x) __clc_amdgcn_s_waitcnt(x) 16 # define __waitcnt(x) __clc_amdgcn_s_waitcnt(x)
17 _CLC_DEF void __clc_amdgcn_s_waitcnt(unsigned) __asm("llvm.amdgcn.s.waitcnt"); 17 _CLC_DEF void __clc_amdgcn_s_waitcnt(unsigned) __asm("llvm.amdgcn.s.waitcnt");
18 #endif 18 #endif
19 19
20 _CLC_DEF void mem_fence(cl_mem_fence_flags flags) 20 _CLC_DEF _CLC_OVERLOAD void mem_fence(cl_mem_fence_flags flags) {
21 { 21 if (flags & CLK_GLOBAL_MEM_FENCE) {
22 if (flags & CLK_GLOBAL_MEM_FENCE) { 22 // scalar loads are counted with LGKM but we don't know whether
23 // scalar loads are counted with LGKM but we don't know whether 23 // the compiler turned any loads to scalar
24 // the compiler turned any loads to scalar 24 __waitcnt(0);
25 __waitcnt(0); 25 } else if (flags & CLK_LOCAL_MEM_FENCE)
26 } else if (flags & CLK_LOCAL_MEM_FENCE) 26 __waitcnt(0xff); // LGKM is [12:8]
27 __waitcnt(0xff); // LGKM is [12:8]
28 } 27 }
29 #undef __waitcnt 28 #undef __waitcnt
30 29
31 // We don't have separate mechanism for read and write fences 30 // We don't have separate mechanism for read and write fences
32 _CLC_DEF void read_mem_fence(cl_mem_fence_flags flags) 31 _CLC_DEF _CLC_OVERLOAD void read_mem_fence(cl_mem_fence_flags flags) {
33 { 32 mem_fence(flags);
34 mem_fence(flags);
35 } 33 }
36 34
37 _CLC_DEF void write_mem_fence(cl_mem_fence_flags flags) 35 _CLC_DEF _CLC_OVERLOAD void write_mem_fence(cl_mem_fence_flags flags) {
38 { 36 mem_fence(flags);
39 mem_fence(flags);
40 } 37 }