|
| 1 | +--- |
| 2 | +author: matinraayai |
| 3 | +format: |
| 4 | + html: default |
| 5 | +title: "Homework 3: Dataflow Analysis" |
| 6 | +--- |
| 7 | +For this homework I implemented a liveness analysis in BRIL. I implemented it using the pseudo code that was covered |
| 8 | +in class. My implementation can be found [here](https://github.com/matinraayai/bril/blob/main/examples/df_matin.py). |
| 9 | + |
| 10 | +I tested my implementation on the tests already under the |
| 11 | +[df](https://github.com/matinraayai/bril/tree/main/examples/test/df) folder, as well as other tests for other programs. |
| 12 | +I added a small portion at the end which checks if the live-ins of the successors of each block is included in the |
| 13 | +live-outs of each block. |
| 14 | + |
| 15 | +Sample Outputs: |
| 16 | + |
| 17 | +```bash |
| 18 | +bril2json < ../../../benchmarks/mem/adj2csr.bril | python3 ../../df_matin.py |
| 19 | + |
| 20 | +b1: |
| 21 | + in: max, seq |
| 22 | + out: ∅ |
| 23 | +b1: |
| 24 | + in: rng, size |
| 25 | + out: arr, i, max, one, rng, size, zero |
| 26 | +loop: |
| 27 | + in: arr, i, max, one, rng, size, zero |
| 28 | + out: arr, i, max, one, rng, size, zero |
| 29 | +body: |
| 30 | + in: arr, i, max, one, rng, size, zero |
| 31 | + out: arr, i, max, one, rng, size, val, zero |
| 32 | +if_body: |
| 33 | + in: arr, i, max, one, rng, size, zero |
| 34 | + out: arr, i, max, one, rng, size, val, zero |
| 35 | +if_done: |
| 36 | + in: arr, i, max, one, rng, size, val, zero |
| 37 | + out: arr, i, max, one, rng, size, zero |
| 38 | +loop_end: |
| 39 | + in: arr, i, max, one, rng, size, zero |
| 40 | + out: arr, i, max, one, rng, size, zero |
| 41 | +done: |
| 42 | + in: arr |
| 43 | + out: ∅ |
| 44 | +b1: |
| 45 | + in: arr, size |
| 46 | + out: arr, i, one, size |
| 47 | +loop: |
| 48 | + in: arr, i, one, size |
| 49 | + out: arr, i, one, size |
| 50 | +body: |
| 51 | + in: arr, i, one, size |
| 52 | + out: arr, i, one, size |
| 53 | +loop_end: |
| 54 | + in: arr, i, one, size |
| 55 | + out: arr, i, one, size |
| 56 | +done: |
| 57 | + in: ∅ |
| 58 | + out: ∅ |
| 59 | +b1: |
| 60 | + in: size |
| 61 | + out: arr, i, one, size, zero |
| 62 | +loop: |
| 63 | + in: arr, i, one, size, zero |
| 64 | + out: arr, i, one, size, zero |
| 65 | +body: |
| 66 | + in: arr, i, one, size, zero |
| 67 | + out: arr, i, one, size, zero |
| 68 | +loop_end: |
| 69 | + in: arr, i, one, size, zero |
| 70 | + out: arr, i, one, size, zero |
| 71 | +done: |
| 72 | + in: arr |
| 73 | + out: ∅ |
| 74 | +b1: |
| 75 | + in: adjmat, csr_edges, csr_offset, num_nodes |
| 76 | + out: adjmat, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 77 | +iter_row: |
| 78 | + in: adjmat, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 79 | + out: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 80 | +iter_col: |
| 81 | + in: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 82 | + out: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 83 | +col_body: |
| 84 | + in: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 85 | + out: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 86 | +if_body: |
| 87 | + in: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 88 | + out: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 89 | +col_end: |
| 90 | + in: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 91 | + out: adjmat, col, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 92 | +col_done: |
| 93 | + in: adjmat, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 94 | + out: adjmat, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 95 | +row_end: |
| 96 | + in: adjmat, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 97 | + out: adjmat, csr_edges, csr_offset, num_edges, num_nodes, one, row |
| 98 | +row_done: |
| 99 | + in: num_edges |
| 100 | + out: ∅ |
| 101 | +b1: |
| 102 | + in: num_nodes, seed |
| 103 | + out: ∅ |
| 104 | +``` |
| 105 | + |
| 106 | +```bash |
| 107 | +bril2json < ../../../benchmarks/mixed/cholesky.bril | python3 ../../df_matin.py |
| 108 | + |
| 109 | +b1: |
| 110 | + in: ∅ |
| 111 | + out: ∅ |
| 112 | +b1: |
| 113 | + in: sqsize |
| 114 | + out: arr, i, one, sqsize, zero |
| 115 | +loop: |
| 116 | + in: arr, i, one, sqsize, zero |
| 117 | + out: arr, i, one, sqsize, zero |
| 118 | +body: |
| 119 | + in: arr, i, one, sqsize, zero |
| 120 | + out: arr, i, one, sqsize, zero |
| 121 | +loop_end: |
| 122 | + in: arr, i, one, sqsize, zero |
| 123 | + out: arr, i, one, sqsize, zero |
| 124 | +done: |
| 125 | + in: arr |
| 126 | + out: ∅ |
| 127 | +b1: |
| 128 | + in: arr, size |
| 129 | + out: arr, i, one, size |
| 130 | +loop: |
| 131 | + in: arr, i, one, size |
| 132 | + out: arr, i, one, size |
| 133 | +body: |
| 134 | + in: arr, i, one, size |
| 135 | + out: arr, i, one, size |
| 136 | +loop_end: |
| 137 | + in: arr, i, one, size |
| 138 | + out: arr, i, one, size |
| 139 | +done: |
| 140 | + in: ∅ |
| 141 | + out: ∅ |
| 142 | +b1: |
| 143 | + in: arr1, arr2, dest, size |
| 144 | + out: arr1, arr2, dest, one, row, size |
| 145 | +row.loop: |
| 146 | + in: arr1, arr2, dest, one, row, size |
| 147 | + out: arr1, arr2, dest, one, row, size |
| 148 | +row.body: |
| 149 | + in: arr1, arr2, dest, one, row, size |
| 150 | + out: arr1, arr2, col, dest, one, row, size |
| 151 | +col.loop: |
| 152 | + in: arr1, arr2, col, dest, one, row, size |
| 153 | + out: arr1, arr2, col, dest, one, row, size |
| 154 | +col.body: |
| 155 | + in: arr1, arr2, col, dest, one, row, size |
| 156 | + out: arr1, arr2, col, dest, i, one, row, size, sum |
| 157 | +sum.loop: |
| 158 | + in: arr1, arr2, col, dest, i, one, row, size, sum |
| 159 | + out: arr1, arr2, col, dest, i, one, row, size, sum |
| 160 | +sum.body: |
| 161 | + in: arr1, arr2, col, dest, i, one, row, size, sum |
| 162 | + out: arr1, arr2, col, dest, i, one, row, size, sum |
| 163 | +sum.loop_end: |
| 164 | + in: arr1, arr2, col, dest, i, one, row, size, sum |
| 165 | + out: arr1, arr2, col, dest, i, one, row, size, sum |
| 166 | +sum.done: |
| 167 | + in: arr1, arr2, col, dest, one, row, size, sum |
| 168 | + out: arr1, arr2, col, dest, one, row, size |
| 169 | +col.loop_end: |
| 170 | + in: arr1, arr2, col, dest, one, row, size |
| 171 | + out: arr1, arr2, col, dest, one, row, size |
| 172 | +col.done: |
| 173 | + in: arr1, arr2, dest, one, row, size |
| 174 | + out: arr1, arr2, dest, one, row, size |
| 175 | +row.loop_end: |
| 176 | + in: arr1, arr2, dest, one, row, size |
| 177 | + out: arr1, arr2, dest, one, row, size |
| 178 | +row.done: |
| 179 | + in: ∅ |
| 180 | + out: ∅ |
| 181 | +b1: |
| 182 | + in: input, output, size |
| 183 | + out: input, one, output, row, size |
| 184 | +row.loop: |
| 185 | + in: input, one, output, row, size |
| 186 | + out: input, one, output, row, size |
| 187 | +row.body: |
| 188 | + in: input, one, output, row, size |
| 189 | + out: col, input, one, output, row, size |
| 190 | +col.loop: |
| 191 | + in: col, input, one, output, row, size |
| 192 | + out: col, input, one, output, row, size |
| 193 | +col.body: |
| 194 | + in: col, input, one, output, row, size |
| 195 | + out: col, input, one, output, row, size |
| 196 | +col.loop_end: |
| 197 | + in: col, input, one, output, row, size |
| 198 | + out: col, input, one, output, row, size |
| 199 | +col.done: |
| 200 | + in: input, one, output, row, size |
| 201 | + out: input, one, output, row, size |
| 202 | +row.loop_end: |
| 203 | + in: input, one, output, row, size |
| 204 | + out: input, one, output, row, size |
| 205 | +row.done: |
| 206 | + in: ∅ |
| 207 | + out: ∅ |
| 208 | +b1: |
| 209 | + in: input |
| 210 | + out: n, notdone, precision, x |
| 211 | +for.cond.4: |
| 212 | + in: n, notdone, precision, x |
| 213 | + out: n, notdone, precision, x |
| 214 | +for.body.4: |
| 215 | + in: n, notdone, precision, x |
| 216 | + out: diff, n, notdone, precision, root |
| 217 | +then.18: |
| 218 | + in: diff, n, notdone, precision, root |
| 219 | + out: diff, n, notdone, precision, root |
| 220 | +else.18: |
| 221 | + in: diff, n, notdone, precision, root |
| 222 | + out: diff, n, notdone, precision, root |
| 223 | +endif.18: |
| 224 | + in: diff, n, notdone, precision, root |
| 225 | + out: n, notdone, precision, root |
| 226 | +then.25: |
| 227 | + in: n, precision, root |
| 228 | + out: n, notdone, precision, root |
| 229 | +else.25: |
| 230 | + in: n, notdone, precision, root |
| 231 | + out: n, notdone, precision, root |
| 232 | +endif.25: |
| 233 | + in: n, notdone, precision, root |
| 234 | + out: n, notdone, precision, x |
| 235 | +for.end.4: |
| 236 | + in: x |
| 237 | + out: ∅ |
| 238 | +b1: |
| 239 | + in: arr1, arr2, size |
| 240 | + out: arr1, arr2, i, one, size |
| 241 | +i.loop: |
| 242 | + in: arr1, arr2, i, one, size |
| 243 | + out: arr1, arr2, i, one, size |
| 244 | +i.body: |
| 245 | + in: arr1, arr2, i, one, size |
| 246 | + out: arr1, arr2, i, j, one, size |
| 247 | +j.loop: |
| 248 | + in: arr1, arr2, i, j, one, size |
| 249 | + out: arr1, arr2, i, j, one, size |
| 250 | +j.body: |
| 251 | + in: arr1, arr2, i, j, one, size |
| 252 | + out: arr1, arr2, i, j, k, one, size |
| 253 | +k.loop: |
| 254 | + in: arr1, arr2, i, j, k, one, size |
| 255 | + out: arr1, arr2, i, j, k, one, size |
| 256 | +k.body: |
| 257 | + in: arr1, arr2, i, j, k, one, size |
| 258 | + out: arr1, arr2, i, j, k, one, size |
| 259 | +k.loop_end: |
| 260 | + in: arr1, arr2, i, j, k, one, size |
| 261 | + out: arr1, arr2, i, j, k, one, size |
| 262 | +k.done: |
| 263 | + in: arr1, arr2, i, j, one, size |
| 264 | + out: arr1, arr2, i, j, one, size |
| 265 | +j.loop_end: |
| 266 | + in: arr1, arr2, i, j, one, size |
| 267 | + out: arr1, arr2, i, j, one, size |
| 268 | +j.done: |
| 269 | + in: arr1, arr2, i, one, size |
| 270 | + out: arr1, arr2, i, one, size |
| 271 | +i.loop_end: |
| 272 | + in: arr1, arr2, i, one, size |
| 273 | + out: arr1, arr2, i, one, size |
| 274 | +i.done: |
| 275 | + in: ∅ |
| 276 | + out: ∅ |
| 277 | +b1: |
| 278 | + in: ∅ |
| 279 | + out: ∅ |
| 280 | +``` |
0 commit comments