Skip to content

Commit

Permalink
Merge pull request #1137 from armanbilge/topic/bye-bye-fastfor
Browse files Browse the repository at this point in the history
Rename `fastFor` back to `cfor`
  • Loading branch information
armanbilge authored Jan 7, 2022
2 parents f717e9d + 9049572 commit 9f82b3e
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 748 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import scala.util.Random
import Random._

import spire.syntax.cfor._
import spire.syntax.fastFor._

import Arrays.init

Expand Down Expand Up @@ -372,62 +371,4 @@ class CForBenchmarks {
arr2
}

@Benchmark
def doFastForOr: Long = {
var t: Long = 0L
val len = size - 1
fastFor(0)(_ < len, _ + 1) { i => t = t ^ or(arr(i), arr(i + 1)) }

val len2 = size / 2
fastFor(0)(_ < len2, _ + 1) { i => t = t ^ or(arr(i + 3), arr(i + 2)) }

val len3 = size / 3
fastFor(0)(_ < len3, _ + 1) { i => t = t ^ or(arr(i + 1), arr(i + 2)) }

t
}

@Benchmark
def doFastForMin: Long = {
var t: Long = 0L
val len = size - 1
fastFor(0)(_ < len, _ + 1) { i => t = t ^ min(arr(i), arr(i + 1)) }

val len2 = size / 2
fastFor(0)(_ < len2, _ + 1) { i => t = t ^ min(arr(i + 3), arr(i + 2)) }

val len3 = size / 3
fastFor(0)(_ < len3, _ + 1) { i => t = t ^ min(arr(i + 1), arr(i + 2)) }

t
}

@Benchmark
def doFastForGcd: Long = {
var t: Long = 0L
val len = size - 1
fastFor(0)(_ < len, _ + 1) { i => t = t ^ gcd(arr(i), arr(i + 1)) }

val len2 = size / 2
fastFor(0)(_ < len2, _ + 1) { i => t = t ^ gcd(arr(i + 3), arr(i + 2)) }

val len3 = size / 3
fastFor(0)(_ < len3, _ + 1) { i => t = t ^ gcd(arr(i + 1), arr(i + 2)) }

t
}

@Benchmark
def doFastForIntArrayMultiply: Array[Long] = {
val arr2 = arr.clone
val len = size
fastFor(0)(_ < len, _ + 1) { i =>
{
val value = arr2(i)
arr2(i) = value * 2
}
}
arr2
}

}
Loading

0 comments on commit 9f82b3e

Please sign in to comment.