-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc3423d
commit 4211a82
Showing
9 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ modules.xml | |
*.gz | ||
*.sc | ||
|
||
float-safe-optimizer.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package float_safe_optimizer | ||
|
||
import util.gen | ||
import rise.core.Expr | ||
import rise.core.DSL.ToBeTyped | ||
|
||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
val name = args(0) | ||
val exprSourcePath = args(1) | ||
val outputPath = args(2) | ||
|
||
val exprSource = util.readFile(exprSourcePath) | ||
val untypedExpr = parseExpr(prefixImports(exprSource)) | ||
val typedExpr = untypedExpr.toExpr | ||
val code = gen.openmp.function.asStringFromExpr(typedExpr) | ||
util.writeToPath(outputPath, code) | ||
} | ||
|
||
def prefixImports(source: String): String = | ||
s""" | ||
|import rise.core.DSL._ | ||
|import rise.core.DSL.Type._ | ||
|import rise.core.DSL.HighLevelConstructs._ | ||
|import rise.core.primitives._ | ||
|import rise.core.types._ | ||
|import rise.core.types.DataType._ | ||
|import rise.openmp.DSL._ | ||
|import rise.openmp.primitives._ | ||
|$source | ||
|""".stripMargin | ||
|
||
def parseExpr(source: String): ToBeTyped[Expr] = { | ||
import scala.reflect.runtime.universe | ||
import scala.tools.reflect.ToolBox | ||
|
||
val toolbox = universe.runtimeMirror(getClass.getClassLoader).mkToolBox() | ||
toolbox.eval(toolbox.parse(source)).asInstanceOf[ToBeTyped[Expr]] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
depFun((n: Nat) => fun((n`.`i32) ->: (n`.`i32))(in => | ||
map(add(li32(3)))(in) | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
depFun((n: Nat) => fun((n`.`i32) ->: (n`.`i32))(in => | ||
mapSeq(add(li32(3)))(in) | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
depFun((n: Nat) => fun((n`.`i32) ->: (n`.`f32))(in => | ||
map(add(li32(3)))(in) | ||
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.4.0-RC1") | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.0") | ||
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.17") | ||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") | ||
addDependencyTreePlugin |