Skip to content

Commit

Permalink
Explore jit assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
pityka committed May 23, 2022
1 parent 830564b commit bc8f2de
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
19 changes: 19 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,25 @@ lazy val time = project
)
.dependsOn(coreJVM)

lazy val exploremain = project
.in(file("exploremain"))
.settings(
name := "saddle-explore",
publish / skip := true,
publishArtifact := false,
fork := true,
scalaVersion := scalaVersionInBuild,
Global / cancelable := true,
run / javaOptions ++= Seq(
"-XX:+UnlockDiagnosticVMOptions",
// in addition of these one needs a shared library - hsdis - from the jdk
// https://blogs.oracle.com/javamagazine/post/java-hotspot-hsdis-disassembler
"-XX:CompileCommand=print,org/saddle/macros/BinOpVecVecInPlace$$anon$1.apply",
"-XX:CompileCommand=print,org/saddle/ops/BinOpVecInPlace$VecVecElemOpIp$mcDD$sp.apply$mcDD$sp",
"-XX:-UseCompressedOops")
)
.dependsOn(coreJVM, linalg, inlinedOps)

lazy val stats = project
.in(file("saddle-stats"))
.settings(commonSettings: _*)
Expand Down
12 changes: 12 additions & 0 deletions exploremain/src/main/scala/main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import org.saddle._
import org.saddle.order._
import org.saddle.macros.BinOps._
// import org.saddle.ops.BinOps._

object M extends App {
0 until 100000 foreach { _ =>
val v1 = vec.zeros(100000)
val v2 = vec.ones(100000)
v1 += v2
}
}
17 changes: 4 additions & 13 deletions saddle-linalg/src/main/scala/saddle/linalg/VecLinalgOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,12 @@ class VecPimp(val self: Vec[Double]) {
var s = 0d
val M = self.length

val m = M % 5
while (i < m) {
s += self.raw(i) * other.raw(i)
i += 1
}
val ar1 = self.toArray
val ar2 = other.toArray

while (i < M) {
val v1 = self.raw(i) * other.raw(i)
val v2 = self.raw(i + 1) * other.raw(i + 1)
val v3 = self.raw(i + 2) * other.raw(i + 2)
val v4 = self.raw(i + 3) * other.raw(i + 3)
val v5 = self.raw(i + 4) * other.raw(i + 4)

s += v1 + v2 + v3 + v4 + v5
i += 5
s += ar1(i) * ar2(i)
i += 1
}
s
}
Expand Down

0 comments on commit bc8f2de

Please sign in to comment.