Skip to content

Commit

Permalink
accelerated loop fusion by performing fast pre-check (process only th…
Browse files Browse the repository at this point in the history
…ose blocks where there is at least one map (the donor loop) at least another map/for (the recipient loop))
  • Loading branch information
vpisarev committed Mar 22, 2021
1 parent a9b7ae1 commit b088168
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions compiler/K_fuse_loops.fx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ type ainfo_map_t = (id_t, arr_info_t ref) Map.t
type arr_fuse_map_t = (id_t, id_t) Map.t

fun fuse_loops(code: kcode_t)
{
val fold nmaps = 0, nfors = 0 for e <- code {
| KDefVal(_, KExpMap _, _) => (nmaps + 1, nfors)
| KExpMap _ => (nmaps + 1, nfors)
| KExpFor _ => (nmaps, nfors + 1)
| _ => (nmaps, nfors)
}
if nmaps >= 1 && nmaps + nfors >= 2 {
fuse_loops_(code)
} else {
code
}
}

fun fuse_loops_(code: kcode_t)
{
var counters: ainfo_map_t = Map.empty(cmp_id)
fun process_atom(a: atom_t, loc: loc_t, callb: k_fold_callb_t) =
Expand Down

0 comments on commit b088168

Please sign in to comment.