1// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s 2 3//===----------------------------------------------------------------------===// 4// spv.GroupNonUniformBallot 5//===----------------------------------------------------------------------===// 6 7func @group_non_uniform_ballot(%predicate: i1) -> vector<4xi32> { 8 // CHECK: %{{.*}} = spv.GroupNonUniformBallot "Workgroup" %{{.*}}: vector<4xi32> 9 %0 = spv.GroupNonUniformBallot "Workgroup" %predicate : vector<4xi32> 10 return %0: vector<4xi32> 11} 12 13// ----- 14 15func @group_non_uniform_ballot(%predicate: i1) -> vector<4xi32> { 16 // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} 17 %0 = spv.GroupNonUniformBallot "Device" %predicate : vector<4xi32> 18 return %0: vector<4xi32> 19} 20 21// ----- 22 23func @group_non_uniform_ballot(%predicate: i1) -> vector<4xsi32> { 24 // expected-error @+1 {{op result #0 must be vector of 8/16/32/64-bit signless/unsigned integer values of length 4, but got 'vector<4xsi32>'}} 25 %0 = spv.GroupNonUniformBallot "Workgroup" %predicate : vector<4xsi32> 26 return %0: vector<4xsi32> 27} 28 29// ----- 30 31//===----------------------------------------------------------------------===// 32// spv.NonUniformGroupBroadcast 33//===----------------------------------------------------------------------===// 34 35func @group_non_uniform_broadcast_scalar(%value: f32) -> f32 { 36 %one = spv.constant 1 : i32 37 // CHECK: spv.GroupNonUniformBroadcast "Workgroup" %{{.*}}, %{{.*}} : f32, i32 38 %0 = spv.GroupNonUniformBroadcast "Workgroup" %value, %one : f32, i32 39 return %0: f32 40} 41 42// ----- 43 44func @group_non_uniform_broadcast_vector(%value: vector<4xf32>) -> vector<4xf32> { 45 %one = spv.constant 1 : i32 46 // CHECK: spv.GroupNonUniformBroadcast "Subgroup" %{{.*}}, %{{.*}} : vector<4xf32>, i32 47 %0 = spv.GroupNonUniformBroadcast "Subgroup" %value, %one : vector<4xf32>, i32 48 return %0: vector<4xf32> 49} 50 51// ----- 52 53func @group_non_uniform_broadcast_negative_scope(%value: f32, %localid: i32 ) -> f32 { 54 %one = spv.constant 1 : i32 55 // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} 56 %0 = spv.GroupNonUniformBroadcast "Device" %value, %one : f32, i32 57 return %0: f32 58} 59 60// ----- 61 62func @group_non_uniform_broadcast_negative_non_const(%value: f32, %localid: i32) -> f32 { 63 // expected-error @+1 {{id must be the result of a constant op}} 64 %0 = spv.GroupNonUniformBroadcast "Subgroup" %value, %localid : f32, i32 65 return %0: f32 66} 67 68// ----- 69 70//===----------------------------------------------------------------------===// 71// spv.GroupNonUniformElect 72//===----------------------------------------------------------------------===// 73 74// CHECK-LABEL: @group_non_uniform_elect 75func @group_non_uniform_elect() -> i1 { 76 // CHECK: %{{.+}} = spv.GroupNonUniformElect "Workgroup" : i1 77 %0 = spv.GroupNonUniformElect "Workgroup" : i1 78 return %0: i1 79} 80 81// ----- 82 83func @group_non_uniform_elect() -> i1 { 84 // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} 85 %0 = spv.GroupNonUniformElect "CrossDevice" : i1 86 return %0: i1 87} 88 89// ----- 90 91//===----------------------------------------------------------------------===// 92// spv.GroupNonUniformFAdd 93//===----------------------------------------------------------------------===// 94 95// CHECK-LABEL: @group_non_uniform_fadd_reduce 96func @group_non_uniform_fadd_reduce(%val: f32) -> f32 { 97 // CHECK: %{{.+}} = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %{{.+}} : f32 98 %0 = spv.GroupNonUniformFAdd "Workgroup" "Reduce" %val : f32 99 return %0: f32 100} 101 102// CHECK-LABEL: @group_non_uniform_fadd_clustered_reduce 103func @group_non_uniform_fadd_clustered_reduce(%val: vector<2xf32>) -> vector<2xf32> { 104 %four = spv.constant 4 : i32 105 // CHECK: %{{.+}} = spv.GroupNonUniformFAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xf32> 106 %0 = spv.GroupNonUniformFAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xf32> 107 return %0: vector<2xf32> 108} 109 110//===----------------------------------------------------------------------===// 111// spv.GroupNonUniformFMul 112//===----------------------------------------------------------------------===// 113 114// CHECK-LABEL: @group_non_uniform_fmul_reduce 115func @group_non_uniform_fmul_reduce(%val: f32) -> f32 { 116 // CHECK: %{{.+}} = spv.GroupNonUniformFMul "Workgroup" "Reduce" %{{.+}} : f32 117 %0 = spv.GroupNonUniformFMul "Workgroup" "Reduce" %val : f32 118 return %0: f32 119} 120 121// CHECK-LABEL: @group_non_uniform_fmul_clustered_reduce 122func @group_non_uniform_fmul_clustered_reduce(%val: vector<2xf32>) -> vector<2xf32> { 123 %four = spv.constant 4 : i32 124 // CHECK: %{{.+}} = spv.GroupNonUniformFMul "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xf32> 125 %0 = spv.GroupNonUniformFMul "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xf32> 126 return %0: vector<2xf32> 127} 128 129// ----- 130 131//===----------------------------------------------------------------------===// 132// spv.GroupNonUniformFMax 133//===----------------------------------------------------------------------===// 134 135// CHECK-LABEL: @group_non_uniform_fmax_reduce 136func @group_non_uniform_fmax_reduce(%val: f32) -> f32 { 137 // CHECK: %{{.+}} = spv.GroupNonUniformFMax "Workgroup" "Reduce" %{{.+}} : f32 138 %0 = spv.GroupNonUniformFMax "Workgroup" "Reduce" %val : f32 139 return %0: f32 140} 141 142// ----- 143 144//===----------------------------------------------------------------------===// 145// spv.GroupNonUniformFMin 146//===----------------------------------------------------------------------===// 147 148// CHECK-LABEL: @group_non_uniform_fmin_reduce 149func @group_non_uniform_fmin_reduce(%val: f32) -> f32 { 150 // CHECK: %{{.+}} = spv.GroupNonUniformFMin "Workgroup" "Reduce" %{{.+}} : f32 151 %0 = spv.GroupNonUniformFMin "Workgroup" "Reduce" %val : f32 152 return %0: f32 153} 154 155// ----- 156 157//===----------------------------------------------------------------------===// 158// spv.GroupNonUniformIAdd 159//===----------------------------------------------------------------------===// 160 161// CHECK-LABEL: @group_non_uniform_iadd_reduce 162func @group_non_uniform_iadd_reduce(%val: i32) -> i32 { 163 // CHECK: %{{.+}} = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %{{.+}} : i32 164 %0 = spv.GroupNonUniformIAdd "Workgroup" "Reduce" %val : i32 165 return %0: i32 166} 167 168// CHECK-LABEL: @group_non_uniform_iadd_clustered_reduce 169func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> { 170 %four = spv.constant 4 : i32 171 // CHECK: %{{.+}} = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32> 172 %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32> 173 return %0: vector<2xi32> 174} 175 176// ----- 177 178func @group_non_uniform_iadd_reduce(%val: i32) -> i32 { 179 // expected-error @+1 {{execution scope must be 'Workgroup' or 'Subgroup'}} 180 %0 = spv.GroupNonUniformIAdd "Device" "Reduce" %val : i32 181 return %0: i32 182} 183 184// ----- 185 186func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> { 187 // expected-error @+1 {{cluster size operand must be provided for 'ClusteredReduce' group operation}} 188 %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val : vector<2xi32> 189 return %0: vector<2xi32> 190} 191 192// ----- 193 194func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>, %size: i32) -> vector<2xi32> { 195 // expected-error @+1 {{cluster size operand must come from a constant op}} 196 %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%size) : vector<2xi32> 197 return %0: vector<2xi32> 198} 199 200// ----- 201 202func @group_non_uniform_iadd_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> { 203 %five = spv.constant 5 : i32 204 // expected-error @+1 {{cluster size operand must be a power of two}} 205 %0 = spv.GroupNonUniformIAdd "Workgroup" "ClusteredReduce" %val cluster_size(%five) : vector<2xi32> 206 return %0: vector<2xi32> 207} 208 209// ----- 210 211//===----------------------------------------------------------------------===// 212// spv.GroupNonUniformIMul 213//===----------------------------------------------------------------------===// 214 215// CHECK-LABEL: @group_non_uniform_imul_reduce 216func @group_non_uniform_imul_reduce(%val: i32) -> i32 { 217 // CHECK: %{{.+}} = spv.GroupNonUniformIMul "Workgroup" "Reduce" %{{.+}} : i32 218 %0 = spv.GroupNonUniformIMul "Workgroup" "Reduce" %val : i32 219 return %0: i32 220} 221 222// CHECK-LABEL: @group_non_uniform_imul_clustered_reduce 223func @group_non_uniform_imul_clustered_reduce(%val: vector<2xi32>) -> vector<2xi32> { 224 %four = spv.constant 4 : i32 225 // CHECK: %{{.+}} = spv.GroupNonUniformIMul "Workgroup" "ClusteredReduce" %{{.+}} cluster_size(%{{.+}}) : vector<2xi32> 226 %0 = spv.GroupNonUniformIMul "Workgroup" "ClusteredReduce" %val cluster_size(%four) : vector<2xi32> 227 return %0: vector<2xi32> 228} 229 230// ----- 231 232//===----------------------------------------------------------------------===// 233// spv.GroupNonUniformSMax 234//===----------------------------------------------------------------------===// 235 236// CHECK-LABEL: @group_non_uniform_smax_reduce 237func @group_non_uniform_smax_reduce(%val: i32) -> i32 { 238 // CHECK: %{{.+}} = spv.GroupNonUniformSMax "Workgroup" "Reduce" %{{.+}} : i32 239 %0 = spv.GroupNonUniformSMax "Workgroup" "Reduce" %val : i32 240 return %0: i32 241} 242 243// ----- 244 245//===----------------------------------------------------------------------===// 246// spv.GroupNonUniformSMin 247//===----------------------------------------------------------------------===// 248 249// CHECK-LABEL: @group_non_uniform_smin_reduce 250func @group_non_uniform_smin_reduce(%val: i32) -> i32 { 251 // CHECK: %{{.+}} = spv.GroupNonUniformSMin "Workgroup" "Reduce" %{{.+}} : i32 252 %0 = spv.GroupNonUniformSMin "Workgroup" "Reduce" %val : i32 253 return %0: i32 254} 255 256// ----- 257 258//===----------------------------------------------------------------------===// 259// spv.GroupNonUniformUMax 260//===----------------------------------------------------------------------===// 261 262// CHECK-LABEL: @group_non_uniform_umax_reduce 263func @group_non_uniform_umax_reduce(%val: i32) -> i32 { 264 // CHECK: %{{.+}} = spv.GroupNonUniformUMax "Workgroup" "Reduce" %{{.+}} : i32 265 %0 = spv.GroupNonUniformUMax "Workgroup" "Reduce" %val : i32 266 return %0: i32 267} 268 269// ----- 270 271//===----------------------------------------------------------------------===// 272// spv.GroupNonUniformUMin 273//===----------------------------------------------------------------------===// 274 275// CHECK-LABEL: @group_non_uniform_umin_reduce 276func @group_non_uniform_umin_reduce(%val: i32) -> i32 { 277 // CHECK: %{{.+}} = spv.GroupNonUniformUMin "Workgroup" "Reduce" %{{.+}} : i32 278 %0 = spv.GroupNonUniformUMin "Workgroup" "Reduce" %val : i32 279 return %0: i32 280} 281