summaryrefslogtreecommitdiff
path: root/src/main/scala/com/nsrddyn/ALU
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/com/nsrddyn/ALU')
-rw-r--r--src/main/scala/com/nsrddyn/ALU/Hash.scala31
-rw-r--r--src/main/scala/com/nsrddyn/ALU/Prime.scala64
2 files changed, 0 insertions, 95 deletions
diff --git a/src/main/scala/com/nsrddyn/ALU/Hash.scala b/src/main/scala/com/nsrddyn/ALU/Hash.scala
deleted file mode 100644
index 9dc5a98..0000000
--- a/src/main/scala/com/nsrddyn/ALU/Hash.scala
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.nsrddyn.alu
-
-import scala.util.hashing
-
-class Hash {
-
-import scala.util.hashing.MurmurHash3
-
- def run(word: String, loopSize: Int): Unit = {
-
- /* TODO: implement ALU friendly, so high speed hashing
- * to continuously loop over voor stressing
- * ALU
- *
- * While looking for hashing algorithmes to implement I stumbled on:
- * https://scala-lang.org/api/3.x/scala/util/hashing/MurmurHash3$.html
- *
- * which is an implemntation of **smasher** http://github.com/aappleby/smhasher
- * the exact type of hashing algorithm I was looking for
- *
- * In the scala description they state: "This algorithm is designed to generate
- * well-distributed non-cryptographic hashes. It is designed to hash data in 32 bit chunks (ints). "
- *
- * (ints) -> ALU
- *
- */
-
- for i <- 0 to loopSize do MurmurHash3.stringHash(word)
-
- }
-}
diff --git a/src/main/scala/com/nsrddyn/ALU/Prime.scala b/src/main/scala/com/nsrddyn/ALU/Prime.scala
deleted file mode 100644
index a6c7d15..0000000
--- a/src/main/scala/com/nsrddyn/ALU/Prime.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.nsrddyn.alu
-import com.nsrddyn.alu.Prime
-import com.nsrddyn.tools.Benchmark
-import com.nsrddyn.test
-
-class Prime() extends {
-
- /*
- * Calculate all primes up to limit
- * This should stress the ALU in someway,
- * doing this in a predictable manner,
- * will hopefully keep the cpu pipeline busy
- * and that way stress the branch predictor
- *
- * math.sqrt(n) => a prime number has 2 factors, one of the factors
- * of the prime numbers has to be smaller then n
- * after that we check if the number is whole number and thereby checking if its a prime
- *
- */
-
-
- /*
- * TODO: I did the countrary of what i wanted to accieve with the is prime function
- * We want the function to be less optimized so that the CPU has more work == more stress
- */
-
-
- def isPrime(n: Int): Boolean = {
- if n <= 1 then false
- else !(2 to math.sqrt(n).toInt).exists(i => n % i == 0)
-
-
- }
-
- def run(n: Int, result: Boolean): Unit = {
-
- for i <- 0 to n do if isPrime(i) == result then println("true") else println("false")
- }
-
-
-}
-
-
-
-
-class PrimeRunner extends Workload {
-
- def run(threads: Int): Unit = {
-
- val pr = new Prime()
- val br = new Benchmark()
-
- /*
- * test cases
- *
- * 7919 true
- * 2147483647 false
- */
-
- val time = pr.run(7919, true)
- println(time)
-
- }
-}