summaryrefslogtreecommitdiff
path: root/src/main/scala/com/nsrddyn/cpu/ALU/Prime.scala
blob: 2ad3ba6e06bf98972fff0e475c598425039444c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.nsrddyn



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
  }


}