@@ -34,6 +34,50 @@ for (julia_name, (spirv_name, julia_type, offset)) in [
3434 end
3535end
3636
37+
38+ # Sub-group shuffle intrinsics using a loop and @eval, matching the style of the 1D/3D value loops above
39+ export sub_group_shuffle, sub_group_shuffle_xor
40+
41+ for (jltype, llvmtype, julia_type_str) in [
42+ (Int8, " i8" , :Int8 ),
43+ (UInt8, " i8" , :UInt8 ),
44+ (Int16, " i16" , :Int16 ),
45+ (UInt16, " i16" , :UInt16 ),
46+ (Int32, " i32" , :Int32 ),
47+ (UInt32, " i32" , :UInt32 ),
48+ (Int64, " i64" , :Int64 ),
49+ (UInt64, " i64" , :UInt64 ),
50+ (Float16, " half" , :Float16 ),
51+ (Float32, " float" , :Float32 ),
52+ (Float64, " double" ,:Float64 )
53+ ]
54+ @eval begin
55+ export sub_group_shuffle, sub_group_shuffle_xor
56+ function sub_group_shuffle (x:: $jltype , idx:: Integer )
57+ Base. llvmcall (
58+ $ ("""
59+ declare $llvmtype @__spirv_GroupNonUniformShuffle(i32, $llvmtype , i32)
60+ define $llvmtype @entry($llvmtype %val, i32 %idx) #0 {
61+ %res = call $llvmtype @__spirv_GroupNonUniformShuffle(i32 3, $llvmtype %val, i32 %idx)
62+ ret $llvmtype %res
63+ }
64+ attributes #0 = { alwaysinline }
65+ """ , " entry" ), $ julia_type_str, Tuple{$ julia_type_str, Int32}, x, idx % Int32 - 1 i32)
66+ end
67+ function sub_group_shuffle_xor (x:: $jltype , mask:: Integer )
68+ Base. llvmcall (
69+ $ ("""
70+ declare $llvmtype @__spirv_GroupNonUniformShuffleXor(i32, $llvmtype , i32)
71+ define $llvmtype @entry($llvmtype %val, i32 %mask) #0 {
72+ %res = call $llvmtype @__spirv_GroupNonUniformShuffleXor(i32 3, $llvmtype %val, i32 %mask)
73+ ret $llvmtype %res
74+ }
75+ attributes #0 = { alwaysinline }
76+ """ , " entry" ), $ julia_type_str, Tuple{$ julia_type_str, Int32}, x, mask % UInt32)
77+ end
78+ end
79+ end
80+
3781# 3D values
3882for (julia_name, (spirv_name, offset)) in [
3983 # indices
0 commit comments