Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/intrinsics/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SPIRVIntrinsics"
uuid = "71d1d633-e7e8-4a92-83a1-de8814b09ba8"
authors = ["Tim Besard <tim.besard@gmail.com>"]
version = "0.5.6"
version = "0.5.7"

[deps]
ExprTools = "e2ba6199-217a-4e67-a87a-7c52f15ade04"
Expand Down
1 change: 1 addition & 0 deletions lib/intrinsics/src/SPIRVIntrinsics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include("printf.jl")
include("math.jl")
include("integer.jl")
include("atomic.jl")
include("shuffle.jl")

# helper macro to import all names from this package, even non-exported ones.
macro import_all()
Expand Down
11 changes: 11 additions & 0 deletions lib/intrinsics/src/shuffle.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export sub_group_shuffle, sub_group_shuffle_xor

const gentypes = [Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Float16, Float32, Float64]

for gentype in gentypes
@eval begin
# cl_khr_subgroup_shuffle extension operations
@device_function sub_group_shuffle(x::$gentype, i::Integer) = @builtin_ccall("sub_group_shuffle", $gentype, ($gentype, Int32), x, i % Int32 - 1i32)
@device_function sub_group_shuffle_xor(x::$gentype, mask::Integer) = @builtin_ccall("sub_group_shuffle_xor", $gentype, ($gentype, Int32), x, mask % Int32)
end
end
6 changes: 5 additions & 1 deletion lib/intrinsics/src/synchronization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@ write_mem_fence(flags) = atomic_work_item_fence(flags, memory_order_release, mem

## OpenCL execution barriers

export barrier, work_group_barrier
export barrier, work_group_barrier, sub_group_barrier

@inline work_group_barrier(flags, scope = memory_scope_work_group) =
control_barrier(Scope.Workgroup, cl_scope_to_spirv(scope),
MemorySemantics.SequentiallyConsistent | mem_fence_flags_to_semantics(flags))

@inline sub_group_barrier(flags, scope = memory_scope_sub_group) =
control_barrier(Scope.Subgroup, cl_scope_to_spirv(scope),
MemorySemantics.SequentiallyConsistent | mem_fence_flags_to_semantics(flags))

barrier(flags) = work_group_barrier(flags)
Loading