Hello All !
tuple is likely to be broken for the reduce operation, that is for the both tests below:
def ReduceEdges(in: Rep[Int]) = {
val edges = DeliteArray.fromFunction(in) { i => make_tuple2( i + 1.0, make_tuple2(i , i + 1 )) }
val zero = make_tuple2( Double.MaxValue, make_tuple2(Int.MaxValue, Int.MaxValue ) )
val x = edges.reduce( ( left, right ) => { if (left._1 < right._1) {left} else {right} } , zero)
println(x)
}
and for the make_tuple3 variant:
def ReduceEdges(in: Rep[Int]) = {
val edges = DeliteArray.fromFunction(in) { i => make_tuple3( i + 1.0, i , i + 1 ) }
val zero = make_tuple3( Double.MaxValue, Int.MaxValue, Int.MaxValue )
val x = edges.reduce( ( left, right ) => { if (left._1 < right._1) {left} else {right} } , zero)
println(x)
}
for the test being run solely, i.e. not in series I'm getting the following error message:
[info] - testReduceEdges *** FAILED ***
[info] java.lang.RuntimeException: transforming reduce elem but rFunc is not a struct and func is
[info] at scala.sys.package$.error(package.scala:27)
[info] at ppl.delite.framework.transform.MultiloopSoATransformExp$class.soaTransform$2(MultiLoopSoA.scala:220)
[info] at ppl.delite.framework.transform.MultiloopSoATransformExp$class.soaReduce(MultiLoopSoA.scala:228)
[info] at ppl.tests.scalatest.delite.DeliteExternalApp$$anon$1.soaReduce(MVMTestSuite.scala:12)
[info] at ppl.delite.framework.transform.MultiloopSoATransformWithReduceExp$class.transformLoop(MultiLoopSoA.scala:16)
[info] at ppl.tests.scalatest.delite.DeliteExternalApp$$anon$1.transformLoop(MVMTestSuite.scala:12)
[info] at ppl.delite.framework.transform.MultiloopSoATransformExp$$anon$1.transformStm(MultiLoopSoA.scala:28)
[info] at scala.virtualization.lms.common.ForwardTransformer$class.traverseStm(ForwardTransformer.scala:48)
[info] at ppl.delite.framework.transform.MultiloopSoATransformExp$$anon$1.traverseStm(MultiLoopSoA.scala:26)
[info] at scala.virtualization.lms.internal.NestedBlockTraversal$$anonfun$traverseStmsInBlock$1.apply(BlockTraversal.scala:117)
But for the test being run the second in the series, say after
def Rec(in: Rep[Int]) = {
def Complex(re: Rep[Double], im: Rep[Double]) = new Record { val real = re; val imag = im }
val v = DeliteArrayBuffer.fromFunction(in){ i => Complex(i, 0-i) }
val x = v.reduce{ (a,b) => Complex(a.real + b.real, a.imag + b.imag) }(Complex(0,0))
println(x)
}
the series passes ok - very strange but is possible in theory.
[info] MVMTestSuite:
[info] - testRecord
[info] - testReduceEdges
[info] Run completed in 26 seconds, 108 milliseconds.
[info] Total number of tests run: 2
[info] Suites: completed 1, aborted 0
[info] Tests: succeeded 2, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
Could you please help to locate the root cause of this seems to be erratic behavior?
Thanks!
Alexander