ochafik/nativelibs4java — Issue #219: scalacl fails on Math.sin
Author: julianrz
Created: 2011-12-27 05:33:22+00:00
State: open

scalacl does not like full class names like Math.sin. (works when Math._ is imported). Error message is misleading...
scalac version is 2.9.1.final. scalac version is 0.2.final

import scalacl._
import scala.math._

object TestSin {
def main(args: Array[String]): Unit = {
implicit val context = Context.best // prefer CPUs ? use Context.best(CPU)
val rng = (1 until args.first.toInt).map(x=>x.toDouble).cl // transform the Range into a CLIntRange

val sumsin = rng.map(x=>Math.sin(x)).foldLeft(0.0)((a,b)=>a+b*b)
println("sum sin2(x)="+sumsin)

}
}

./scalac TestSin.scala

java.lang.RuntimeException: [ScalaCL] Unhandled method name in Scala -> OpenCL conversion : sin
left = scala.Math,
args = List(x)
at scalacl.plugin.OpenCLConverter$class.convert(OpenCLConverter.scala:201)
at scalacl.plugin.ScalaCLFunctionsTransformComponent.convert(ScalaCLFunctionsTransformComponent.scala:52)
at scalacl.plugin.ScalaCLFunctionsTransformComponent$$anon$1.convertCode$1(ScalaCLFunctionsTransformComponent.scala:196)
at scalacl.plugin.ScalaCLFunctionsTransformComponent$$anon$1$$anonfun$4.apply(ScalaCLFunctionsTransformComponent.scala:201)
at scalacl.plugin.ScalaCLFunctionsTransformComponent$$anon$1$$anonfun$4.apply(ScalaCLFunctionsTransformComponent.scala:201)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:194)
warning: [scalacl] TestSin.scala:10 An unexpected error occurred while attempting an optimization
[scalacl] TestSin.scala:10 Attempted optimization : 'associated equivalent OpenCL source to scalacl.CLArray[Double].map's function argument.'
[scalacl] TestSin.scala:10 You can skip this line with the following environment variable :
[scalacl] TestSin.scala:10 SCALACL_SKIP=TestSin.scala:10
[scalacl] TestSin.scala:10	Error : java.lang.RuntimeException: [ScalaCL] Unhandled method name in Scala -> OpenCL conversion : sin
[scalacl] TestSin.scala:10	left = scala.Math,
[scalacl] TestSin.scala:10	args = List(x)
[scalacl] TestSin.scala:10 An unexpected error occurred while attempting an optimization
[scalacl] TestSin.scala:10 Attempted optimization : 'associated equivalent OpenCL source to scalacl.CLArray[Double].map's function argument.'
[scalacl] TestSin.scala:10 You can skip this line with the following environment variable :
[scalacl] TestSin.scala:10 SCALACL_SKIP=TestSin.scala:10
[scalacl] TestSin.scala:10	Error : java.lang.RuntimeException: [ScalaCL] Unhandled method name in Scala -> OpenCL conversion : sin
[scalacl] TestSin.scala:10	left = scala.Math,
[scalacl] TestSin.scala:10	args = List(x)