Skip to content

Commit

Permalink
Partial transition to Scala3.
Browse files Browse the repository at this point in the history
  • Loading branch information
PapyChacal committed Oct 21, 2024
1 parent 8843c37 commit 0d14b80
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 124 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To learn more about StructTensor, please read [our paper published in OOPSLA'23]

## Requirements

To run this framework, you need [Scala](https://www.scala-lang.org/download/all.html) 2 of minimum version 2.13.3 and [sbt](https://www.scala-sbt.org/download/) of minimum version 1.7.0. Note that sbt relies on JDK version 8. To compile the generated code, any C++ compiler, such as GCC or Clang can be used.
To run this framework, you need [Scala](https://www.scala-lang.org/download/all.html) 3 of minimum version 3.3.1 and [sbt](https://www.scala-sbt.org/download/) of minimum version 1.7.0. Note that sbt relies on JDK version 8. To compile the generated code, any C++ compiler, such as GCC or Clang can be used.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
scalaVersion := "2.13.14"
scalaVersion := "3.3.1"

name := "struct-tensor"
organization := "uk.ac.ed.dal"
version := "0.1"

libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.0.0"
libraryDependencies += "com.lihaoyi" %% "fastparse" % "3.0.2"
libraryDependencies += "com.github.scopt" %% "scopt" % "4.1.0"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % Test
Expand Down
7 changes: 4 additions & 3 deletions src/main/scala/uk/ac/ed/dal/structtensor/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import codegen._

import java.io.File
import scopt.OParser
import scopt.OParserBuilder

object Main extends App {
import Optimizer._
Expand Down Expand Up @@ -67,8 +68,8 @@ object Main extends App {
outFilePath: String = ""
)

val builder = OParser.builder[Config]
val parser1 = {
val builder: OParserBuilder[Config] = OParser.builder[Config]
val parser1: OParser[Unit,Config] = {
import builder._
OParser.sequence(
programName("sturct-tensor"),
Expand Down Expand Up @@ -201,7 +202,7 @@ object Main extends App {
val rcRule = Rule(
ccRule.head,
SoPTimesSoP(
SoP(Seq(Prod(Seq(ccRule.head.vars2RedundancyVars)))),
SoP(Seq(Prod(Seq(ccRule.head.vars2RedundancyVars())))),
rmRule.body
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object CodegenUtils {
.map { case (name, i) => s"const int $name = atoi(argv[${i + 1}]);" }
.mkString("\n")

def CPP_printerr(var_name: String, dimensions: Seq[String]) =
def CPP_printerr(var_name: String, dimensions: Seq[String]): String =
s"cerr << $var_name[${dimensions.map(e => s"$e - 1").mkString("][")}] << endl;"

def CPP_return(): String = "return 0;\n}"
Expand Down Expand Up @@ -263,7 +263,7 @@ int main(int argc, char **argv){
.mkString("][")}]);"""
}

def CPP_free(var_name: String, dims: Seq[Dim]) = {
def CPP_free(var_name: String, dims: Seq[Dim]): String = {
val dimensions = dims.map(C_convert_index(_))
val c0 = dimensions.init.zipWithIndex
.map { case (dim, i) => s"for (size_t i$i = 0; i$i < $dim; ++i$i) {" }
Expand Down Expand Up @@ -317,7 +317,7 @@ int main(int argc, char **argv){
case _ => throw new Exception("Unknown code language")
}

def free(lang: String, var_name: String, dims: Seq[Dim]) =
def free(lang: String, var_name: String, dims: Seq[Dim]): String =
lang.toUpperCase() match {
case "C" => C_free(var_name)
case "CPP" => CPP_free(var_name, dims)
Expand Down
Loading

0 comments on commit 0d14b80

Please sign in to comment.