brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.1 KiB · 6facf1e Raw
160 lines · plain
1// RUN: mlir-opt %s -pass-pipeline='builtin.module( \2// RUN:       func.func(test-affine-reify-value-bounds), \3// RUN:       gpu.module(llvm.func(test-affine-reify-value-bounds)), \4// RUN:       gpu.module(gpu.func(test-affine-reify-value-bounds)))' \5// RUN:     -verify-diagnostics \6// RUN:     -split-input-file | FileCheck %s7 8// CHECK-LABEL: func @launch_func9func.func @launch_func(%arg0 : index) {10  %c0 = arith.constant 0 : index11  %c1 = arith.constant 1 : index12  %c2 = arith.constant 2 : index13  %c4 = arith.constant 4 : index14  %c64 = arith.constant 64 : index15  gpu.launch blocks(%block_id_x, %block_id_y, %block_id_z) in (%grid_dim_x = %arg0, %grid_dim_y = %c4, %grid_dim_z = %c2)16      threads(%thread_id_x, %thread_id_y, %thread_id_z) in (%block_dim_x = %c64, %block_dim_y = %c4, %block_dim_z = %c2) {17 18    // Sanity checks:19    // expected-error @below{{unknown}}20    "test.compare" (%thread_id_x, %c1) {cmp = "EQ"} : (index, index) -> ()21    // expected-remark @below{{false}}22    "test.compare" (%thread_id_x, %c64) {cmp = "GE"} : (index, index) -> ()23 24    // expected-remark @below{{true}}25    "test.compare" (%grid_dim_x, %c1) {cmp = "GE"}  : (index, index) -> ()26    // expected-remark @below{{true}}27    "test.compare" (%grid_dim_x, %arg0) {cmp = "EQ"} : (index, index) -> ()28    // expected-remark @below{{true}}29    "test.compare" (%grid_dim_y, %c4) {cmp = "EQ"} : (index, index) -> ()30    // expected-remark @below{{true}}31    "test.compare" (%grid_dim_z, %c2) {cmp = "EQ"} : (index, index) -> ()32 33    // expected-remark @below{{true}}34    "test.compare"(%block_id_x, %c0) {cmp = "GE"} : (index, index) -> ()35    // expected-remark @below{{true}}36    "test.compare"(%block_id_x, %arg0) {cmp = "LT"} : (index, index) -> ()37    // expected-remark @below{{true}}38    "test.compare"(%block_id_y, %c0) {cmp = "GE"} : (index, index) -> ()39    // expected-remark @below{{true}}40    "test.compare"(%block_id_y, %c4) {cmp = "LT"} : (index, index) -> ()41    // expected-remark @below{{true}}42    "test.compare"(%block_id_z, %c0) {cmp = "GE"} : (index, index) -> ()43    // expected-remark @below{{true}}44    "test.compare"(%block_id_z, %c2) {cmp = "LT"} : (index, index) -> ()45 46    // expected-remark @below{{true}}47    "test.compare" (%block_dim_x, %c64) {cmp = "EQ"} : (index, index) -> ()48    // expected-remark @below{{true}}49    "test.compare" (%block_dim_y, %c4) {cmp = "EQ"} : (index, index) -> ()50    // expected-remark @below{{true}}51    "test.compare" (%block_dim_z, %c2) {cmp = "EQ"} : (index, index) -> ()52 53    // expected-remark @below{{true}}54    "test.compare"(%thread_id_x, %c0) {cmp = "GE"} : (index, index) -> ()55    // expected-remark @below{{true}}56    "test.compare"(%thread_id_x, %c64) {cmp = "LT"} : (index, index) -> ()57    // expected-remark @below{{true}}58    "test.compare"(%thread_id_y, %c0) {cmp = "GE"} : (index, index) -> ()59    // expected-remark @below{{true}}60    "test.compare"(%thread_id_y, %c4) {cmp = "LT"} : (index, index) -> ()61    // expected-remark @below{{true}}62    "test.compare"(%thread_id_z, %c0) {cmp = "GE"} : (index, index) -> ()63    // expected-remark @below{{true}}64    "test.compare"(%thread_id_z, %c2) {cmp = "LT"} : (index, index) -> ()65 66    // expected-remark @below{{true}}67    "test.compare"(%thread_id_x, %block_dim_x) {cmp = "LT"} : (index, index) -> ()68    gpu.terminator69  }70 71  func.return72}73 74// -----75 76// The tests for what the ranges are are located in int-range-interface.mlir,77// so here we just make sure that the results of that interface propagate into78// constraints.79 80// CHECK-LABEL: func @kernel81module attributes {gpu.container_module} {82  gpu.module @gpu_module {83    llvm.func @kernel() attributes {gpu.kernel} {84 85      %c0 = arith.constant 0 : index86      %ctid_max = arith.constant 4294967295 : index87      %thread_id_x = gpu.thread_id x88 89      // expected-remark @below{{true}}90      "test.compare" (%thread_id_x, %c0) {cmp = "GE"} : (index, index) -> ()91      // expected-remark @below{{true}}92      "test.compare" (%thread_id_x, %ctid_max) {cmp = "LT"} : (index, index) -> ()93      llvm.return94    }95  }96}97 98// -----99 100// CHECK-LABEL: func @annotated_kernel101module attributes {gpu.container_module} {102  gpu.module @gpu_module {103    gpu.func @annotated_kernel() kernel104      attributes {known_block_size = array<i32: 8, 12, 16>,105          known_grid_size = array<i32: 20, 24, 28>} {106 107      %c0 = arith.constant 0 : index108      %c8 = arith.constant 8 : index109      %thread_id_x = gpu.thread_id x110 111      // expected-remark @below{{true}}112      "test.compare"(%thread_id_x, %c0) {cmp = "GE"} : (index, index) -> ()113      // expected-remark @below{{true}}114      "test.compare"(%thread_id_x, %c8) {cmp = "LT"} : (index, index) -> ()115 116      %block_dim_x = gpu.block_dim x117      // expected-remark @below{{true}}118      "test.compare"(%block_dim_x, %c8) {cmp = "EQ"} : (index, index) -> ()119 120      // expected-remark @below{{true}}121      "test.compare"(%thread_id_x, %block_dim_x) {cmp = "LT"} : (index, index) -> ()122      gpu.return123    }124  }125}126 127// -----128 129// CHECK-LABEL: func @local_bounds_kernel130module attributes {gpu.container_module} {131  gpu.module @gpu_module {132    gpu.func @local_bounds_kernel() kernel {133 134      %c0 = arith.constant 0 : index135      %c1 = arith.constant 1 : index136      %c8 = arith.constant 8 : index137 138      %block_dim_x = gpu.block_dim x upper_bound 8139      // expected-remark @below{{true}}140      "test.compare"(%block_dim_x, %c1) {cmp = "GE"} : (index, index) -> ()141      // expected-remark @below{{true}}142      "test.compare"(%block_dim_x, %c8) {cmp = "LE"} : (index, index) -> ()143      // expected-error @below{{unknown}}144      "test.compare"(%block_dim_x, %c8) {cmp = "EQ"} : (index, index) -> ()145 146      %thread_id_x = gpu.thread_id x upper_bound 8147      // expected-remark @below{{true}}148      "test.compare"(%thread_id_x, %c0) {cmp = "GE"} : (index, index) -> ()149      // expected-remark @below{{true}}150      "test.compare"(%thread_id_x, %c8) {cmp = "LT"} : (index, index) -> ()151 152      // Note: there isn't a way to express the ID <= size constraint153      // in this form154      // expected-error @below{{unknown}}155      "test.compare"(%thread_id_x, %block_dim_x) {cmp = "LT"} : (index, index) -> ()156      gpu.return157    }158  }159}160