Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Quafadas committed Sep 25, 2024
1 parent 547400c commit 65646ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ benchmark:
mill benchmark.runJmh -jvmArgs --add-modules=jdk.incubator.vector -rf json

benchmarkOnly:
mill benchmark.runJmh -jvmArgs --add-modules=jdk.incubator.vector -rf json vecxt.benchmark.AddScalarBenchmark
mill benchmark.runJmh -jvmArgs --add-modules=jdk.incubator.vector -rf json vecxt.benchmark.AddScalarBenchmark

setJvm:
eval "$(cs java --jvm 21 --env)"
11 changes: 6 additions & 5 deletions vecxt/jvm/src/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package vecxt
import dev.ludovic.netlib.blas.JavaBLAS.getInstance as blas
import scala.util.chaining.*
import vecxt.Matrix.*
import jdk.incubator.vector.ByteVector
import jdk.incubator.vector.DoubleVector
import jdk.incubator.vector.VectorSpecies
import jdk.incubator.vector.VectorOperators
Expand Down Expand Up @@ -56,15 +57,15 @@ object extensions:

end extension
extension (vec: Array[Boolean])
inline def countTrue: Int =
val species = VectorSpecies.ofBoolean(VectorSpecies.PREFERRED)
val length = species.length()
inline def countTrue: Int =
val species = ByteVector.SPECIES_PREFERRED
val l = species.length()
var sum = 0
var i = 0

while i < species.loopBound(vec.length) do
sum += DoubleVector.fromArray(species, vec, i).compare(VectorOperators.EQ, true).trueCount
i += length
sum = sum + ByteVector.fromBooleanArray(species, vec, i).reduceLanes(VectorOperators.ADD)
i += l
end while

while i < vec.length do
Expand Down

0 comments on commit 65646ff

Please sign in to comment.