|
| 1 | +// RUN: ptoas %s | FileCheck %s |
| 2 | + |
| 3 | +module { |
| 4 | + func.func @vector_while_kernel() attributes {pto.kernel_kind = #pto.kernel_kind<vector>} { |
| 5 | + %c0 = arith.constant 0 : index |
| 6 | + %c1 = arith.constant 1 : index |
| 7 | + %c2 = arith.constant 2 : index |
| 8 | + %c4 = arith.constant 4 : index |
| 9 | + %c32 = arith.constant 32 : index |
| 10 | + %true = arith.constant true |
| 11 | + %false = arith.constant false |
| 12 | + %one = arith.constant 1.0 : f32 |
| 13 | + %ten = arith.constant 10.0 : f32 |
| 14 | + |
| 15 | + %tile = pto.alloc_tile |
| 16 | + : !pto.tile_buf<loc=vec, dtype=f32, rows=32, cols=32, v_row=32, v_col=32, |
| 17 | + blayout=row_major, slayout=none_box, fractal=512, pad=0> |
| 18 | + |
| 19 | + %final:2 = scf.while (%i = %c0, %alive = %true) : (index, i1) -> (index, i1) { |
| 20 | + %lt = arith.cmpi slt, %i, %c4 : index |
| 21 | + %go = arith.andi %lt, %alive : i1 |
| 22 | + scf.condition(%go) %i, %alive : index, i1 |
| 23 | + } do { |
| 24 | + ^bb0(%i2: index, %alive2: i1): |
| 25 | + pto.tadds ins(%tile, %one |
| 26 | + : !pto.tile_buf<loc=vec, dtype=f32, rows=32, cols=32, v_row=32, v_col=32, |
| 27 | + blayout=row_major, slayout=none_box, fractal=512, pad=0>, |
| 28 | + f32) |
| 29 | + outs(%tile |
| 30 | + : !pto.tile_buf<loc=vec, dtype=f32, rows=32, cols=32, v_row=32, v_col=32, |
| 31 | + blayout=row_major, slayout=none_box, fractal=512, pad=0>) |
| 32 | + %break_now = arith.cmpi eq, %i2, %c2 : index |
| 33 | + %next_i = arith.addi %i2, %c1 : index |
| 34 | + %yield:2 = scf.if %break_now -> (index, i1) { |
| 35 | + scf.yield %next_i, %false : index, i1 |
| 36 | + } else { |
| 37 | + pto.tadds ins(%tile, %ten |
| 38 | + : !pto.tile_buf<loc=vec, dtype=f32, rows=32, cols=32, v_row=32, v_col=32, |
| 39 | + blayout=row_major, slayout=none_box, fractal=512, pad=0>, |
| 40 | + f32) |
| 41 | + outs(%tile |
| 42 | + : !pto.tile_buf<loc=vec, dtype=f32, rows=32, cols=32, v_row=32, v_col=32, |
| 43 | + blayout=row_major, slayout=none_box, fractal=512, pad=0>) |
| 44 | + scf.yield %next_i, %true : index, i1 |
| 45 | + } |
| 46 | + scf.yield %yield#0, %yield#1 : index, i1 |
| 47 | + } |
| 48 | + |
| 49 | + %stopped = arith.xori %final#1, %true : i1 |
| 50 | + scf.if %stopped { |
| 51 | + pto.tadds ins(%tile, %one |
| 52 | + : !pto.tile_buf<loc=vec, dtype=f32, rows=32, cols=32, v_row=32, v_col=32, |
| 53 | + blayout=row_major, slayout=none_box, fractal=512, pad=0>, |
| 54 | + f32) |
| 55 | + outs(%tile |
| 56 | + : !pto.tile_buf<loc=vec, dtype=f32, rows=32, cols=32, v_row=32, v_col=32, |
| 57 | + blayout=row_major, slayout=none_box, fractal=512, pad=0>) |
| 58 | + } |
| 59 | + return |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +// CHECK: AICORE void vector_while_kernel() |
| 64 | +// CHECK: using T = float; |
| 65 | +// CHECK: #if defined(__DAV_VEC__) |
| 66 | +// CHECK: set_mask_norm(); |
| 67 | +// CHECK: set_vector_mask(-1, -1); |
| 68 | +// CHECK: goto [[HEADER:label[0-9]+]]; |
| 69 | +// CHECK: [[HEADER]]: |
| 70 | +// CHECK: if ({{.*}}) { |
| 71 | +// CHECK: goto [[BODY:label[0-9]+]]; |
| 72 | +// CHECK: goto [[EXIT:label[0-9]+]]; |
| 73 | +// CHECK: [[BODY]]: |
| 74 | +// CHECK: goto [[HEADER]]; |
| 75 | +// CHECK: [[EXIT]]: |
| 76 | +// CHECK: #endif // __DAV_VEC__ |
0 commit comments