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

Scala 3 Draft PR #205

Draft
wants to merge 4 commits into
base: scala-3-prep
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
url = https://github.com/rise-lang/executor.git
[submodule "lib/yacx"]
path = lib/yacx
url = https://github.com/ZerataX/yacx.git
url = https://github.com/rise-lang/yacx.git
[submodule "lib/elevate"]
path = lib/elevate
url = https://github.com/elevate-lang/elevate.git
Expand Down
116 changes: 44 additions & 72 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,82 +1,65 @@
ThisBuild / scalaVersion := "2.13.3"
ThisBuild / organization := "org.rise-lang"

lazy val commonSettings = Seq(
scalacOptions ++= Seq(
"-Wunused:nowarn",
"-Xfatal-warnings",
"-Xlint:-unused",
"-Ymacro-annotations",
"-unchecked",
"-deprecation",
"-feature",
"-language:reflectiveCalls",
),
fork := true
)

lazy val riseAndShine = (project in file("."))
.aggregate(executor, CUexecutor)
.dependsOn(meta, arithExpr, executor, CUexecutor, elevate)
.aggregate(meta, executor, CUexecutor)
.dependsOn(arithExpr, executor, CUexecutor, elevate)
.settings(
name := "riseAndShine",
organization := "org.rise-lang",
version := "1.0",
scalaVersion := "3.0.1",

javaOptions ++= Seq("-Djava.library.path=lib/yacx/build:lib/executor/lib/Executor/build",
"-DexecuteCudaTests=false", "-Xss26m"),

commonSettings,
scalacOptions ++= Seq(
// "-Xfatal-warnings",
// "-rewrite",
"-source:3.0-migration",
// "-indent",
// "-new-syntax",
"-deprecation",
"-feature",
"-unchecked",
"-language:reflectiveCalls",
),

fork := true,

libraryDependencies ++= Seq(
// scala
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.scala-lang" % "scala-library" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % "1.3.0",
"org.scala-lang.modules" %% "scala-parallel-collections" % "0.2.0",
// testing
"junit" % "junit" % "4.11",
"org.scalatest" %% "scalatest" % "3.1.0" % "test",
"org.apache.logging.log4j" % "log4j-core" % "2.14.1",
"org.apache.logging.log4j" %% "log4j-api-scala" % "12.0",
// json
"com.typesafe.play" %% "play-json" % "2.9.1",
// subprocess communication
"com.lihaoyi" %% "os-lib" % "0.7.3"
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.3",
// testing
"junit" % "junit" % "4.11",
"org.scalatest" %% "scalatest" % "3.2.9" % "test",
"org.apache.logging.log4j" % "log4j-core" % "2.14.1",
"org.wvlet.airframe" %% "airframe-log" % "21.5.4",
// os
("com.lihaoyi" %% "os-lib" % "0.7.8").cross(CrossVersion.for3Use2_13),
// json
("com.typesafe.play" %% "play-json" % "2.9.2").cross(CrossVersion.for3Use2_13),
// xml
"org.scala-lang.modules" %% "scala-xml" % "2.0.1"
),

compile := ((compile in Compile) dependsOn (generateRISEPrimitives, clap)).value,
test := ((test in Test) dependsOn (generateRISEPrimitives, clap)).value
compile := ((Compile / compile) dependsOn generateRISEPrimitives).value,
test := ((Test / test) dependsOn generateRISEPrimitives).value
)

lazy val generateRISEPrimitives = taskKey[Unit]("Generate RISE Primitives")

generateRISEPrimitives := {
runner.value.run("meta.generator.RisePrimitives",
(dependencyClasspath in Compile).value.files,
Seq((scalaSource in Compile).value.getAbsolutePath),
streams.value.log).failed foreach (sys error _.getMessage)
}
generateRISEPrimitives := (Def.taskDyn {
(meta / Compile / runMain).toTask(
" meta.generator.RisePrimitives " + (Compile / scalaSource).value.getAbsolutePath
)
}).value

lazy val generateDPIAPrimitives = taskKey[Unit]("Generate DPIA Primitives")

generateDPIAPrimitives := {
runner.value.run("meta.generator.DPIAPrimitives",
(dependencyClasspath in Compile).value.files,
Seq((scalaSource in Compile).value.getAbsolutePath),
streams.value.log).failed foreach (sys error _.getMessage)
}

lazy val meta = (project in file("meta"))
.settings(
name := "meta",
version := "1.0",
commonSettings,
libraryDependencies += "com.lihaoyi" %% "fastparse" % "2.2.2",
libraryDependencies += "com.lihaoyi" %% "scalaparse" % "2.2.2",
libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.7.3",
libraryDependencies += "org.scalameta" %% "scalameta" % "4.4.10",
generateDPIAPrimitives := (Def.taskDyn {
(meta / Compile / runMain).toTask(
" meta.generator.DPIAPrimitives " + (Compile / scalaSource).value.getAbsolutePath
)
}).value

lazy val meta = (project in file("meta"))

lazy val arithExpr = project in file("lib/arithexpr")

Expand All @@ -86,22 +69,11 @@ lazy val CUexecutor = project in file("lib/yacx")

lazy val elevate = project in file("lib/elevate")

lazy val docs = (project in file("riseAndShine-docs"))
lazy val docs = (project in file("riseAndShine-docs"))
.settings(
moduleName := "riseAndShine-docs",
mdocOut := file("docs-website/docs"),
scalaVersion := "3.0.0",
)
.enablePlugins(MdocPlugin)
.dependsOn(riseAndShine)

lazy val clap = taskKey[Unit]("Builds Clap library")

clap := {
import scala.language.postfixOps
import scala.sys.process._
//noinspection PostfixMethodCall
"echo y" #| (baseDirectory.value + "/lib/clap/buildClap.sh") !
}



2 changes: 1 addition & 1 deletion lib/elevate
Submodule elevate updated 44 files
+1 −0 .gitignore
+14 −38 build.sbt
+0 −288 macros/src/main/scala/elevate/macros/CombinatorMacro.scala
+0 −248 macros/src/main/scala/elevate/macros/RuleMacro.scala
+0 −15 macros/src/main/scala/elevate/macros/StrategyMacro.scala
+1 −0 project/build.properties
+0 −1 project/plugins.sbt
+51 −72 src/main/scala/FSmooth/DSL.scala
+23 −31 src/main/scala/FSmooth/Differentiation.scala
+44 −66 src/main/scala/FSmooth/Expr.scala
+11 −5 src/main/scala/FSmooth/MSmooth.scala
+5 −9 src/main/scala/FSmooth/PairFunctionConstants.scala
+21 −39 src/main/scala/FSmooth/ScalarFunctionConstants.scala
+33 −33 src/main/scala/FSmooth/Type.scala
+39 −63 src/main/scala/FSmooth/TypeInference.scala
+2 −4 src/main/scala/FSmooth/ValueConstants.scala
+6 −11 src/main/scala/FSmooth/VectorFunctionConstants.scala
+11 −13 src/main/scala/FSmooth/lifting.scala
+10 −13 src/main/scala/FSmooth/replace.scala
+11 −18 src/main/scala/FSmooth/traversal.scala
+28 −31 src/main/scala/elevate/core/RewriteResult.scala
+11 −0 src/main/scala/elevate/core/Strategy.scala
+86 −0 src/main/scala/elevate/core/macros/Macros.scala
+0 −18 src/main/scala/elevate/core/package.scala
+3 −2 src/main/scala/elevate/core/strategies/Traversable.scala
+21 −31 src/main/scala/elevate/core/strategies/basic.scala
+13 −14 src/main/scala/elevate/core/strategies/debug.scala
+22 −26 src/main/scala/elevate/core/strategies/predicate.scala
+27 −42 src/main/scala/elevate/core/strategies/traversal.scala
+1 −2 src/main/scala/elevate/fsmooth/package.scala
+171 −169 src/main/scala/elevate/fsmooth/rules.scala
+21 −24 src/main/scala/elevate/fsmooth/traversal.scala
+2 −7 src/main/scala/elevate/heuristic_search/Heuristic.scala
+2 −7 src/main/scala/elevate/heuristic_search/HeuristicPanel.scala
+16 −22 src/main/scala/elevate/heuristic_search/HeuristicPanelImplementation.scala
+18 −29 src/main/scala/elevate/heuristic_search/Metaheuristic.scala
+1 −2 src/main/scala/elevate/heuristic_search/Runner.scala
+12 −19 src/main/scala/elevate/heuristic_search/heuristics/IterativeImprovement.scala
+17 −23 src/main/scala/elevate/heuristic_search/heuristics/Random.scala
+5 −7 src/main/scala/elevate/heuristic_search/util/IOHelper.scala
+49 −50 src/main/scala/elevate/heuristic_search/util/Path.scala
+4 −2 src/test/scala/FSmooth/typeInference.scala
+9 −7 src/test/scala/elevate/fsmooth/rewriteExamples.scala
+1 −2 src/test/scala/elevate/test_util/package.scala
2 changes: 1 addition & 1 deletion lib/yacx
Submodule yacx updated 1 files
+11 −13 build.sbt
21 changes: 21 additions & 0 deletions meta/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
lazy val meta = (project in file("."))
.settings(
name := "meta",
version := "1.0",
scalaVersion := "2.13.6",
scalacOptions ++= Seq(
"-Wunused:nowarn",
"-Xfatal-warnings",
"-Xlint:-unused",
"-Ymacro-annotations",
"-unchecked",
"-deprecation",
"-feature",
"-language:reflectiveCalls",
),
fork := true,
libraryDependencies += "com.lihaoyi" %% "fastparse" % "2.2.2",
libraryDependencies += "com.lihaoyi" %% "scalaparse" % "2.2.2",
libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.7.8",
libraryDependencies += "org.scalameta" %% "scalameta" % "4.4.10",
)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.7
sbt.version=1.5.5
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
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("ch.epfl.scala" % "sbt-bloop" % "1.4.8")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21")
18 changes: 9 additions & 9 deletions src/main/scala/apps/cameraPipelineRewrite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object cameraPipelineRewrite {
}

def takeDropTowardsInput: Strategy[Rise] = {
normalize.apply(
normalize(
gentleBetaReduction() <+ etaReduction() <+
takeAll <+ dropNothing <+
mapFusion <+ mapIdentity <+
Expand Down Expand Up @@ -161,7 +161,7 @@ object cameraPipelineRewrite {
case _ => Failure(idxAfterF)
}

def normalizeSingleInput: Strategy[Rise] = normalize.apply(
def normalizeSingleInput: Strategy[Rise] = normalize(
dropBeforeTake <+ dropBeforeMap <+ takeBeforeMap <+
slideBeforeMap <+ mapFusion // <+ TODO
// (not(isAppliedMap) `;` idxAfterF `;` debugS("idx"))
Expand Down Expand Up @@ -293,21 +293,21 @@ object cameraPipelineRewrite {
argument(argument(normalizeInput) `;` repeat(mapFusion))
}

def stronglyReducedForm: Strategy[Rise] = normalize.apply(
def stronglyReducedForm: Strategy[Rise] = normalize(
betaReduction <+ etaReduction() <+
removeTransposePair <+ mapFusion <+
idxReduction <+ fstReduction <+ sndReduction
)

def gentlyReducedForm: Strategy[Rise] = normalize.apply(
def gentlyReducedForm: Strategy[Rise] = normalize(
gentleBetaReduction() <+ etaReduction() <+
removeTransposePair <+ mapFusion <+
idxReduction <+ fstReduction <+ sndReduction
)

def demosaicCircularBuffers: Strategy[Rise] = {
rewriteSteps(scala.collection.Seq(
normalize.apply(gentleBetaReduction()),
normalize(gentleBetaReduction()),

takeDropTowardsInput,

Expand Down Expand Up @@ -373,7 +373,7 @@ object cameraPipelineRewrite {

def precomputeSharpenStrengthX32: Strategy[Rise] = {
// |> toMem() |> letf(fun(strength_x32 =>
normalize.apply(gentleBetaReduction()) `;`
normalize(gentleBetaReduction()) `;`
afterTopLevel(
function(argument( // sharpen
???
Expand All @@ -399,22 +399,22 @@ object cameraPipelineRewrite {
}

def precomputeColorCorrectionMatrix: Strategy[Rise] = {
normalize.apply(gentleBetaReduction()) `;`
normalize(gentleBetaReduction()) `;`
afterTopLevel(
argument(argument({
case expr @ App(Lambda(x, color_correct), matrix) =>
Success(letf(lambda(toBeTyped(x), color_correct))(
p.mapSeq(p.mapSeq(fun(x => x)))(matrix)) !: expr.t)
case _ => Failure(precomputeColorCorrectionMatrix)
})) `;`
normalize.apply(gentleBetaReduction() <+ letHoist)
normalize(gentleBetaReduction() <+ letHoist)
)
}

def precomputeCurve: Strategy[Rise] = {
// TODO: apply_curve curve:
// |> mapSeq(fun(x => x)) |> letf(fun(curve =>
normalize.apply(gentleBetaReduction()) `;`
normalize(gentleBetaReduction()) `;`
afterTopLevel(
argument(function(argument(
topDown(
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/apps/convolution.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import rise.openCL.DSL._
import rise.openCL.primitives.oclReduceSeqUnroll
import util.{Time, TimeSpan}
import shine.OpenCL.KernelExecutor._
import reflect.Selectable.reflectiveSelectable

object convolution {
private val id = fun(x => x)
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/apps/gemv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import rise.core.primitives.{let => _, _}
import rise.core.types._
import rise.core.types.DataType._
import HighLevelConstructs.reorderWithStride
import reflect.Selectable.reflectiveSelectable

object gemv {
// we can use implicit type parameters and type annotations to specify the function type of mult
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/apps/harrisCornerDetection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import rise.openCL.DSL._
import rise.openCL.primitives.oclRotateValues
import util.gen
import shine.OpenCL.KernelExecutor._
import reflect.Selectable.reflectiveSelectable

import scala.reflect.ClassTag

Expand Down
Loading