For more options, visit https://groups.google.com/d/optout.
Hi,
You can find an example application using this feature at
https://github.com/stanford-ppl/Forge/blob/master/apps/OptiGraph/src/CommunityDetection.scala
To make this work with any other app you just need to add the two extra lines in the Compiler object. The first overrides ‘main’ as the function that you want the compiler to use as the entry point to your app. The second defines the name for that function that your external scala code will use to call it.
While this will work for any function, in practice you'll want to restrict the input/output types of the function to primitives (Int, Double, etc.) String, and ForgeArray, as these are the types that have direct translations to the corresponding scala types in the generated code.
You then call delitec on your app the same as always. After that call delite and add two extra options: ‘—jar’ and ‘—walk-only’. The first tells the runtime to save the generated code in a jar and the second stops it from trying to run the app immediately.
You should now see a jar named after your app in your working directory. To run the app you need to add this jar and the runtime jar to your classpath.
If you’re using the binary version of optiml you’ll find the jar called runtime in the lib directory. If you’re using optiml from source you can generate it by running
sbt “; project runtime; publish-local”
in the delite repository directory.
You should now be able to call the generated app directly from any scala or java code using the name you defined. We generate the entry point as a scala Function so you can call it and pass it around just like any other function object.
—Kevin
//override def functionName = "kMeansExtRun";
rm -rf ./../delite/generatedCache/ kMeansCompilerExt.deg generated MeansCompilerExt-bin.jar
published/OptiML
bin/delitec kMeansCompilerExt --cuda
bin/delite kMeansCompilerExt --walk-only --jar --cuda 1