-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathsynchronization.jl
48 lines (40 loc) · 1.52 KB
/
synchronization.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
sync_workgroup()
Waits until all wavefronts in a workgroup have reached this call.
"""
@inline sync_workgroup() =
ccall("llvm.amdgcn.s.barrier", llvmcall, Cvoid, ())
"""
sync_workgroup_count(predicate::Cint)::Cint
Identical to `sync_workgroup`, with the additional feature
that it evaluates the predicate for all workitems in the workgroup
and returns the number of workitems for which predicate evaluates to non-zero.
"""
@inline function sync_workgroup_count(predicate::Cint)::Cint
ccall(
"extern __ockl_wgred_add_i32", llvmcall, Cint, (Cint,),
__not(__not(predicate)))
end
"""
sync_workgroup_and(predicate::Cint)::Cint
Identical to `sync_workgroup`, with the additional feature
that it evaluates the predicate for all workitems in the workgroup
and returns non-zero if and only if predicate evaluates to non-zero for all of them.
"""
@inline function sync_workgroup_and(predicate::Cint)::Cint
ccall(
"extern __ockl_wgred_and_i32", llvmcall, Cint, (Cint,),
__not(__not(predicate)))
end
"""
sync_workgroup_or(predicate::Cint)::Cint
Identical to `sync_workgroup`, with the additional feature
that it evaluates the predicate for all workitems in the workgroup
and returns non-zero if and only if predicate evaluates to non-zero for any of them.
"""
@inline function sync_workgroup_or(predicate::Cint)::Cint
ccall(
"extern __ockl_wgred_or_i32", llvmcall, Cint, (Cint,),
__not(__not(predicate)))
end
@inline __not(x::Cint)::Cint = ifelse(iszero(x), one(x), zero(x))