summaryrefslogtreecommitdiff
path: root/src/main/scala/com/nsrddyn/cpu/ALU
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/com/nsrddyn/cpu/ALU')
-rw-r--r--src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala b/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala
index 7a80df4..2ad3ba6 100644
--- a/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala
+++ b/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala
@@ -1,5 +1,46 @@
package com.nsrddyn
-class Prime {
-
+
+
+class Prime(threads: Int) {
+
+ /*
+ * 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
+ *
+ * */
+
+
+ // TODO: bad implementation of scala, scala prefers functional programming which something I am not doing here
+
+ def run(n: Long): Unit = {
+
+
+ var iterator = 0
+
+ // TODO: run the isPrime checks
+
+ }
+
+ def isPrime(n: Int): Boolean = {
+
+ for
+ i <- 2 to 5
+ if isWholeNumber(n % i) == true then
+ true
+
+ false
+
+ // TODO: calculate if the number is a prime number
+ // TODO: fix errors
+ }
+
+ def isWholeNumber(n: Int | Float): Boolean = {
+ // TODO: calculate if the number is a whole number
+ }
+
+
}