Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal horizontal fusion #45

Open
asujeeth opened this issue Dec 8, 2014 · 1 comment
Open

Illegal horizontal fusion #45

asujeeth opened this issue Dec 8, 2014 · 1 comment
Labels

Comments

@asujeeth
Copy link
Contributor

asujeeth commented Dec 8, 2014

After making mapRows pure in OptiML, we encountered an illegal instance of horizontal fusion in the DenseMatrixSuite's testMapAll(). The code to trigger the fusion error is:

def main() = {
    val x = DenseMatrix.zeros(10,10)
    val b = x mapRows { i => DenseVector.ones(10) }
    println(b == DenseMatrix.ones(10,10))
  }

The result of this is a java.lang.RuntimeException: Couldn't find following op: x509, and the generated kernel is:

object kernel_x509x824 {
def apply(resourceInfo:generated.scala.ResourceInfo,x509:Array[Double]):
generated.scala.DeliteOpMultiLoop[activation_x509x824] { ... }

The horizontally fused kernel x509x824 also expects x509 as an input. It seems to be caused by the fact that the outer loop and inner loop have the same constant size (10) in the example, and the inner loop has no dependency on the outer loop's bound symbol (i).

To reproduce, use the following hashes:
Forge: stanford-ppl/Forge@939141a
Delite: e686064
LMS: TiarkRompf/virtualization-lms-core@afeb9ef

and run the code snippet pasted above in OptiML.

@asujeeth asujeeth added the bug label Dec 8, 2014
@vsalvis
Copy link

vsalvis commented Dec 9, 2014

It seems that x509 is DenseVector.ones(10), which is moved out of the loop since it doesn't depend on i. x824 is b. Note that x isn't even generated, because its elements aren't used and its rowlength is constant. So the structure seen by fusion should be something along the lines of:

def main() = {
  val x509 = DenseVector.ones(10)
  val x824 = SimpleLoop (i <- 0 until 10) {
    collect(x509)
  }
  println(x824 == DenseMatrix.ones(10,10))
}

The bug is that in this case, x509 and x824 are fused horizontally, despite the dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants