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
9 changes: 2 additions & 7 deletions ext/Metal/shuffle_vote.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const SHFL_DISPATCH = Dict(
Down => :(Metal.simd_shuffle_down)
)

for T in (:Float32, :Int32, :UInt32, :Float16, :Int16, :UInt16)
for T in (:Float32, :Int32, :UInt32)
for (direction, metal_fname) in SHFL_DISPATCH
@eval begin
Base.Experimental.@overlay Metal.method_table @inline _shfl(::Type{$direction}, mask, val::$T, src) =
Expand All @@ -21,13 +21,8 @@ end
# Will update when they are part of official release
# =======================================================================================================
simd_shuffle_map = ((Float32, "f32"),
(Float16, "f16"),
(Int32, "s.i32"),
(UInt32, "u.i32"),
(Int16, "s.i16"),
(UInt16, "u.i16"),
(Int8, "s.i8"),
(UInt8, "u.i8"))
(UInt32, "u.i32"))

for (jltype, suffix) in simd_shuffle_map
@eval begin
Expand Down
19 changes: 18 additions & 1 deletion test/tests/shfl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ struct ComplexType
z::Float64
end

struct ComplexTypeMetal
x::Int32
y::SubType
z::Float16
end

# ─────────────────────────────────────────────────────────────────────────────
# Helpers
# ─────────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -126,7 +132,18 @@ end
end
end

if TEST_BACKEND != "metal"
if TEST_BACKEND == "metal"
@testset "Up ComplexTypeMetal" begin
src = to_device([ComplexTypeMetal(i, SubType(Float16(i), UInt8(i)), Float16(i)) for i in 1:warpsz])
dst = to_device([ComplexTypeMetal(0, SubType(Float16(0), UInt8(0)),Float16(0.0)) for _ in 1:warpsz])
launch(shfl_up_kernel, dst, src, 1; ndrange=warpsz)
result = from_device(dst)
@test result[1] == ComplexTypeMetal(1, SubType(Float16(1), UInt8(1)), Float16(1.0))
for i in 2:warpsz
@test result[i] == ComplexTypeMetal(i - 1, SubType(Float16(i - 1), UInt8(i - 1)), Float16(i - 1))
end
end
else
@testset "Up ComplexType" begin
src = to_device([ComplexType(i, SubType(Float16(i), UInt8(i)), Float64(i)) for i in 1:warpsz])
dst = to_device([ComplexType(0, SubType(Float16(0), UInt8(0)), 0.0) for _ in 1:warpsz])
Expand Down
Loading