diff --git a/libclc/opencl/lib/amdgcn/mem_fence/fence.cl b/libclc/opencl/lib/amdgcn/mem_fence/fence.cl index 7e5d97bc6de6..38fb15c2c1de 100644 --- a/libclc/opencl/lib/amdgcn/mem_fence/fence.cl +++ b/libclc/opencl/lib/amdgcn/mem_fence/fence.cl @@ -10,17 +10,22 @@ #include _CLC_DEF _CLC_OVERLOAD void mem_fence(cl_mem_fence_flags flags) { - int memory_scope = __opencl_get_memory_scope(flags); - int memory_order = __ATOMIC_SEQ_CST; + int memory_scope = __MEMORY_SCOPE_WRKGRP; + int memory_order = __ATOMIC_ACQ_REL; __CLC_MemorySemantics memory_semantics = __opencl_get_memory_semantics(flags); __clc_mem_fence(memory_scope, memory_order, memory_semantics); } -// We don't have separate mechanism for read and write fences _CLC_DEF _CLC_OVERLOAD void read_mem_fence(cl_mem_fence_flags flags) { - mem_fence(flags); + int memory_scope = __MEMORY_SCOPE_WRKGRP; + int memory_order = __ATOMIC_ACQUIRE; + __CLC_MemorySemantics memory_semantics = __opencl_get_memory_semantics(flags); + __clc_mem_fence(memory_scope, memory_order, memory_semantics); } _CLC_DEF _CLC_OVERLOAD void write_mem_fence(cl_mem_fence_flags flags) { - mem_fence(flags); + int memory_scope = __MEMORY_SCOPE_WRKGRP; + int memory_order = __ATOMIC_RELEASE; + __CLC_MemorySemantics memory_semantics = __opencl_get_memory_semantics(flags); + __clc_mem_fence(memory_scope, memory_order, memory_semantics); } diff --git a/libclc/opencl/lib/ptx-nvidiacl/mem_fence/fence.cl b/libclc/opencl/lib/ptx-nvidiacl/mem_fence/fence.cl index c799cf2ad7dd..38fb15c2c1de 100644 --- a/libclc/opencl/lib/ptx-nvidiacl/mem_fence/fence.cl +++ b/libclc/opencl/lib/ptx-nvidiacl/mem_fence/fence.cl @@ -10,17 +10,22 @@ #include _CLC_DEF _CLC_OVERLOAD void mem_fence(cl_mem_fence_flags flags) { - int memory_scope = __opencl_get_memory_scope(flags); - int memory_order = __ATOMIC_SEQ_CST; + int memory_scope = __MEMORY_SCOPE_WRKGRP; + int memory_order = __ATOMIC_ACQ_REL; __CLC_MemorySemantics memory_semantics = __opencl_get_memory_semantics(flags); __clc_mem_fence(memory_scope, memory_order, memory_semantics); } -// We do not have separate mechanism for read and write fences. _CLC_DEF _CLC_OVERLOAD void read_mem_fence(cl_mem_fence_flags flags) { - mem_fence(flags); + int memory_scope = __MEMORY_SCOPE_WRKGRP; + int memory_order = __ATOMIC_ACQUIRE; + __CLC_MemorySemantics memory_semantics = __opencl_get_memory_semantics(flags); + __clc_mem_fence(memory_scope, memory_order, memory_semantics); } _CLC_DEF _CLC_OVERLOAD void write_mem_fence(cl_mem_fence_flags flags) { - mem_fence(flags); + int memory_scope = __MEMORY_SCOPE_WRKGRP; + int memory_order = __ATOMIC_RELEASE; + __CLC_MemorySemantics memory_semantics = __opencl_get_memory_semantics(flags); + __clc_mem_fence(memory_scope, memory_order, memory_semantics); }