Skip to content

Commit 945a1ae

Browse files
authored
Add MemoryFlagDevice to KA.jl's synchronization primitive. (#609)
KernelAbstractions (influenced by CUDA) states > After a statement all read and writes to global and local memory > from each thread in the workgroup are visible in from all other threads in the > workgroup.
1 parent 9c6d582 commit 945a1ae

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/MetalKernels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ end
189189
## other
190190

191191
@device_override @inline function KA.__synchronize()
192-
threadgroup_barrier(Metal.MemoryFlagThreadGroup)
192+
threadgroup_barrier(Metal.MemoryFlagDevice | Metal.MemoryFlagThreadGroup)
193193
end
194194

195195
@device_override @inline function KA.__print(args...)

src/device/intrinsics/synchronization.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ end
3434

3535

3636
"""
37-
threadgroup_barrier(flag::MemoryFlags=MemoryFlagNone)
37+
threadgroup_barrier(flag=MemoryFlagNone)
3838
3939
Synchronize all threads in a threadgroup.
4040
4141
Possible flags that affect the memory synchronization behavior are found in [`MemoryFlags`](@ref)
4242
"""
43-
@inline threadgroup_barrier(flag::MemoryFlags=MemoryFlagNone) =
43+
@inline threadgroup_barrier(flag=MemoryFlagNone) =
4444
ccall("extern air.wg.barrier", llvmcall, Cvoid, (Cuint, Cuint, ), flag, UInt32(1))
4545

4646
"""
47-
simdgroup_barrier(flag::MemoryFlags=MemoryFlagNone)
47+
simdgroup_barrier(flag=MemoryFlagNone)
4848
4949
Synchronize all threads in a SIMD-group.
5050
5151
Possible flags that affect the memory synchronization behavior are found in [`MemoryFlags`](@ref)
5252
"""
53-
@inline simdgroup_barrier(flag::MemoryFlags=MemoryFlagNone) =
53+
@inline simdgroup_barrier(flag=MemoryFlagNone) =
5454
ccall("extern air.simdgroup.barrier", llvmcall, Cvoid, (Cuint, Cuint, ), flag, UInt32(1))

0 commit comments

Comments
 (0)