From 56b0d0ed830dfdc6c770eb0e69799c2a66b73cfd Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Fri, 13 Nov 2015 15:16:47 +0300 Subject: [PATCH 1/4] Update .gitignore --- .gitignore | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 9a3a2da0..aa51f24c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ lib_managed *.iml +.idea/ .DS_Store local.properties project/boot project/build/target -target -virtualization-lms-core.iml -.gitingore -#test-out +target/ +test-out/ +!test-out/**/*.check +data/ \ No newline at end of file From 47218ef4e3b9db31b9b58c853cf0790b6986561c Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Thu, 19 Nov 2015 10:27:03 +0300 Subject: [PATCH 2/4] Add type comparison to Const.equals --- src/internal/Expressions.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/internal/Expressions.scala b/src/internal/Expressions.scala index a2898c8c..b878ec8f 100644 --- a/src/internal/Expressions.scala +++ b/src/internal/Expressions.scala @@ -20,7 +20,12 @@ trait Expressions extends Utils { def pos: List[SourceContext] = Nil } - case class Const[+T:Manifest](x: T) extends Exp[T] + case class Const[+T:Manifest](x: T) extends Exp[T] { + override def equals(other: Any) = other match { + case c: Const[_] => x == c.x && tp == c.tp + case _ => false + } + } case class Sym[+T:Manifest](val id: Int) extends Exp[T] { var sourceContexts: List[SourceContext] = Nil From afc237673ef39c10f2b074044fbb11200d9ebd85 Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Tue, 17 Nov 2015 13:09:13 +0300 Subject: [PATCH 3/4] Ensure correct type in findDefinition --- src/internal/Expressions.scala | 15 ++-- src/internal/FatExpressions.scala | 12 ++- test-out/epfl/test14-queries2.check | 56 ++++++------- test-out/epfl/test14-queries3.check | 80 +++++++++---------- test-out/epfl/test14-queries4.check | 80 +++++++++---------- test-out/epfl/test9-struct3.check | 15 ++-- test-src/epfl/test2-fft/DisableOpts.scala | 2 +- test-src/epfl/test3-parsers/Parsers.scala | 4 +- test-src/epfl/test3-parsers/TestParsers.scala | 4 +- 9 files changed, 140 insertions(+), 128 deletions(-) diff --git a/src/internal/Expressions.scala b/src/internal/Expressions.scala index b878ec8f..b3e0cd3a 100644 --- a/src/internal/Expressions.scala +++ b/src/internal/Expressions.scala @@ -70,11 +70,11 @@ trait Expressions extends Utils { case _ => None } - def infix_defines[A](stm: Stm, rhs: Def[A]): Option[Sym[A]] = stm match { - case TP(sym: Sym[A], `rhs`) => Some(sym) + def infix_defines[A: Manifest](stm: Stm, rhs: Def[A]): Option[Sym[A]] = stm match { + case TP(sym: Sym[A], `rhs`) if sym.tp <:< manifest[A] => Some(sym) case _ => None } - + case class TP[+T](sym: Sym[T], rhs: Def[T]) extends Stm // graph construction state @@ -113,7 +113,7 @@ trait Expressions extends Utils { globalDefsCache.get(s) //globalDefs.find(x => x.defines(s).nonEmpty) - def findDefinition[T](d: Def[T]): Option[Stm] = + def findDefinition[T: Manifest](d: Def[T]): Option[Stm] = globalDefs.find(x => x.defines(d).nonEmpty) def findOrCreateDefinition[T:Manifest](d: Def[T], pos: List[SourceContext]): Stm = @@ -121,8 +121,11 @@ trait Expressions extends Utils { createDefinition(fresh[T](pos), d) } - def findOrCreateDefinitionExp[T:Manifest](d: Def[T], pos: List[SourceContext]): Exp[T] = - findOrCreateDefinition(d, pos).defines(d).get + def findOrCreateDefinitionExp[T:Manifest](d: Def[T], pos: List[SourceContext]): Exp[T] = { + val stm = findOrCreateDefinition(d, pos) + val optExp = stm.defines(d) + optExp.get + } def createDefinition[T](s: Sym[T], d: Def[T]): Stm = { val f = TP(s, d) diff --git a/src/internal/FatExpressions.scala b/src/internal/FatExpressions.scala index 3181e999..c2397a79 100644 --- a/src/internal/FatExpressions.scala +++ b/src/internal/FatExpressions.scala @@ -24,8 +24,16 @@ trait FatExpressions extends Expressions { case _ => super.infix_defines(stm, sym) } - override def infix_defines[A](stm: Stm, rhs: Def[A]): Option[Sym[A]] = stm match { - case TTP(lhs, mhs, rhs) => mhs.indexOf(rhs) match { case idx if idx >= 0 => Some(lhs(idx).asInstanceOf[Sym[A]]) case _ => None } + override def infix_defines[A: Manifest](stm: Stm, rhs: Def[A]): Option[Sym[A]] = stm match { + case TTP(lhs, mhs, rhs) => mhs.indexOf(rhs) match { + case idx if idx >= 0 => + val sym = lhs(idx) + if (sym.tp <:< manifest[A]) + Some(sym.asInstanceOf[Sym[A]]) + else + None + case _ => None + } case _ => super.infix_defines(stm, rhs) } diff --git a/test-out/epfl/test14-queries2.check b/test-out/epfl/test14-queries2.check index 3f13fe95..43209630 100644 --- a/test-out/epfl/test14-queries2.check +++ b/test-out/epfl/test14-queries2.check @@ -6,39 +6,39 @@ nVars=2000 import scala.lms.epfl.test14.Schema class staged$0 extends ((Unit)=>(Unit)) { def apply(x0:Unit): Unit = { -val x2550 = println("rangeFromNames(\"Edna\",\"Bert\"):") -val x617 = Schema.db.people.flatMap { x111 => -val x616 = Schema.db.people.flatMap { x435 => -val x615 = Schema.db.people.flatMap { x598 => -val x112 = x111.name -val x113 = x112 == "Edna" -val x438 = x435.name -val x439 = x438 == "Bert" -val x116 = x111.age -val x602 = x598.age -val x603 = x116 <= x602 -val x441 = x435.age -val x604 = x602 < x441 -val x605 = x603 && x604 -val x611 = x439 && x605 -val x613 = x113 && x611 -val x614 = if (x613) { -val x607 = x598.name -val x608 = new Schema.Record { val name = x607 } -val x609 = List(x608) -x609 +val x2580 = println("rangeFromNames(\"Edna\",\"Bert\"):") +val x641 = Schema.db.people.flatMap { x112 => +val x640 = Schema.db.people.flatMap { x445 => +val x639 = Schema.db.people.flatMap { x620 => +val x113 = x112.name +val x114 = x113 == "Edna" +val x448 = x445.name +val x449 = x448 == "Bert" +val x117 = x112.age +val x624 = x620.age +val x625 = x117 <= x624 +val x452 = x445.age +val x626 = x624 < x452 +val x627 = x625 && x626 +val x634 = x449 && x627 +val x637 = x114 && x634 +val x638 = if (x637) { +val x630 = x620.name +val x631 = new Schema.Record { val name = x630 } +val x632 = List(x631) +x632 } else { -val x19 = List() -x19 +val x34 = List() +x34 } -x614 +x638 } -x615 +x639 } -x616 +x640 } -val x2551 = println(x617) -x2551 +val x2581 = println(x641) +x2581 } } /***************************************** diff --git a/test-out/epfl/test14-queries3.check b/test-out/epfl/test14-queries3.check index 1526c97a..c0086b4f 100644 --- a/test-out/epfl/test14-queries3.check +++ b/test-out/epfl/test14-queries3.check @@ -6,55 +6,55 @@ nVars=2000 import scala.lms.epfl.test14.Schema class staged$0 extends ((Unit)=>(Unit)) { def apply(x0:Unit): Unit = { -val x2550 = println("expertise(\"abstract\"):") -val x800 = Schema.org.departments.flatMap { x732 => -val x792 = Schema.org.employees.flatMap { x763 => -val x734 = x732.dpt -val x764 = x763.dpt -val x765 = x734 == x764 -val x785 = Schema.org.tasks.flatMap { x776 => -val x767 = x763.emp -val x777 = x776.emp -val x778 = x767 == x777 -val x779 = x776.tsk -val x780 = x779 == "abstract" -val x781 = x778 && x780 -val x784 = if (x781) { -val x661 = new Schema.Record { val ignore = () } -val x688 = List(x661) -x688 +val x2580 = println("expertise(\"abstract\"):") +val x824 = Schema.org.departments.flatMap { x756 => +val x816 = Schema.org.employees.flatMap { x787 => +val x758 = x756.dpt +val x788 = x787.dpt +val x789 = x758 == x788 +val x809 = Schema.org.tasks.flatMap { x800 => +val x791 = x787.emp +val x801 = x800.emp +val x802 = x791 == x801 +val x803 = x800.tsk +val x804 = x803 == "abstract" +val x805 = x802 && x804 +val x808 = if (x805) { +val x685 = new Schema.Record { val ignore = () } +val x712 = List(x685) +x712 } else { -val x19 = List() -x19 +val x34 = List() +x34 } -x784 +x808 } -val x786 = x785.isEmpty -val x788 = x765 && x786 -val x791 = if (x788) { -val x661 = new Schema.Record { val ignore = () } -val x688 = List(x661) -x688 +val x810 = x809.isEmpty +val x812 = x789 && x810 +val x815 = if (x812) { +val x685 = new Schema.Record { val ignore = () } +val x712 = List(x685) +x712 } else { -val x19 = List() -x19 +val x34 = List() +x34 } -x791 +x815 } -val x793 = x792.isEmpty -val x799 = if (x793) { -val x734 = x732.dpt -val x797 = new Schema.Record { val dpt = x734 } -val x798 = List(x797) -x798 +val x817 = x816.isEmpty +val x823 = if (x817) { +val x758 = x756.dpt +val x821 = new Schema.Record { val dpt = x758 } +val x822 = List(x821) +x822 } else { -val x19 = List() -x19 +val x34 = List() +x34 } -x799 +x823 } -val x2551 = println(x800) -x2551 +val x2581 = println(x824) +x2581 } } /***************************************** diff --git a/test-out/epfl/test14-queries4.check b/test-out/epfl/test14-queries4.check index fa5b5c59..f54dfdac 100644 --- a/test-out/epfl/test14-queries4.check +++ b/test-out/epfl/test14-queries4.check @@ -6,55 +6,55 @@ nVars=2000 import scala.lms.epfl.test14.Schema class staged$0 extends ((Unit)=>(Unit)) { def apply(x0:Unit): Unit = { -val x2550 = println("expertise2(\"abstract\"):") -val x1147 = Schema.org.departments.flatMap { x991 => -val x1140 = Schema.org.employees.flatMap { x1083 => -val x993 = x991.dpt -val x1084 = x1083.dpt -val x1085 = x993 == x1084 -val x1133 = Schema.org.tasks.flatMap { x1120 => -val x1088 = x1083.emp -val x1121 = x1120.emp -val x1122 = x1088 == x1121 -val x1125 = x1120.tsk -val x1128 = x1125 == "abstract" -val x1130 = x1122 && x1128 -val x1132 = if (x1130) { -val x661 = new Schema.Record { val ignore = () } -val x688 = List(x661) -x688 +val x2580 = println("expertise2(\"abstract\"):") +val x1177 = Schema.org.departments.flatMap { x1018 => +val x1169 = Schema.org.employees.flatMap { x1111 => +val x1020 = x1018.dpt +val x1112 = x1111.dpt +val x1113 = x1020 == x1112 +val x1161 = Schema.org.tasks.flatMap { x1148 => +val x1116 = x1111.emp +val x1149 = x1148.emp +val x1150 = x1116 == x1149 +val x1153 = x1148.tsk +val x1156 = x1153 == "abstract" +val x1158 = x1150 && x1156 +val x1160 = if (x1158) { +val x685 = new Schema.Record { val ignore = () } +val x712 = List(x685) +x712 } else { -val x19 = List() -x19 +val x34 = List() +x34 } -x1132 +x1160 } -val x1134 = x1133.isEmpty -val x1137 = x1085 && x1134 -val x1139 = if (x1137) { -val x661 = new Schema.Record { val ignore = () } -val x688 = List(x661) -x688 +val x1162 = x1161.isEmpty +val x1166 = x1113 && x1162 +val x1168 = if (x1166) { +val x685 = new Schema.Record { val ignore = () } +val x712 = List(x685) +x712 } else { -val x19 = List() -x19 +val x34 = List() +x34 } -x1139 +x1168 } -val x1141 = x1140.isEmpty -val x1146 = if (x1141) { -val x993 = x991.dpt -val x1144 = new Schema.Record { val dpt = x993 } -val x1145 = List(x1144) -x1145 +val x1170 = x1169.isEmpty +val x1176 = if (x1170) { +val x1020 = x1018.dpt +val x1174 = new Schema.Record { val dpt = x1020 } +val x1175 = List(x1174) +x1175 } else { -val x19 = List() -x19 +val x34 = List() +x34 } -x1146 +x1176 } -val x2551 = println(x1147) -x2551 +val x2581 = println(x1177) +x2581 } } /***************************************** diff --git a/test-out/epfl/test9-struct3.check b/test-out/epfl/test9-struct3.check index 5b474aaf..b5eb6f3c 100644 --- a/test-out/epfl/test9-struct3.check +++ b/test-out/epfl/test9-struct3.check @@ -3,24 +3,25 @@ partitions: List(TTP(List(Sym(4), Sym(5), Sym(13)),List(SimpleLoop(Const(100),Sy considering TP(Sym(9),ArrayIndex(Sym(5),Sym(7))) replace TP(Sym(9),ArrayIndex(Sym(5),Sym(7))) at 1 within TTP(List(Sym(4), Sym(5), Sym(13)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2)))), SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(11))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))), ArrayElem(Block(Sym(11)))))) warning: mirroring of Sym(11)=Minus(Const(0.0),Sym(9)) type Double returned Sym(1) type Int (not a subtype) -warning: mirroring of Sym(13)=SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(11)))) type Array[Double] returned Sym(4)=SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))) type Array[Int] (not a subtype) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(4)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))))))) +partitions: List(TTP(List(Sym(4), Sym(17)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(1))))))) no changes, we're done -super.focusExactScopeFat with result changed from List(Sym(16)) to List(Sym(19)) +super.focusExactScopeFat with result changed from List(Sym(16)) to List(Sym(20)) /***************************************** Emitting Generated Code *******************************************/ class Test extends ((Int)=>(Unit)) { def apply(x0:Int): Unit = { var x4 = new Array[Int](100) +var x17 = new Array[Int](100) for (x1 <- 0 until 100) { x4(x1) = x1 +x17(x1) = x1 } -val x17 = new ArrayOfAnon189207751(x4,x4) -val x18 = println(x17) -val x15 = x18 +val x18 = new ArrayOfAnon189207751(x4,x17) +val x19 = println(x18) +val x15 = x19 x15 } } @@ -28,4 +29,4 @@ x15 End of Generated Code *******************************************/ -case class ArrayOfAnon189207751(re: Array[Int], im: Array[Int]) +case class ArrayOfAnon189207751(re: Array[Int], im: Array[Double]) diff --git a/test-src/epfl/test2-fft/DisableOpts.scala b/test-src/epfl/test2-fft/DisableOpts.scala index bdcffe04..ef84aaac 100644 --- a/test-src/epfl/test2-fft/DisableOpts.scala +++ b/test-src/epfl/test2-fft/DisableOpts.scala @@ -5,7 +5,7 @@ package test2 import internal._ trait DisableCSE extends Expressions { - override def findDefinition[T](d: Def[T]) = None + override def findDefinition[T: Manifest](d: Def[T]) = None } diff --git a/test-src/epfl/test3-parsers/Parsers.scala b/test-src/epfl/test3-parsers/Parsers.scala index 905bdf55..b586594e 100644 --- a/test-src/epfl/test3-parsers/Parsers.scala +++ b/test-src/epfl/test3-parsers/Parsers.scala @@ -6,9 +6,9 @@ trait Parsers { this: Matching with Extractors => type Elem type Input = List[Elem] + // Don't declare as implicit val in children, it gives problems with initialization order! implicit val mE: Manifest[Elem] - //implicit val mI: Manifest[List[Elem]] - + abstract class Parser { def apply(in: Rep[Input]): Rep[ParseResult] } diff --git a/test-src/epfl/test3-parsers/TestParsers.scala b/test-src/epfl/test3-parsers/TestParsers.scala index 8c04686a..6c4399d7 100644 --- a/test-src/epfl/test3-parsers/TestParsers.scala +++ b/test-src/epfl/test3-parsers/TestParsers.scala @@ -35,7 +35,7 @@ class TestParsers extends FileDiffSuite { with MatchingExtractorsExpOpt with FunctionsExpUnfoldAll with FlatResult // with ControlOpt with DisableCSE { type Elem = Char - implicit val mE = manifest[Char] + val mE = manifest[Char] //implicit val mI = manifest[List[Char]] def toElem(c: Char) = c } @@ -57,7 +57,7 @@ class TestParsers extends FileDiffSuite { with MatchingExtractorsExpOpt with FunctionsExpUnfoldAll with FlatResult // with ControlOpt { type Elem = Char - implicit val mE = manifest[Char] + val mE = manifest[Char] //implicit val mI = manifest[List[Char]] def toElem(c: Char) = c } From 25b2852ec7dc5291d7ee90e3b96c21ba49c2982c Mon Sep 17 00:00:00 2001 From: Alexey Romanov Date: Tue, 17 Nov 2015 16:16:43 +0300 Subject: [PATCH 4/4] Combine lhs and mhs in TTP --- src/common/IfThenElse.scala | 8 +- src/common/LoopFusionOpt.scala | 44 +++++------ src/common/Loops.scala | 8 +- src/common/SimplifyTransform.scala | 75 ++++++++++++------- src/common/SplitEffects.scala | 30 ++++---- src/common/Structs.scala | 9 +-- src/internal/FatCodegen.scala | 2 +- src/internal/FatExpressions.scala | 26 +++---- test-out/epfl/test7-fusion2.check | 12 +-- test-out/epfl/test7-fusion21.check | 4 +- test-out/epfl/test7-fusion22.check | 22 +++--- test-out/epfl/test7-fusion23.check | 18 ++--- test-out/epfl/test7-fusion24.check | 12 +-- test-out/epfl/test7-fusion4.check | 10 +-- test-out/epfl/test9-struct2b.check | 4 +- test-out/epfl/test9-struct3.check | 6 +- test-out/epfl/test9-struct4.check | 6 +- .../epfl/test10-transform/TestEffect.scala | 3 +- 18 files changed, 160 insertions(+), 139 deletions(-) diff --git a/src/common/IfThenElse.scala b/src/common/IfThenElse.scala index c691c9cf..d1628442 100644 --- a/src/common/IfThenElse.scala +++ b/src/common/IfThenElse.scala @@ -211,14 +211,14 @@ trait BaseGenIfThenElseFat extends BaseGenIfThenElse with GenericFatCodegen { import IR._ override def fatten(e: Stm): Stm = e match { - case TP(sym, o: AbstractIfThenElse[_]) => - TTP(List(sym), List(o), SimpleFatIfThenElse(o.cond, List(o.thenp), List(o.elsep))) - case TP(sym, p @ Reflect(o: AbstractIfThenElse[_], u, es)) => //if !u.maySimple && !u.mayGlobal => // contrary, fusing will not change observable order + case tp @ TP(sym, o: AbstractIfThenElse[_]) => + TTP(List(tp), SimpleFatIfThenElse(o.cond, List(o.thenp), List(o.elsep))) + case tp @ TP(sym, p @ Reflect(o: AbstractIfThenElse[_], u, es)) => //if !u.maySimple && !u.mayGlobal => // contrary, fusing will not change observable order // assume body will reflect, too... printdbg("-- fatten effectful if/then/else " + e) val e2 = SimpleFatIfThenElse(o.cond, List(o.thenp), List(o.elsep)) e2.extradeps = es //HACK - TTP(List(sym), List(p), e2) + TTP(List(tp), e2) case _ => super.fatten(e) } } diff --git a/src/common/LoopFusionOpt.scala b/src/common/LoopFusionOpt.scala index cb2087df..2b8a8fcc 100644 --- a/src/common/LoopFusionOpt.scala +++ b/src/common/LoopFusionOpt.scala @@ -269,7 +269,7 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif val levelScope = getExactScope(currentScope)(result) // could provide as input ... // TODO: cannot in general fuse several effect loops (one effectful and several pure ones is ok though) // so we need a strategy. a simple one would be exclude all effectful loops right away (TODO). - levelScope collect { case e @ TTP(_, _, SimpleFatLoop(_,_,_)) => e } + levelScope collect { case e @ TTP(_, SimpleFatLoop(_,_,_)) => e } } // FIXME: more than one super call means exponential cost -- is there a better way? @@ -284,7 +284,7 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif var done = false // keep track of loops in inner scopes - var UloopSyms = currentScope collect { case e @ TTP(lhs, _, SimpleFatLoop(_,_,_)) if !Wloops.contains(e) => lhs } + var UloopSyms = currentScope collect { case e @ TTP(_, SimpleFatLoop(_,_,_)) if !Wloops.contains(e) => e.lhs } //do{ @@ -367,7 +367,7 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif var partitionsIn = Wloops var partitionsOut = Nil:List[Stm] - for (b@ TTP(_,_,_) <- partitionsIn) { + for (b@ TTP(_,_) <- partitionsIn) { // try to add to an item in partitionsOut, if not possible add as-is partitionsOut.find(a => canFuse(a,b)) match { case Some(a: TTP) => @@ -394,13 +394,14 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif shapeA } - val lhs = a.lhs ++ b.lhs + val tps = a.tps ++ b.tps - val fused = TTP(lhs, a.mhs ++ b.mhs, SimpleFatLoop(shape, targetVar, WgetLoopRes(a):::WgetLoopRes(b))) + val fused = TTP(tps, SimpleFatLoop(shape, targetVar, WgetLoopRes(a):::WgetLoopRes(b))) partitionsOut = fused :: (partitionsOut diff List(a)) - val preNeg = WtableNeg collect { case p if (lhs contains p._2) => p._1 } - val postNeg = WtableNeg collect { case p if (lhs contains p._1) => p._2 } + val syms = tps.map(_.sym).toSet + val preNeg = WtableNeg collect { case p if (syms contains p._2) => p._1 } + val postNeg = WtableNeg collect { case p if (syms contains p._1) => p._2 } val fusedNeg = preNeg flatMap { s1 => postNeg map { s2 => (s1,s2) } } WtableNeg = (fusedNeg ++ WtableNeg).distinct @@ -461,10 +462,10 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif // prune Wloops (some might be no longer necessary) Wloops = pOutT map { - case TTP(lhs, mhs, SimpleFatLoop(s, x, rhs)) => - val ex = lhs map (s => currentScope exists (_.lhs contains s)) + case TTP(tps, SimpleFatLoop(s, x, rhs)) => + val ex = tps map (s => currentScope exists (_.lhs contains s.sym)) def select[A](a: List[A], b: List[Boolean]) = (a zip b) collect { case (w, true) => w } - TTP(select(lhs, ex), select(mhs, ex), SimpleFatLoop(s, x, select(rhs, ex))) + TTP(select(tps, ex), SimpleFatLoop(s, x, select(rhs, ex))) } currentScope = (currentScope diff pInT) ++ Wloops @@ -520,7 +521,7 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif val levelScope = getExactScope(currentScope)(result) // could provide as input ... // TODO: cannot in general fuse several effect loops (one effectful and several pure ones is ok though) // so we need a strategy. a simple one would be exclude all effectful loops right away (TODO). - levelScope collect { case e @ TTP(_, _, SimpleFatLoop(_,_,_)) => e } + levelScope collect { case e @ TTP(_, SimpleFatLoop(_,_,_)) => e } } // FIXME: more than one super call means exponential cost -- is there a better way? @@ -535,7 +536,7 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif var done = false // keep track of loops in inner scopes - var UloopSyms = currentScope collect { case e @ TTP(lhs, _, SimpleFatLoop(_,_,_)) if !Wloops.contains(e) => lhs } + var UloopSyms = currentScope collect { case e @ TTP(lhs, SimpleFatLoop(_,_,_)) if !Wloops.contains(e) => lhs.map(_.sym) } do { // utils @@ -630,7 +631,7 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif var partitionsIn = Wloops var partitionsOut = Nil:List[Stm] - for (b@ TTP(_,_,_) <- partitionsIn) { + for (b@ TTP(_,_) <- partitionsIn) { // try to add to an item in partitionsOut, if not possible add as-is partitionsOut.find(a => canFuse(a,b)) match { case Some(a: TTP) => @@ -659,11 +660,12 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif val lhs = a.lhs ++ b.lhs - val fused = TTP(lhs, a.mhs ++ b.mhs, SimpleFatLoop(shape, targetVar, WgetLoopRes(a):::WgetLoopRes(b))) + val fused = TTP(lhs, SimpleFatLoop(shape, targetVar, WgetLoopRes(a):::WgetLoopRes(b))) partitionsOut = fused :: (partitionsOut diff List(a)) - val preNeg = WtableNeg collect { case p if (lhs contains p._2) => p._1 } - val postNeg = WtableNeg collect { case p if (lhs contains p._1) => p._2 } + val syms = lhs.map(_.sym).toSet + val preNeg = WtableNeg collect { case p if (syms contains p._2) => p._1 } + val postNeg = WtableNeg collect { case p if (syms contains p._1) => p._2 } val fusedNeg = preNeg flatMap { s1 => postNeg map { s2 => (s1,s2) } } WtableNeg = (fusedNeg ++ WtableNeg).distinct @@ -722,10 +724,10 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif // prune Wloops (some might be no longer necessary) Wloops = Wloops map { - case TTP(lhs, mhs, SimpleFatLoop(s, x, rhs)) => - val ex = lhs map (s => currentScope exists (_.lhs == List(s))) + case TTP(lhs, SimpleFatLoop(s, x, rhs)) => + val ex = lhs map (s => currentScope exists (_.lhs == List(s.sym))) def select[A](a: List[A], b: List[Boolean]) = (a zip b) collect { case (w, true) => w } - TTP(select(lhs, ex), select(mhs, ex), SimpleFatLoop(s, x, select(rhs, ex))) + TTP(select(lhs, ex), SimpleFatLoop(s, x, select(rhs, ex))) } // PREVIOUS PROBLEM: don't throw out all loops, might have some that are *not* in levelScope @@ -733,8 +735,8 @@ trait LoopFusionCore extends internal.FatScheduling with CodeMotion with Simplif // FatCodegen.focusExactScopeFat below. --> how to go back from SimpleFatLoop to VectorPlus?? // UPDATE: UloopSyms puts a tentative fix in place. check if it is sufficient!! // what is the reason we cannot just look at Wloops?? - currentScope = currentScope.filter { case e@TTP(lhs, _, _: AbstractFatLoop) => - val keep = UloopSyms contains lhs + currentScope = currentScope.filter { case e@TTP(lhs, _: AbstractFatLoop) => + val keep = UloopSyms contains lhs.map(_.sym) //if (!keep) println("dropping: " + e + ", not int UloopSyms: " + UloopSyms) keep case _ => true } ::: Wloops diff --git a/src/common/Loops.scala b/src/common/Loops.scala index 4f1b83b4..6d4f6f27 100644 --- a/src/common/Loops.scala +++ b/src/common/Loops.scala @@ -137,11 +137,11 @@ trait BaseLoopsTraversalFat extends FatBlockTraversal { import IR._ override def fatten(e: Stm): Stm = e match { - case TP(sym, op: AbstractLoop[_]) => - TTP(List(sym), List(op), SimpleFatLoop(op.size, op.v, List(op.body))) - case TP(sym, p @ Reflect(op: AbstractLoop[_], u, es)) if !u.maySimple && !u.mayGlobal => // assume body will reflect, too. bring it on... + case tp @ TP(sym, op: AbstractLoop[_]) => + TTP(List(tp), SimpleFatLoop(op.size, op.v, List(op.body))) + case tp @ TP(sym, p @ Reflect(op: AbstractLoop[_], u, es)) if !u.maySimple && !u.mayGlobal => // assume body will reflect, too. bring it on... printdbg("-- fatten effectful loop " + e) - TTP(List(sym), List(p), SimpleFatLoop(op.size, op.v, List(op.body))) + TTP(List(tp), SimpleFatLoop(op.size, op.v, List(op.body))) case _ => super.fatten(e) } diff --git a/src/common/SimplifyTransform.scala b/src/common/SimplifyTransform.scala index 6d4387ad..e4e5a3a4 100644 --- a/src/common/SimplifyTransform.scala +++ b/src/common/SimplifyTransform.scala @@ -106,20 +106,22 @@ trait SimplifyTransform extends internal.FatScheduling { case s: Sym[Any] => (Option(scopeIndex.get(s)) orElse findDefinition(s)).toList // check scope before target graph case _ => Nil } - case TTP(lhs, mhs, SimpleFatIfThenElse(c,as,bs)) => + case TTP(tps, SimpleFatIfThenElse(c,as,bs)) => // alternate strategy: transform thin def, then fatten again (a little detour) - printdbg("need to transform rhs of fat if/then/else: " + lhs + ", if " + c + " then " + as + " else " + bs) - val lhs2 = (lhs zip mhs).map { case (s,r) => transformOne(s, r, t) }.distinct.asInstanceOf[List[Sym[Any]]] + val lhs1 = tps.map(_.sym) + printdbg("need to transform rhs of fat if/then/else: " + lhs1 + ", if " + c + " then " + as + " else " + bs) + val lhs2 = tps.map { case TP(s,r) => transformOne(s, r, t) }.distinct.asInstanceOf[List[Sym[Any]]] val mhs2 = lhs2.map(s => findDefinition(s).get.defines(s).get) // TBD: we're mirroring the defs in mhs, creating new stms // we don't really want new stms: if the defs are just abstract descriptions we only want them updated // this means we'll have both a TP and a TTP defining the same sym in globalDefs --> bad! // not quite so fast, chances are the TTP's never make it into globalDefs (no toAtom call)!!! - - if (lhs != lhs2) { + + val lhsesAreDifferent = lhs1 != lhs2 + if (lhsesAreDifferent) { val missing = Nil//(lhs2.map(s => findDefinition(s).get) diff innerScope) - printdbg("lhs changed! will add to innerScope: "+missing.mkString(",")) + printdbg("tps changed! will add to innerScope: "+missing.mkString(",")) //innerScope = innerScope ::: missing } @@ -127,44 +129,65 @@ trait SimplifyTransform extends internal.FatScheduling { case l: AbstractIfThenElse[_] => l case Reflect(l: AbstractIfThenElse[_], _, _) => l } - val cond2 = if (lhs != lhs2) mhs2.map (_.toIf.cond) reduceLeft { (s1,s2) => assert(s1==s2,"conditions don't agree: "+s1+","+s2); s1 } - else t(c) - val as2 = (if (lhs != lhs2) (lhs2 zip (mhs2 map (_.toIf.thenp))) - else (lhs zip as)) map { case (s,r) => transformIfBody(s,r,t) } - val bs2 = (if (lhs != lhs2) (lhs2 zip (mhs2 map (_.toIf.elsep))) - else (lhs zip bs)) map { case (s,r) => transformIfBody(s,r,t) } + def branches(ifDifferent: AbstractIfThenElse[_] => Block[_], ifSame: List[Block[_]]) = { + val rhs2 = if (lhsesAreDifferent) + mhs2.map(x => ifDifferent(x.toIf)) + else + ifSame + lhs2.zip(rhs2).map { case (s,r) => transformIfBody(s,r,t) } + } + + val cond2 = if (lhsesAreDifferent) + mhs2.map(_.toIf.cond).reduceLeft { (s1,s2) => + assert(s1==s2,"conditions don't agree: "+s1+","+s2) + s1 + } + else + t(c) + val as2 = branches(_.thenp, as) + val bs2 = branches(_.elsep, bs) printdbg("came up with: " + lhs2 + ", if " + cond2 + " then " + as2 + " else " + bs2 + " with subst " + t.subst.mkString(",")) - List(TTP(lhs2, mhs2, SimpleFatIfThenElse(cond2,as2,bs2))) + List(TTP(lhs2.zip(mhs2).map { case (s, d) => TP(s,d) }, SimpleFatIfThenElse(cond2,as2,bs2))) - case TTP(lhs, mhs, SimpleFatLoop(s,x,rhs)) => + case TTP(tps, SimpleFatLoop(s,x,rhs)) => // alternate strategy: transform thin def, then fatten again (a little detour) - printdbg("need to transform rhs of fat loop: " + lhs + ", " + rhs) - val lhs2 = (lhs zip mhs).map { case (s,r) => transformOne(s, r, t) }.distinct.asInstanceOf[List[Sym[Any]]] + val lhs1 = tps.map(_.sym) + printdbg("need to transform rhs of fat loop: " + lhs1 + ", " + rhs) + val lhs2 = tps.map { case TP(s,r) => transformOne(s, r, t) }.distinct.asInstanceOf[List[Sym[Any]]] val mhs2 = lhs2.map(s => findDefinition(s).get.defines(s).get) - if (lhs != lhs2) { + val lhsesAreDifferent = lhs1 != lhs2 + if (lhsesAreDifferent) { val missing = (lhs2.map(s => findDefinition(s).get) diff scope/*innerScope*/) - printdbg("lhs changed! will add to innerScope: "+missing.mkString(",")) + printdbg("tps changed! will add to innerScope: "+missing.mkString(",")) //innerScope = innerScope ::: missing } - //val shape2 = if (lhs != lhs2) lhs2.map { case Def(SimpleLoop(s,_,_)) => s } reduceLeft { (s1,s2) => assert(s1==s2,"shapes don't agree: "+s1+","+s2); s1 } + //val shape2 = if (lhs1 != lhs2) lhs2.map { case Def(SimpleLoop(s,_,_)) => s } reduceLeft { (s1,s2) => assert(s1==s2,"shapes don't agree: "+s1+","+s2); s1 } def infix_toLoop(d: Def[Any]) = d match { case l: AbstractLoop[_] => l case Reflect(l: AbstractLoop[_], _, _) => l } - val shape2 = if (lhs != lhs2) mhs2.map (_.toLoop.size) reduceLeft { (s1,s2) => assert(s1==s2,"shapes don't agree: "+s1+","+s2); s1 } - else t(s) - val rhs2 = (if (lhs != lhs2) (lhs2 zip (mhs2 map (_.toLoop.body))) - else (lhs zip rhs)) map { case (s,r) => transformLoopBody(s,r,t) } + val shape2 = if (lhsesAreDifferent) + mhs2.map(_.toLoop.size).reduceLeft { (s1,s2) => + assert(s1==s2,"shapes don't agree: "+s1+","+s2) + s1 + } + else + t(s) + val rhs2 = if (lhsesAreDifferent) + mhs2 map (_.toLoop.body) + else + rhs + val rhs3 = lhs2.zip(rhs2).map { case (s,r) => transformLoopBody(s,r,t) } /* //update innerScope -- change definition of lhs2 in place (necessary?) innerScope = innerScope map { - case TP(l,_) if lhs2 contains l => TP(l, SimpleLoop(shape2,t(x).asInstanceOf[Sym[Int]],rhs2(lhs2.indexOf(l)))) + case TP(l,_) if lhs2 contains l => TP(l, SimpleLoop(shape2,t(x).asInstanceOf[Sym[Int]],rhs3(lhs2.indexOf(l)))) case d => d }*/ - printdbg("came up with: " + lhs2 + ", " + rhs2 + " with subst " + t.subst.mkString(",")) - List(TTP(lhs2, mhs2, SimpleFatLoop(shape2,t(x).asInstanceOf[Sym[Int]],rhs2))) + printdbg("came up with: " + lhs2 + ", " + rhs3 + " with subst " + t.subst.mkString(",")) + List(TTP(lhs2.zip(mhs2).map { case (s, d) => TP(s,d) }, SimpleFatLoop(shape2,t(x).asInstanceOf[Sym[Int]],rhs3))) // still problem: VectorSum(a,b) = SimpleLoop(i, ReduceElem(f(i))) // might need to translate f(i), but looking up VectorSum will not be changed at all!!! // --> change rhs nonetheless??? diff --git a/src/common/SplitEffects.scala b/src/common/SplitEffects.scala index 162cabfe..38a4f0cd 100644 --- a/src/common/SplitEffects.scala +++ b/src/common/SplitEffects.scala @@ -183,14 +183,14 @@ trait BaseGenSplitEffects extends BaseGenIfThenElseFat with GenericFatCodegen { override def fatten(e: Stm): Stm = e match { - case TP(s,d@While(c,b)) => TTP(List(s),List(d),SimpleFatWhile(c,List(b))) - case TP(s,d@Reflect(While(c,b),u,es)) => + case tp @ TP(s,d@While(c,b)) => TTP(List(tp),SimpleFatWhile(c,List(b))) + case tp @ TP(s,d@Reflect(While(c,b),u,es)) => val x = SimpleFatWhile(c,List(b)) x.extradeps = es.asInstanceOf[List[Sym[Any]]] - TTP(List(s),List(d),x) - case TP(s,d@Reflect(PreviousIteration(k),u,es)) => + TTP(List(tp),x) + case tp @ TP(s,d@Reflect(PreviousIteration(k),u,es)) => val x = SimpleFatPrevious(k,es.asInstanceOf[List[Sym[Any]]]) - TTP(List(s),List(d),x) + TTP(List(tp),x) case _ => super.fatten(e) } @@ -205,31 +205,31 @@ trait BaseGenSplitEffects extends BaseGenIfThenElseFat with GenericFatCodegen { //println(e1) val e2 = e1 collect { - case t@TTP(lhs, mhs, p @ SimpleFatIfThenElse(c,as,bs)) => t - case t@TTP(lhs, mhs, p @ SimpleFatWhile(c,b)) => t - case t@TTP(lhs, mhs, p @ SimpleFatPrevious(k,es)) => t + case t@TTP(_, p @ SimpleFatIfThenElse(c,as,bs)) => t + case t@TTP(_, p @ SimpleFatWhile(c,b)) => t + case t@TTP(_, p @ SimpleFatPrevious(k,es)) => t } val m = e2 groupBy { - case t@TTP(lhs, mhs, p @ SimpleFatIfThenElse(c,as,bs)) => (c, "if") - case t@TTP(lhs, mhs, p @ SimpleFatWhile(Block(Def(Reify(c,_,_))),b)) => (c, "while") - case t@TTP(lhs, mhs, p @ SimpleFatPrevious(k,es)) => (k,"prev") + case t@TTP(_, p @ SimpleFatIfThenElse(c,as,bs)) => (c, "if") + case t@TTP(_, p @ SimpleFatWhile(Block(Def(Reify(c,_,_))),b)) => (c, "while") + case t@TTP(_, p @ SimpleFatPrevious(k,es)) => (k,"prev") } val e3 = e1 diff e2 val g1 = m map { - case ((c:Exp[Boolean], "if"), ifs: List[TTP]) => TTP(ifs.flatMap(_.lhs), ifs.flatMap(_.mhs), + case ((c:Exp[Boolean], "if"), ifs: List[TTP]) => TTP(ifs.flatMap(_.tps), SimpleFatIfThenElse(c, ifs.flatMap(_.rhs.asInstanceOf[SimpleFatIfThenElse].thenp), ifs.flatMap(_.rhs.asInstanceOf[SimpleFatIfThenElse].elsep))) case ((c, "while"), wls: List[TTP]) => val x = SimpleFatWhile(wls.map(_.rhs.asInstanceOf[SimpleFatWhile].cond).apply(0), //FIXME: merge cond!!! wls.flatMap(_.rhs.asInstanceOf[SimpleFatWhile].body)) - x.extradeps = wls.flatMap(_.rhs.asInstanceOf[SimpleFatWhile].extradeps) diff wls.flatMap(_.lhs) - TTP(wls.flatMap(_.lhs), wls.flatMap(_.mhs), // TODO: merge cond blocks! + x.extradeps = wls.flatMap(_.rhs.asInstanceOf[SimpleFatWhile].extradeps) diff wls.flatMap(_.tps) + TTP(wls.flatMap(_.tps), // TODO: merge cond blocks! x) case ((k:Exp[Nothing],"prev"), pvs: List[TTP]) => - TTP(pvs.flatMap(_.lhs), pvs.flatMap(_.mhs), SimpleFatPrevious(k,pvs.flatMap(_.rhs.asInstanceOf[SimpleFatPrevious].extra))) + TTP(pvs.flatMap(_.tps), SimpleFatPrevious(k,pvs.flatMap(_.rhs.asInstanceOf[SimpleFatPrevious].extra))) } val r = e3 ++ g1 diff --git a/src/common/Structs.scala b/src/common/Structs.scala index 6e23349a..cfe423bc 100644 --- a/src/common/Structs.scala +++ b/src/common/Structs.scala @@ -365,18 +365,17 @@ trait BaseGenFatStruct extends GenericFatCodegen { //println("grouped: ") //println(m.mkString("\n")) def fatphi(s:Sym[Unit]) = m.get(s).map { phis => - val ss = phis collect { case TP(s, _) => s } val us = phis collect { case TP(_, Phi(c,a,u,b,v)) => u } // assert c,a,b match val vs = phis collect { case TP(_, Phi(c,a,u,b,v)) => v } val c = phis collect { case TP(_, Phi(c,a,u,b,v)) => c } reduceLeft { (c1,c2) => assert(c1 == c2); c1 } - TTP(ss, phis map (_.rhs), SimpleFatIfThenElse(c,us,vs)) + TTP(phis, SimpleFatIfThenElse(c,us,vs)) } def fatif(s:Sym[Unit],o:Def[Unit],c:Exp[Boolean],a:Block[Unit],b:Block[Unit]) = fatphi(s) match { - case Some(TTP(ss, oo, SimpleFatIfThenElse(c2,us,vs))) => + case Some(TTP(tps, SimpleFatIfThenElse(c2,us,vs))) => assert(c == c2) - TTP(s::ss, o::oo, SimpleFatIfThenElse(c,a::us,b::vs)) + TTP(TP(s, o) :: tps, SimpleFatIfThenElse(c,a::us,b::vs)) case _ => - TTP(s::Nil, o::Nil, SimpleFatIfThenElse(c,a::Nil,b::Nil)) + TTP(List(TP(s, o)), SimpleFatIfThenElse(c,a::Nil,b::Nil)) } val orphans = m.keys.toList.filterNot(k => e exists (_.lhs contains k)) // parent if/else might have been removed! diff --git a/src/internal/FatCodegen.scala b/src/internal/FatCodegen.scala index 497d3f5d..dd4479bd 100644 --- a/src/internal/FatCodegen.scala +++ b/src/internal/FatCodegen.scala @@ -10,7 +10,7 @@ trait GenericFatCodegen extends GenericNestedCodegen with FatBlockTraversal { override def traverseStm(stm: Stm) = stm match { - case TTP(lhs, mhs, rhs) => emitFatNode(lhs, rhs) + case ttp: TTP => emitFatNode(ttp.lhs, ttp.rhs) case _ => super.traverseStm(stm) } diff --git a/src/internal/FatExpressions.scala b/src/internal/FatExpressions.scala index c2397a79..e958cafb 100644 --- a/src/internal/FatExpressions.scala +++ b/src/internal/FatExpressions.scala @@ -7,38 +7,36 @@ trait FatExpressions extends Expressions { //case class ThinDef(rhs: Def[Any]) extends FatDef - case class TTP(val lhs: List[Sym[Any]], val mhs: List[Def[Any]], val rhs: FatDef) extends Stm + case class TTP(tps: List[TP[Any]], rhs: FatDef) extends Stm override def infix_lhs(stm: Stm): List[Sym[Any]] = stm match { - case TTP(lhs, mhs, rhs) => lhs + case TTP(tps, _) => tps.map(_.sym) case _ => super.infix_lhs(stm) } override def infix_rhs(stm: Stm): Any = stm match { - case TTP(lhs, mhs, rhs) => rhs + case TTP(_, rhs) => rhs case _ => super.infix_rhs(stm) } override def infix_defines[A](stm: Stm, sym: Sym[A]): Option[Def[A]] = stm match { - case TTP(lhs, mhs, rhs) => lhs.indexOf(sym) match { case idx if idx >= 0 => Some(mhs(idx).asInstanceOf[Def[A]]) case _ => None } + case TTP(tps, rhs) => + tps.flatMap { + case tp => tp.defines(sym) + }.headOption case _ => super.infix_defines(stm, sym) } override def infix_defines[A: Manifest](stm: Stm, rhs: Def[A]): Option[Sym[A]] = stm match { - case TTP(lhs, mhs, rhs) => mhs.indexOf(rhs) match { - case idx if idx >= 0 => - val sym = lhs(idx) - if (sym.tp <:< manifest[A]) - Some(sym.asInstanceOf[Sym[A]]) - else - None - case _ => None - } + case TTP(tps, _) => + tps.flatMap { + // compiler fails to resolve the correct infix_defines if manifest[A] is left implicit + case tp => tp.defines(rhs)(manifest[A]) + }.headOption case _ => super.infix_defines(stm, rhs) } - case class Combine(a: List[Exp[Any]]) extends Exp[Any] //TODO: get rid of. used by emitFatBlock case class Forward[A](x: Exp[A]) extends Def[A] // TODO: get rid of. used by SimplifyTransform diff --git a/test-out/epfl/test7-fusion2.check b/test-out/epfl/test7-fusion2.check index 8069eba9..b5aa9ae5 100644 --- a/test-out/epfl/test7-fusion2.check +++ b/test-out/epfl/test7-fusion2.check @@ -5,22 +5,22 @@ fusion of List((Sym(5),Sym(18))) prevented by TP(Sym(8),ArrayIndex(Sym(5),Sym(6) fusion of List((Sym(2),Sym(22))) prevented by TP(Sym(7),ArrayIndex(Sym(2),Sym(6))) which is required by body of List(Sym(22)) fusion of List((Sym(5),Sym(22))) prevented by TP(Sym(8),ArrayIndex(Sym(5),Sym(6))) which is required by body of List(Sym(22)) wtableneg: List((Sym(2),Sym(13)), (Sym(5),Sym(13)), (Sym(2),Sym(18)), (Sym(5),Sym(18)), (Sym(2),Sym(22)), (Sym(5),Sym(22))) -partitions: List(TTP(List(Sym(13), Sym(18), Sym(22)),List(SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(12)))), SimpleLoop(Const(100),Sym(15),ReduceElem(Block(Sym(17)))), SimpleLoop(Const(100),Sym(20),ReduceElem(Block(Sym(21))))),SimpleFatLoop(Const(100),Sym(11),List(ReduceElem(Block(Sym(12))), ReduceElem(Block(Sym(17))), ReduceElem(Block(Sym(21)))))), TTP(List(Sym(2), Sym(5), Sym(10)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(1.0)))), SimpleLoop(Const(100),Sym(3),ArrayElem(Block(Sym(4)))), SimpleLoop(Const(100),Sym(6),ArrayElem(Block(Sym(9))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Sym(4))), ArrayElem(Block(Sym(9))))))) +partitions: List(TTP(List(TP(Sym(13),SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(12))))), TP(Sym(18),SimpleLoop(Const(100),Sym(15),ReduceElem(Block(Sym(17))))), TP(Sym(22),SimpleLoop(Const(100),Sym(20),ReduceElem(Block(Sym(21)))))),SimpleFatLoop(Const(100),Sym(11),List(ReduceElem(Block(Sym(12))), ReduceElem(Block(Sym(17))), ReduceElem(Block(Sym(21)))))), TTP(List(TP(Sym(2),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(1.0))))), TP(Sym(5),SimpleLoop(Const(100),Sym(3),ArrayElem(Block(Sym(4))))), TP(Sym(10),SimpleLoop(Const(100),Sym(6),ArrayElem(Block(Sym(9)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Sym(4))), ArrayElem(Block(Sym(9))))))) considering TP(Sym(7),ArrayIndex(Sym(2),Sym(6))) -replace TP(Sym(7),ArrayIndex(Sym(2),Sym(6))) at 0 within TTP(List(Sym(2), Sym(5), Sym(10)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(1.0)))), SimpleLoop(Const(100),Sym(3),ArrayElem(Block(Sym(4)))), SimpleLoop(Const(100),Sym(6),ArrayElem(Block(Sym(9))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Sym(4))), ArrayElem(Block(Sym(9)))))) +replace TP(Sym(7),ArrayIndex(Sym(2),Sym(6))) at 0 within TTP(List(TP(Sym(2),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(1.0))))), TP(Sym(5),SimpleLoop(Const(100),Sym(3),ArrayElem(Block(Sym(4))))), TP(Sym(10),SimpleLoop(Const(100),Sym(6),ArrayElem(Block(Sym(9)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Sym(4))), ArrayElem(Block(Sym(9)))))) considering TP(Sym(8),ArrayIndex(Sym(5),Sym(6))) -replace TP(Sym(8),ArrayIndex(Sym(5),Sym(6))) at 1 within TTP(List(Sym(2), Sym(5), Sym(10)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(1.0)))), SimpleLoop(Const(100),Sym(3),ArrayElem(Block(Sym(4)))), SimpleLoop(Const(100),Sym(6),ArrayElem(Block(Sym(9))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Sym(4))), ArrayElem(Block(Sym(9)))))) +replace TP(Sym(8),ArrayIndex(Sym(5),Sym(6))) at 1 within TTP(List(TP(Sym(2),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(1.0))))), TP(Sym(5),SimpleLoop(Const(100),Sym(3),ArrayElem(Block(Sym(4))))), TP(Sym(10),SimpleLoop(Const(100),Sym(6),ArrayElem(Block(Sym(9)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Sym(4))), ArrayElem(Block(Sym(9)))))) considering TP(Sym(12),ArrayIndex(Sym(10),Sym(11))) considering TP(Sym(16),ArrayIndex(Sym(10),Sym(15))) considering TP(Sym(21),ArrayIndex(Sym(10),Sym(20))) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(32), Sym(34), Sym(38)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(31)))), SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(33)))), SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(37))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(31))), ReduceElem(Block(Sym(33))), ReduceElem(Block(Sym(37))))))) +partitions: List(TTP(List(TP(Sym(32),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(31))))), TP(Sym(34),SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(33))))), TP(Sym(38),SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(37)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(31))), ReduceElem(Block(Sym(33))), ReduceElem(Block(Sym(37))))))) considering TP(Sym(33),ArrayIndex(Sym(32),Sym(11))) -replace TP(Sym(33),ArrayIndex(Sym(32),Sym(11))) at 0 within TTP(List(Sym(32), Sym(34), Sym(38)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(31)))), SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(33)))), SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(37))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(31))), ReduceElem(Block(Sym(33))), ReduceElem(Block(Sym(37)))))) +replace TP(Sym(33),ArrayIndex(Sym(32),Sym(11))) at 0 within TTP(List(TP(Sym(32),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(31))))), TP(Sym(34),SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(33))))), TP(Sym(38),SimpleLoop(Const(100),Sym(11),ReduceElem(Block(Sym(37)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(31))), ReduceElem(Block(Sym(33))), ReduceElem(Block(Sym(37)))))) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(45), Sym(46)),List(SimpleLoop(Const(100),Sym(1),ReduceElem(Block(Sym(31)))), SimpleLoop(Const(100),Sym(1),ReduceElem(Block(Sym(44))))),SimpleFatLoop(Const(100),Sym(1),List(ReduceElem(Block(Sym(31))), ReduceElem(Block(Sym(44))))))) +partitions: List(TTP(List(TP(Sym(45),SimpleLoop(Const(100),Sym(1),ReduceElem(Block(Sym(31))))), TP(Sym(46),SimpleLoop(Const(100),Sym(1),ReduceElem(Block(Sym(44)))))),SimpleFatLoop(Const(100),Sym(1),List(ReduceElem(Block(Sym(31))), ReduceElem(Block(Sym(44))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(28)) to List(Sym(53)) /***************************************** diff --git a/test-out/epfl/test7-fusion21.check b/test-out/epfl/test7-fusion21.check index 4c94a031..e037e5b6 100644 --- a/test-out/epfl/test7-fusion21.check +++ b/test-out/epfl/test7-fusion21.check @@ -1,7 +1,7 @@ fusion of List((Sym(2),Sym(7))) prevented by TP(Sym(6),ArrayIndex(Sym(2),Const(0))) which is required by body of List(Sym(7)) fusion of List((Sym(4),Sym(10))) prevented by TP(Sym(9),ArrayIndex(Sym(4),Const(0))) which is required by body of List(Sym(10)) wtableneg: List((Sym(2),Sym(7)), (Sym(4),Sym(10))) -partitions: List(TTP(List(Sym(10)),List(SimpleLoop(Const(100),Sym(8),ArrayElem(Block(Sym(9))))),SimpleFatLoop(Const(100),Sym(8),List(ArrayElem(Block(Sym(9)))))), TTP(List(Sym(4), Sym(7)),List(SimpleLoop(Const(50),Sym(3),ArrayElem(Block(Const(3.0)))), SimpleLoop(Const(50),Sym(5),ArrayElem(Block(Sym(6))))),SimpleFatLoop(Const(50),Sym(3),List(ArrayElem(Block(Const(3.0))), ArrayElem(Block(Sym(6)))))), TTP(List(Sym(2)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(9.0))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(9.0))))))) +partitions: List(TTP(List(TP(Sym(10),SimpleLoop(Const(100),Sym(8),ArrayElem(Block(Sym(9)))))),SimpleFatLoop(Const(100),Sym(8),List(ArrayElem(Block(Sym(9)))))), TTP(List(TP(Sym(4),SimpleLoop(Const(50),Sym(3),ArrayElem(Block(Const(3.0))))), TP(Sym(7),SimpleLoop(Const(50),Sym(5),ArrayElem(Block(Sym(6)))))),SimpleFatLoop(Const(50),Sym(3),List(ArrayElem(Block(Const(3.0))), ArrayElem(Block(Sym(6)))))), TTP(List(TP(Sym(2),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(9.0)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(9.0))))))) considering TP(Sym(6),ArrayIndex(Sym(2),Const(0))) considering TP(Sym(9),ArrayIndex(Sym(4),Const(0))) try once more ... @@ -9,7 +9,7 @@ fusion of List((Sym(2),Sym(4)), (Sym(2),Sym(7))) prevented by TP(Sym(6),ArrayInd fusion of List((Sym(2),Sym(10))) prevented by TP(Sym(6),ArrayIndex(Sym(2),Const(0))) which is required by body of List(Sym(10)) fusion of List((Sym(4),Sym(10))) prevented by TP(Sym(9),ArrayIndex(Sym(4),Const(0))) which is required by body of List(Sym(10)) wtableneg: List((Sym(2),Sym(4)), (Sym(2),Sym(7)), (Sym(2),Sym(10)), (Sym(4),Sym(10))) -partitions: List(TTP(List(Sym(10)),List(SimpleLoop(Const(100),Sym(8),ArrayElem(Block(Sym(9))))),SimpleFatLoop(Const(100),Sym(8),List(ArrayElem(Block(Sym(9)))))), TTP(List(Sym(4), Sym(7)),List(SimpleLoop(Const(50),Sym(3),ArrayElem(Block(Const(3.0)))), SimpleLoop(Const(50),Sym(5),ArrayElem(Block(Sym(6))))),SimpleFatLoop(Const(50),Sym(3),List(ArrayElem(Block(Const(3.0))), ArrayElem(Block(Sym(6)))))), TTP(List(Sym(2)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(9.0))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(9.0))))))) +partitions: List(TTP(List(TP(Sym(10),SimpleLoop(Const(100),Sym(8),ArrayElem(Block(Sym(9)))))),SimpleFatLoop(Const(100),Sym(8),List(ArrayElem(Block(Sym(9)))))), TTP(List(TP(Sym(4),SimpleLoop(Const(50),Sym(3),ArrayElem(Block(Const(3.0))))), TP(Sym(7),SimpleLoop(Const(50),Sym(5),ArrayElem(Block(Sym(6)))))),SimpleFatLoop(Const(50),Sym(3),List(ArrayElem(Block(Const(3.0))), ArrayElem(Block(Sym(6)))))), TTP(List(TP(Sym(2),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Const(9.0)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Const(9.0))))))) no changes, we're done /***************************************** Emitting Generated Code diff --git a/test-out/epfl/test7-fusion22.check b/test-out/epfl/test7-fusion22.check index 6a1a0999..557006cf 100644 --- a/test-out/epfl/test7-fusion22.check +++ b/test-out/epfl/test7-fusion22.check @@ -1,30 +1,30 @@ -fusion of List((Sym(3),Sym(23))) prevented by TTP(List(Sym(4)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3)))))) which is required by body of List(Sym(23)) -fusion of List((Sym(7),Sym(23))) prevented by TTP(List(Sym(8)),List(SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))),SimpleFatLoop(Const(100),Sym(5),List(ArrayElem(Block(Sym(7)))))) which is required by body of List(Sym(23)) -fusion of List((Sym(11),Sym(23))) prevented by TTP(List(Sym(12)),List(SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))),SimpleFatLoop(Const(100),Sym(9),List(ArrayElem(Block(Sym(11)))))) which is required by body of List(Sym(23)) +fusion of List((Sym(3),Sym(23))) prevented by TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3)))))) which is required by body of List(Sym(23)) +fusion of List((Sym(7),Sym(23))) prevented by TTP(List(TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))))),SimpleFatLoop(Const(100),Sym(5),List(ArrayElem(Block(Sym(7)))))) which is required by body of List(Sym(23)) +fusion of List((Sym(11),Sym(23))) prevented by TTP(List(TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))))),SimpleFatLoop(Const(100),Sym(9),List(ArrayElem(Block(Sym(11)))))) which is required by body of List(Sym(23)) wtableneg: List((Sym(3),Sym(23)), (Sym(7),Sym(23)), (Sym(11),Sym(23))) -partitions: List(TTP(List(Sym(4), Sym(8), Sym(12), Sym(23)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))), TTP(List(Sym(3), Sym(7), Sym(11)),List(SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(23),SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))), TTP(List(TP(Sym(3),SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(7),SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(11),SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0)))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))))))) considering TP(Sym(15),ArrayIndex(Sym(4),Sym(13))) -replace TP(Sym(15),ArrayIndex(Sym(4),Sym(13))) at 0 within TTP(List(Sym(4), Sym(8), Sym(12), Sym(23)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) +replace TP(Sym(15),ArrayIndex(Sym(4),Sym(13))) at 0 within TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(23),SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) considering TP(Sym(16),ArrayIndex(Sym(15),Sym(14))) considering TP(Sym(17),ArrayIndex(Sym(8),Sym(13))) -replace TP(Sym(17),ArrayIndex(Sym(8),Sym(13))) at 1 within TTP(List(Sym(4), Sym(8), Sym(12), Sym(23)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) +replace TP(Sym(17),ArrayIndex(Sym(8),Sym(13))) at 1 within TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(23),SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) considering TP(Sym(18),ArrayIndex(Sym(17),Sym(14))) considering TP(Sym(21),ArrayIndex(Sym(12),Sym(13))) -replace TP(Sym(21),ArrayIndex(Sym(12),Sym(13))) at 2 within TTP(List(Sym(4), Sym(8), Sym(12), Sym(23)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) +replace TP(Sym(21),ArrayIndex(Sym(12),Sym(13))) at 2 within TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(23),SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) try once more ... fusion of List((Sym(3),Sym(4)), (Sym(3),Sym(8)), (Sym(3),Sym(12)), (Sym(3),Sym(34))) prevented by TP(Sym(29),ArrayIndex(Sym(3),Sym(14))) which is required by body of List(Sym(4), Sym(8), Sym(12), Sym(34)) fusion of List((Sym(7),Sym(4)), (Sym(7),Sym(8)), (Sym(7),Sym(12)), (Sym(7),Sym(34))) prevented by TP(Sym(30),ArrayIndex(Sym(7),Sym(14))) which is required by body of List(Sym(4), Sym(8), Sym(12), Sym(34)) fusion of List((Sym(32),Sym(4)), (Sym(32),Sym(8)), (Sym(32),Sym(12)), (Sym(32),Sym(34)), (Sym(11),Sym(4)), (Sym(11),Sym(8)), (Sym(11),Sym(12)), (Sym(11),Sym(34))) prevented by TP(Sym(33),Plus(Sym(32),Sym(11))) which is required by body of List(Sym(4), Sym(8), Sym(12), Sym(34)) wtableneg: List((Sym(3),Sym(4)), (Sym(3),Sym(8)), (Sym(3),Sym(12)), (Sym(3),Sym(34)), (Sym(7),Sym(4)), (Sym(7),Sym(8)), (Sym(7),Sym(12)), (Sym(7),Sym(34)), (Sym(32),Sym(4)), (Sym(32),Sym(8)), (Sym(32),Sym(12)), (Sym(32),Sym(34)), (Sym(11),Sym(4)), (Sym(11),Sym(8)), (Sym(11),Sym(12)), (Sym(11),Sym(34))) -partitions: List(TTP(List(Sym(4), Sym(8), Sym(12), Sym(34)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(33))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(33)))))), TTP(List(Sym(3), Sym(7), Sym(11), Sym(32)),List(SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0)))), SimpleLoop(Const(50),Sym(14),ReduceElem(Block(Sym(31))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(31))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(34),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(33)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(33)))))), TTP(List(TP(Sym(3),SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(7),SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(11),SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0))))), TP(Sym(32),SimpleLoop(Const(50),Sym(14),ReduceElem(Block(Sym(31)))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(31))))))) considering TP(Sym(29),ArrayIndex(Sym(3),Sym(14))) -replace TP(Sym(29),ArrayIndex(Sym(3),Sym(14))) at 0 within TTP(List(Sym(3), Sym(7), Sym(11), Sym(32)),List(SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0)))), SimpleLoop(Const(50),Sym(14),ReduceElem(Block(Sym(31))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(31)))))) +replace TP(Sym(29),ArrayIndex(Sym(3),Sym(14))) at 0 within TTP(List(TP(Sym(3),SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(7),SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(11),SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0))))), TP(Sym(32),SimpleLoop(Const(50),Sym(14),ReduceElem(Block(Sym(31)))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(31)))))) considering TP(Sym(30),ArrayIndex(Sym(7),Sym(14))) -replace TP(Sym(30),ArrayIndex(Sym(7),Sym(14))) at 1 within TTP(List(Sym(3), Sym(7), Sym(11), Sym(32)),List(SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0)))), SimpleLoop(Const(50),Sym(14),ReduceElem(Block(Sym(31))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(31)))))) +replace TP(Sym(30),ArrayIndex(Sym(7),Sym(14))) at 1 within TTP(List(TP(Sym(3),SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(7),SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(11),SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0))))), TP(Sym(32),SimpleLoop(Const(50),Sym(14),ReduceElem(Block(Sym(31)))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(31)))))) try once more ... fusion of List((Sym(38),Sym(4)), (Sym(38),Sym(8)), (Sym(38),Sym(12)), (Sym(38),Sym(40)), (Sym(11),Sym(4)), (Sym(11),Sym(8)), (Sym(11),Sym(12)), (Sym(11),Sym(40))) prevented by TP(Sym(39),Plus(Sym(38),Sym(11))) which is required by body of List(Sym(4), Sym(8), Sym(12), Sym(40)) wtableneg: List((Sym(38),Sym(4)), (Sym(38),Sym(8)), (Sym(38),Sym(12)), (Sym(38),Sym(40)), (Sym(11),Sym(4)), (Sym(11),Sym(8)), (Sym(11),Sym(12)), (Sym(11),Sym(40))) -partitions: List(TTP(List(Sym(4), Sym(8), Sym(12), Sym(40)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(39))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(39)))))), TTP(List(Sym(3), Sym(7), Sym(11), Sym(38)),List(SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0)))), SimpleLoop(Const(50),Sym(2),ReduceElem(Block(Sym(37))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(37))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(40),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(39)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(39)))))), TTP(List(TP(Sym(3),SimpleLoop(Const(50),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(7),SimpleLoop(Const(50),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(11),SimpleLoop(Const(50),Sym(10),ReduceElem(Block(Const(4.0))))), TP(Sym(38),SimpleLoop(Const(50),Sym(2),ReduceElem(Block(Sym(37)))))),SimpleFatLoop(Const(50),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(37))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(28)) to List(Sym(42)) /***************************************** diff --git a/test-out/epfl/test7-fusion23.check b/test-out/epfl/test7-fusion23.check index d898ef2b..354a338d 100644 --- a/test-out/epfl/test7-fusion23.check +++ b/test-out/epfl/test7-fusion23.check @@ -1,27 +1,27 @@ wtableneg: List() -partitions: List(TTP(List(Sym(4), Sym(8), Sym(12), Sym(23)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(23),SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22))))))) considering TP(Sym(15),ArrayIndex(Sym(4),Sym(13))) -replace TP(Sym(15),ArrayIndex(Sym(4),Sym(13))) at 0 within TTP(List(Sym(4), Sym(8), Sym(12), Sym(23)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) +replace TP(Sym(15),ArrayIndex(Sym(4),Sym(13))) at 0 within TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(23),SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) considering TP(Sym(16),ArrayIndex(Sym(15),Sym(14))) considering TP(Sym(17),ArrayIndex(Sym(8),Sym(13))) -replace TP(Sym(17),ArrayIndex(Sym(8),Sym(13))) at 1 within TTP(List(Sym(4), Sym(8), Sym(12), Sym(23)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) +replace TP(Sym(17),ArrayIndex(Sym(8),Sym(13))) at 1 within TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(23),SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) considering TP(Sym(18),ArrayIndex(Sym(17),Sym(14))) considering TP(Sym(21),ArrayIndex(Sym(12),Sym(13))) -replace TP(Sym(21),ArrayIndex(Sym(12),Sym(13))) at 2 within TTP(List(Sym(4), Sym(8), Sym(12), Sym(23)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11)))), SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) +replace TP(Sym(21),ArrayIndex(Sym(12),Sym(13))) at 2 within TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(8),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(7))))), TP(Sym(12),SimpleLoop(Const(100),Sym(9),ArrayElem(Block(Sym(11))))), TP(Sym(23),SimpleLoop(Const(100),Sym(13),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(11))), ArrayElem(Block(Sym(22)))))) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(4), Sym(30), Sym(33), Sym(40)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(29)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(32)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(39))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(29))), ArrayElem(Block(Sym(32))), ArrayElem(Block(Sym(39))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(3))))), TP(Sym(30),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(29))))), TP(Sym(33),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(32))))), TP(Sym(40),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(39)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(3))), ArrayElem(Block(Sym(29))), ArrayElem(Block(Sym(32))), ArrayElem(Block(Sym(39))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(28)) to List(Sym(42)) wtableneg: List() -partitions: List(TTP(List(Sym(3), Sym(29), Sym(32), Sym(38)),List(SimpleLoop(Sym(1),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Sym(1),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Sym(1),Sym(10),ReduceElem(Block(Const(4.0)))), SimpleLoop(Sym(1),Sym(14),ReduceElem(Block(Sym(37))))),SimpleFatLoop(Sym(1),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(37))))))) +partitions: List(TTP(List(TP(Sym(3),SimpleLoop(Sym(1),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(29),SimpleLoop(Sym(1),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(32),SimpleLoop(Sym(1),Sym(10),ReduceElem(Block(Const(4.0))))), TP(Sym(38),SimpleLoop(Sym(1),Sym(14),ReduceElem(Block(Sym(37)))))),SimpleFatLoop(Sym(1),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(37))))))) considering TP(Sym(35),ArrayIndex(Sym(3),Sym(14))) -replace TP(Sym(35),ArrayIndex(Sym(3),Sym(14))) at 0 within TTP(List(Sym(3), Sym(29), Sym(32), Sym(38)),List(SimpleLoop(Sym(1),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Sym(1),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Sym(1),Sym(10),ReduceElem(Block(Const(4.0)))), SimpleLoop(Sym(1),Sym(14),ReduceElem(Block(Sym(37))))),SimpleFatLoop(Sym(1),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(37)))))) +replace TP(Sym(35),ArrayIndex(Sym(3),Sym(14))) at 0 within TTP(List(TP(Sym(3),SimpleLoop(Sym(1),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(29),SimpleLoop(Sym(1),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(32),SimpleLoop(Sym(1),Sym(10),ReduceElem(Block(Const(4.0))))), TP(Sym(38),SimpleLoop(Sym(1),Sym(14),ReduceElem(Block(Sym(37)))))),SimpleFatLoop(Sym(1),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(37)))))) considering TP(Sym(36),ArrayIndex(Sym(29),Sym(14))) -replace TP(Sym(36),ArrayIndex(Sym(29),Sym(14))) at 1 within TTP(List(Sym(3), Sym(29), Sym(32), Sym(38)),List(SimpleLoop(Sym(1),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Sym(1),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Sym(1),Sym(10),ReduceElem(Block(Const(4.0)))), SimpleLoop(Sym(1),Sym(14),ReduceElem(Block(Sym(37))))),SimpleFatLoop(Sym(1),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(37)))))) +replace TP(Sym(36),ArrayIndex(Sym(29),Sym(14))) at 1 within TTP(List(TP(Sym(3),SimpleLoop(Sym(1),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(29),SimpleLoop(Sym(1),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(32),SimpleLoop(Sym(1),Sym(10),ReduceElem(Block(Const(4.0))))), TP(Sym(38),SimpleLoop(Sym(1),Sym(14),ReduceElem(Block(Sym(37)))))),SimpleFatLoop(Sym(1),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(37)))))) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(3), Sym(29), Sym(32), Sym(44)),List(SimpleLoop(Sym(1),Sym(2),ArrayElem(Block(Const(1.0)))), SimpleLoop(Sym(1),Sym(6),ArrayElem(Block(Const(2.0)))), SimpleLoop(Sym(1),Sym(10),ReduceElem(Block(Const(4.0)))), SimpleLoop(Sym(1),Sym(2),ReduceElem(Block(Sym(43))))),SimpleFatLoop(Sym(1),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(43))))))) +partitions: List(TTP(List(TP(Sym(3),SimpleLoop(Sym(1),Sym(2),ArrayElem(Block(Const(1.0))))), TP(Sym(29),SimpleLoop(Sym(1),Sym(6),ArrayElem(Block(Const(2.0))))), TP(Sym(32),SimpleLoop(Sym(1),Sym(10),ReduceElem(Block(Const(4.0))))), TP(Sym(44),SimpleLoop(Sym(1),Sym(2),ReduceElem(Block(Sym(43)))))),SimpleFatLoop(Sym(1),Sym(2),List(ArrayElem(Block(Const(1.0))), ArrayElem(Block(Const(2.0))), ReduceElem(Block(Const(4.0))), ReduceElem(Block(Sym(43))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(3), Sym(29), Sym(32), Sym(39)) to List(Sym(3), Sym(29), Sym(32), Sym(45)) /***************************************** diff --git a/test-out/epfl/test7-fusion24.check b/test-out/epfl/test7-fusion24.check index 0134a316..abf2d7d2 100644 --- a/test-out/epfl/test7-fusion24.check +++ b/test-out/epfl/test7-fusion24.check @@ -1,25 +1,25 @@ fusion of List((Sym(2),Sym(9))) prevented by TP(Sym(7),ArrayIndex(Sym(2),Const(0))) which is required by body of List(Sym(9)) fusion of List((Sym(2),Sym(16))) prevented by TP(Sym(7),ArrayIndex(Sym(2),Const(0))) which is required by body of List(Sym(16)) wtableneg: List((Sym(2),Sym(9)), (Sym(2),Sym(16))) -partitions: List(TTP(List(Sym(9), Sym(16)),List(SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(8)))), SimpleLoop(Const(100),Sym(10),ArrayElem(Block(Sym(15))))),SimpleFatLoop(Const(100),Sym(5),List(ArrayElem(Block(Sym(8))), ArrayElem(Block(Sym(15)))))), TTP(List(Sym(4), Sym(2)),List(SimpleLoop(Const(200),Sym(3),ArrayElem(Block(Const(2.0)))), SimpleLoop(Const(200),Sym(1),ArrayElem(Block(Const(1.0))))),SimpleFatLoop(Const(200),Sym(3),List(ArrayElem(Block(Const(2.0))), ArrayElem(Block(Const(1.0))))))) +partitions: List(TTP(List(TP(Sym(9),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(8))))), TP(Sym(16),SimpleLoop(Const(100),Sym(10),ArrayElem(Block(Sym(15)))))),SimpleFatLoop(Const(100),Sym(5),List(ArrayElem(Block(Sym(8))), ArrayElem(Block(Sym(15)))))), TTP(List(TP(Sym(4),SimpleLoop(Const(200),Sym(3),ArrayElem(Block(Const(2.0))))), TP(Sym(2),SimpleLoop(Const(200),Sym(1),ArrayElem(Block(Const(1.0)))))),SimpleFatLoop(Const(200),Sym(3),List(ArrayElem(Block(Const(2.0))), ArrayElem(Block(Const(1.0))))))) considering TP(Sym(7),ArrayIndex(Sym(2),Const(0))) considering TP(Sym(12),ArrayIndex(Sym(9),Sym(10))) -replace TP(Sym(12),ArrayIndex(Sym(9),Sym(10))) at 0 within TTP(List(Sym(9), Sym(16)),List(SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(8)))), SimpleLoop(Const(100),Sym(10),ArrayElem(Block(Sym(15))))),SimpleFatLoop(Const(100),Sym(5),List(ArrayElem(Block(Sym(8))), ArrayElem(Block(Sym(15)))))) +replace TP(Sym(12),ArrayIndex(Sym(9),Sym(10))) at 0 within TTP(List(TP(Sym(9),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(8))))), TP(Sym(16),SimpleLoop(Const(100),Sym(10),ArrayElem(Block(Sym(15)))))),SimpleFatLoop(Const(100),Sym(5),List(ArrayElem(Block(Sym(8))), ArrayElem(Block(Sym(15)))))) considering TP(Sym(13),ArrayIndex(Sym(12),Sym(11))) try once more ... fusion of List((Sym(2),Sym(23))) prevented by TP(Sym(7),ArrayIndex(Sym(2),Const(0))) which is required by body of List(Sym(23)) wtableneg: List((Sym(2),Sym(23))) -partitions: List(TTP(List(Sym(23)),List(SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(22))))),SimpleFatLoop(Const(100),Sym(5),List(ArrayElem(Block(Sym(22)))))), TTP(List(Sym(4), Sym(2)),List(SimpleLoop(Const(200),Sym(3),ArrayElem(Block(Const(2.0)))), SimpleLoop(Const(200),Sym(1),ArrayElem(Block(Const(1.0))))),SimpleFatLoop(Const(200),Sym(3),List(ArrayElem(Block(Const(2.0))), ArrayElem(Block(Const(1.0))))))) +partitions: List(TTP(List(TP(Sym(23),SimpleLoop(Const(100),Sym(5),ArrayElem(Block(Sym(22)))))),SimpleFatLoop(Const(100),Sym(5),List(ArrayElem(Block(Sym(22)))))), TTP(List(TP(Sym(4),SimpleLoop(Const(200),Sym(3),ArrayElem(Block(Const(2.0))))), TP(Sym(2),SimpleLoop(Const(200),Sym(1),ArrayElem(Block(Const(1.0)))))),SimpleFatLoop(Const(200),Sym(3),List(ArrayElem(Block(Const(2.0))), ArrayElem(Block(Const(1.0))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(19)) to List(Sym(25)) wtableneg: List() -partitions: List(TTP(List(Sym(8), Sym(22)),List(SimpleLoop(Sym(5),Sym(6),ArrayElem(Block(Sym(7)))), SimpleLoop(Sym(5),Sym(11),ArrayElem(Block(Sym(21))))),SimpleFatLoop(Sym(5),Sym(6),List(ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(21))))))) +partitions: List(TTP(List(TP(Sym(8),SimpleLoop(Sym(5),Sym(6),ArrayElem(Block(Sym(7))))), TP(Sym(22),SimpleLoop(Sym(5),Sym(11),ArrayElem(Block(Sym(21)))))),SimpleFatLoop(Sym(5),Sym(6),List(ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(21))))))) considering TP(Sym(20),ArrayIndex(Sym(8),Sym(11))) -replace TP(Sym(20),ArrayIndex(Sym(8),Sym(11))) at 0 within TTP(List(Sym(8), Sym(22)),List(SimpleLoop(Sym(5),Sym(6),ArrayElem(Block(Sym(7)))), SimpleLoop(Sym(5),Sym(11),ArrayElem(Block(Sym(21))))),SimpleFatLoop(Sym(5),Sym(6),List(ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(21)))))) +replace TP(Sym(20),ArrayIndex(Sym(8),Sym(11))) at 0 within TTP(List(TP(Sym(8),SimpleLoop(Sym(5),Sym(6),ArrayElem(Block(Sym(7))))), TP(Sym(22),SimpleLoop(Sym(5),Sym(11),ArrayElem(Block(Sym(21)))))),SimpleFatLoop(Sym(5),Sym(6),List(ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(21)))))) *** removing self subtraction Sym(7) - Sym(7) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(26)),List(SimpleLoop(Sym(5),Sym(6),ArrayElem(Block(Const(0.0))))),SimpleFatLoop(Sym(5),Sym(6),List(ArrayElem(Block(Const(0.0))))))) +partitions: List(TTP(List(TP(Sym(26),SimpleLoop(Sym(5),Sym(6),ArrayElem(Block(Const(0.0)))))),SimpleFatLoop(Sym(5),Sym(6),List(ArrayElem(Block(Const(0.0))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(22)) to List(Sym(26)) /***************************************** diff --git a/test-out/epfl/test7-fusion4.check b/test-out/epfl/test7-fusion4.check index d07175f6..16cd9229 100644 --- a/test-out/epfl/test7-fusion4.check +++ b/test-out/epfl/test7-fusion4.check @@ -1,17 +1,17 @@ fusion of List((Sym(2),Sym(10))) prevented by TP(Sym(4),ArrayIndex(Sym(2),Sym(3))) which is required by body of List(Sym(10)) wtableneg: List((Sym(2),Sym(10))) -partitions: List(TTP(List(Sym(10)),List(SimpleLoop(Sym(7),Sym(8),ReduceElem(Block(Sym(9))))),SimpleFatLoop(Sym(7),Sym(8),List(ReduceElem(Block(Sym(9)))))), TTP(List(Sym(2), Sym(6)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(3),ArrayIfElem(Sym(5),Block(Sym(4))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayIfElem(Sym(5),Block(Sym(4))))))) +partitions: List(TTP(List(TP(Sym(10),SimpleLoop(Sym(7),Sym(8),ReduceElem(Block(Sym(9)))))),SimpleFatLoop(Sym(7),Sym(8),List(ReduceElem(Block(Sym(9)))))), TTP(List(TP(Sym(2),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))), TP(Sym(6),SimpleLoop(Const(100),Sym(3),ArrayIfElem(Sym(5),Block(Sym(4)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayIfElem(Sym(5),Block(Sym(4))))))) considering TP(Sym(4),ArrayIndex(Sym(2),Sym(3))) -replace TP(Sym(4),ArrayIndex(Sym(2),Sym(3))) at 0 within TTP(List(Sym(2), Sym(6)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(3),ArrayIfElem(Sym(5),Block(Sym(4))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayIfElem(Sym(5),Block(Sym(4)))))) +replace TP(Sym(4),ArrayIndex(Sym(2),Sym(3))) at 0 within TTP(List(TP(Sym(2),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))), TP(Sym(6),SimpleLoop(Const(100),Sym(3),ArrayIfElem(Sym(5),Block(Sym(4)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayIfElem(Sym(5),Block(Sym(4)))))) considering TP(Sym(9),ArrayIndex(Sym(6),Sym(8))) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(14), Sym(17)),List(SimpleLoop(Const(100),Sym(1),ArrayIfElem(Sym(13),Block(Sym(1)))), SimpleLoop(Sym(15),Sym(8),ReduceElem(Block(Sym(16))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayIfElem(Sym(13),Block(Sym(1))), ReduceElem(Block(Sym(16))))))) +partitions: List(TTP(List(TP(Sym(14),SimpleLoop(Const(100),Sym(1),ArrayIfElem(Sym(13),Block(Sym(1))))), TP(Sym(17),SimpleLoop(Sym(15),Sym(8),ReduceElem(Block(Sym(16)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayIfElem(Sym(13),Block(Sym(1))), ReduceElem(Block(Sym(16))))))) considering TP(Sym(16),ArrayIndex(Sym(14),Sym(8))) -replace TP(Sym(16),ArrayIndex(Sym(14),Sym(8))) at 0 within TTP(List(Sym(14), Sym(17)),List(SimpleLoop(Const(100),Sym(1),ArrayIfElem(Sym(13),Block(Sym(1)))), SimpleLoop(Sym(15),Sym(8),ReduceElem(Block(Sym(16))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayIfElem(Sym(13),Block(Sym(1))), ReduceElem(Block(Sym(16)))))) +replace TP(Sym(16),ArrayIndex(Sym(14),Sym(8))) at 0 within TTP(List(TP(Sym(14),SimpleLoop(Const(100),Sym(1),ArrayIfElem(Sym(13),Block(Sym(1))))), TP(Sym(17),SimpleLoop(Sym(15),Sym(8),ReduceElem(Block(Sym(16)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayIfElem(Sym(13),Block(Sym(1))), ReduceElem(Block(Sym(16)))))) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(23)),List(SimpleLoop(Const(100),Sym(1),ReduceIfElem(Sym(13),Block(Sym(1))))),SimpleFatLoop(Const(100),Sym(1),List(ReduceIfElem(Sym(13),Block(Sym(1))))))) +partitions: List(TTP(List(TP(Sym(23),SimpleLoop(Const(100),Sym(1),ReduceIfElem(Sym(13),Block(Sym(1)))))),SimpleFatLoop(Const(100),Sym(1),List(ReduceIfElem(Sym(13),Block(Sym(1))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(12)) to List(Sym(25)) /***************************************** diff --git a/test-out/epfl/test9-struct2b.check b/test-out/epfl/test9-struct2b.check index de35de84..f9dca683 100644 --- a/test-out/epfl/test9-struct2b.check +++ b/test-out/epfl/test9-struct2b.check @@ -1,8 +1,8 @@ wtableneg: List() -partitions: List(TTP(List(Sym(10), Sym(11), Sym(4), Sym(5)),List(SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(8)))), SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(7)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2))))),SimpleFatLoop(Const(100),Sym(7),List(ArrayElem(Block(Sym(8))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))))))) +partitions: List(TTP(List(TP(Sym(10),SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(8))))), TP(Sym(11),SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(7))))), TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))), TP(Sym(5),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2)))))),SimpleFatLoop(Const(100),Sym(7),List(ArrayElem(Block(Sym(8))), ArrayElem(Block(Sym(7))), ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))))))) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(10), Sym(11)),List(SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(8)))), SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(7))))),SimpleFatLoop(Const(100),Sym(7),List(ArrayElem(Block(Sym(8))), ArrayElem(Block(Sym(7))))))) +partitions: List(TTP(List(TP(Sym(10),SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(8))))), TP(Sym(11),SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(7)))))),SimpleFatLoop(Const(100),Sym(7),List(ArrayElem(Block(Sym(8))), ArrayElem(Block(Sym(7))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(37)) to List(Sym(48)) /***************************************** diff --git a/test-out/epfl/test9-struct3.check b/test-out/epfl/test9-struct3.check index b5eb6f3c..c8dee4e0 100644 --- a/test-out/epfl/test9-struct3.check +++ b/test-out/epfl/test9-struct3.check @@ -1,11 +1,11 @@ wtableneg: List() -partitions: List(TTP(List(Sym(4), Sym(5), Sym(13)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2)))), SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(11))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))), ArrayElem(Block(Sym(11))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))), TP(Sym(5),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2))))), TP(Sym(13),SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(11)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))), ArrayElem(Block(Sym(11))))))) considering TP(Sym(9),ArrayIndex(Sym(5),Sym(7))) -replace TP(Sym(9),ArrayIndex(Sym(5),Sym(7))) at 1 within TTP(List(Sym(4), Sym(5), Sym(13)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2)))), SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(11))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))), ArrayElem(Block(Sym(11)))))) +replace TP(Sym(9),ArrayIndex(Sym(5),Sym(7))) at 1 within TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))), TP(Sym(5),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2))))), TP(Sym(13),SimpleLoop(Const(100),Sym(7),ArrayElem(Block(Sym(11)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))), ArrayElem(Block(Sym(11)))))) warning: mirroring of Sym(11)=Minus(Const(0.0),Sym(9)) type Double returned Sym(1) type Int (not a subtype) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(4), Sym(17)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(1))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))), TP(Sym(17),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(1))))))) no changes, we're done super.focusExactScopeFat with result changed from List(Sym(16)) to List(Sym(20)) /***************************************** diff --git a/test-out/epfl/test9-struct4.check b/test-out/epfl/test9-struct4.check index 48296d3f..9d883184 100644 --- a/test-out/epfl/test9-struct4.check +++ b/test-out/epfl/test9-struct4.check @@ -1,12 +1,12 @@ wtableneg: List() -partitions: List(TTP(List(Sym(4), Sym(5)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))), TP(Sym(5),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))))))) considering TP(Sym(19),ArrayIndex(Sym(5),Sym(17))) try once more ... wtableneg: List() -partitions: List(TTP(List(Sym(4), Sym(5)),List(SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1)))), SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))))))) +partitions: List(TTP(List(TP(Sym(4),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(1))))), TP(Sym(5),SimpleLoop(Const(100),Sym(1),ArrayElem(Block(Sym(2)))))),SimpleFatLoop(Const(100),Sym(1),List(ArrayElem(Block(Sym(1))), ArrayElem(Block(Sym(2))))))) no changes, we're done wtableneg: List() -partitions: List(TTP(List(Sym(23)),List(SimpleLoop(Const(100),Sym(17),ArrayElem(Block(Sym(21))))),SimpleFatLoop(Const(100),Sym(17),List(ArrayElem(Block(Sym(21))))))) +partitions: List(TTP(List(TP(Sym(23),SimpleLoop(Const(100),Sym(17),ArrayElem(Block(Sym(21)))))),SimpleFatLoop(Const(100),Sym(17),List(ArrayElem(Block(Sym(21))))))) no changes, we're done /***************************************** Emitting Generated Code diff --git a/test-src/epfl/test10-transform/TestEffect.scala b/test-src/epfl/test10-transform/TestEffect.scala index 1fa6c0b3..d861d5ff 100644 --- a/test-src/epfl/test10-transform/TestEffect.scala +++ b/test-src/epfl/test10-transform/TestEffect.scala @@ -195,9 +195,8 @@ class TestEffects extends FileDiffSuite { val e2 = e map { case e@TP(s, rhs) if mg.contains(s) => val vs = mg(s) - val llhs = vs map (_.sym) val rrhs = vs map (_.rhs) - TTP(s::llhs, rhs::rrhs, Multi(rhs::rrhs)) + TTP(e::vs, Multi(rhs::rrhs)) case e => e } val e3 = e2 diff m