Skip to content

Commit

Permalink
testing: merge all gpu invalid filechecks (#1138)
Browse files Browse the repository at this point in the history
Except some cases that are now handled by traits.
  • Loading branch information
PapyChacal committed Jun 15, 2023
1 parent b14e59a commit 41eddeb
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 172 deletions.
11 changes: 0 additions & 11 deletions tests/filecheck/dialects/gpu/all_reduce_neither.mlir

This file was deleted.

12 changes: 0 additions & 12 deletions tests/filecheck/dialects/gpu/all_reduce_types.mlir

This file was deleted.

8 changes: 0 additions & 8 deletions tests/filecheck/dialects/gpu/alloc_wrong_dynamic_size.mlir

This file was deleted.

6 changes: 0 additions & 6 deletions tests/filecheck/dialects/gpu/dimension_unknown.mlir

This file was deleted.

118 changes: 118 additions & 0 deletions tests/filecheck/dialects/gpu/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,121 @@
}) {} : () -> ()

// CHECK: Expected ['index', 'index'], got ['index']. A gpu.all_reduce's body must have two arguments matching the result type.

// -----

"builtin.module"()({
"gpu.module"()({
%init = "arith.constant"() {"value" = 42 : index} : () -> index
%sum = "gpu.all_reduce"(%init) ({}) : (index) -> index
"gpu.module_end"() : () -> ()
}) {"sym_name" = "gpu"} : () -> ()
}) {} : () -> ()

// CHECK: gpu.all_reduce need either a non empty body or an op attribute.

// -----

"builtin.module"()({
"gpu.module"()({
%init = "arith.constant"() {"value" = 42 : index} : () -> index
%sum = "gpu.all_reduce"(%init) ({
}) {"op" = #gpu<all_reduce_op add>} : (index) -> f32
"gpu.module_end"() : () -> ()
}) {"sym_name" = "gpu"} : () -> ()
}) {} : () -> ()

// CHECK: Type mismatch: result type is f32, operand type is index. They must be the same type for gpu.all_reduce

// -----

"builtin.module"() ({
%0 = "arith.constant"() {"value" = 10 : index} : () -> index
%gdmemref = "gpu.alloc"(%0, %0, %0) {"operand_segment_sizes" = array<i32: 0, 3, 0>} : (index, index, index) -> memref<10x10x10xf64>
}) : () -> ()

// CHECK: Expected 0 dynamic sizes, got 3. All dynamic sizes need to be set in the alloc operation.

// -----

"builtin.module"() ({
}) {"wrong_dim" = #gpu<dim w>}: () -> ()

// CHECK: Unexpected dim w. A gpu dim can only be x, y, or z

// -----

"builtin.module"()({
"gpu.module"()({
%n = "arith.constant"() {"value" = 13 : index} : () -> index
%one = "arith.constant"() {"value" = 1 : index} : () -> index

"gpu.launch"(%one, %one, %n, %one, %one, %one) ({
^bb0(%bx : index, %by : index, %bz : index,
%tx : index, %ty : index, %tz : index):
%sum = "gpu.all_reduce"(%tx) ({
}) {"op" = #gpu<all_reduce_op add>} : (index) -> index
%final = "arith.muli"(%sum, %one) : (index, index) -> index
"gpu.terminator"() : () -> ()
}) {"operand_segment_sizes" = array<i32: 0, 1, 1, 1, 1, 1, 1, 0>} : (index, index, index, index, index, index) -> ()
"gpu.module_end"() : () -> ()
}) {"sym_name" = "gpu"} : () -> ()
}) {} : () -> ()

// CHECK: Expected [12 x index], got ['index', 'index', 'index', 'index', 'index', 'index']. gpu.launch's body arguments are 12 index arguments, with 3 block indices, 3 block sizes, 3 thread indices, and 3 thread counts

// -----

"builtin.module"()({
"gpu.module"()({
%n = "arith.constant"() {"value" = 13 : index} : () -> index
%one = "arith.constant"() {"value" = 1 : index} : () -> index

"gpu.launch"(%one, %one, %n, %one, %one, %one) ({})
{"operand_segment_sizes" = array<i32: 0, 1, 1, 1, 1, 1, 1, 0>} : (index, index, index, index, index, index) -> ()
"gpu.module_end"() : () -> ()
}) {"sym_name" = "gpu"} : () -> ()
}) {} : () -> ()

// CHECK: gpu.launch requires a non-empty body.

// -----

"builtin.module"() ({
%memref = "memref.alloc"() {"alignment" = 0 : i64, "operand_segment_sizes" = array<i32: 0, 0>} : () -> memref<10x10xi32>
%ten = "arith.constant"() {"value" = 10 : index} : () -> index
%gmemref = "gpu.alloc"(%ten, %ten) {"operand_segment_sizes" = array<i32: 0, 2, 0>} : (index, index) -> memref<?x?xi32>

"gpu.memcpy"(%memref, %gmemref) {"operand_segment_sizes" = array<i32: 0, 1, 1>} : (memref<10x10xi32>, memref<?x?xi32>) -> ()

}) : () -> ()

// CHECK: Expected memref<10x10xi32>, got memref<?x?xi32>. gpu.memcpy source and destination types must match.

// -----

"builtin.module"()({
"gpu.module"()({
"gpu.module_end"() : () -> ()
}) {} : () -> ()
}) {} : () -> ()

// CHECK: attribute sym_name expected

// -----


"builtin.module"()({
"gpu.module"()({
%init = "arith.constant"() {"value" = 42 : index} : () -> index
%sum = "gpu.all_reduce"(%init) ({
^bb(%lhs : index, %rhs : index):
%sum = "arith.addi"(%lhs, %rhs) : (index, index) -> index
%float = "arith.constant"() {"value" = 42.0 : f32} : () -> f32
"gpu.yield"(%float) : (f32) -> ()
}) {} : (index) -> index
"gpu.module_end"() : () -> ()
}) {"sym_name" = "gpu"} : () -> ()
}) {} : () -> ()

// CHECK: Expected ['index'], got ['f32']. The gpu.yield values types must match its enclosing operation result types.
20 changes: 0 additions & 20 deletions tests/filecheck/dialects/gpu/launch_args.mlir

This file was deleted.

14 changes: 0 additions & 14 deletions tests/filecheck/dialects/gpu/launch_empty.mlir

This file was deleted.

12 changes: 0 additions & 12 deletions tests/filecheck/dialects/gpu/memcpy_type_mismatch.mlir

This file was deleted.

9 changes: 0 additions & 9 deletions tests/filecheck/dialects/gpu/module_unnamed.mlir

This file was deleted.

24 changes: 0 additions & 24 deletions tests/filecheck/dialects/gpu/terminator_launch.mlir

This file was deleted.

23 changes: 0 additions & 23 deletions tests/filecheck/dialects/gpu/terminator_terminate.mlir

This file was deleted.

17 changes: 0 additions & 17 deletions tests/filecheck/dialects/gpu/yield_terminate.mlir

This file was deleted.

16 changes: 0 additions & 16 deletions tests/filecheck/dialects/gpu/yield_types.mlir

This file was deleted.

0 comments on commit 41eddeb

Please sign in to comment.