Semester Project - CPU Temps

Thomas J. Kennedy

Contents:

1 Overview - Milestones

The Semester Project has intermediary milestones (in addition to the final submission):

 
  1. Semester Project - Input Library and Language Selection

  2. Semester Project - Piecewise Linear Interpolation

  3. Semester Project - Least Squares Approximation

  4. Semester Project (Finished)

2 Overview - Problem Background

As a Computer Scientist, I have a number of interests. Many of these interests overlap. While designing this project, I happened to be batch encoding some videos. I decided to write a quick script to grab CPU temperature data every 30 seconds.

Each of the encoding jobs ran for 5 to 10 hours. If you look at the data you see four temperatures for each reading. My CPU is a 4-core (8 thread) Intel i7-6700K. I found myself interested in not only the behavior of the readings, but also in the temperature differences between the 4 CPU cores.

I initially gathered three (3) sets of data.

I generated three (3) graphs (using Gnuplot):

Click on each item to view either the graph.

3 Input Format

Data takes the form of temperatures in a txt file. All data points are whitespace delimited. For example, suppose we have 5 temperature readings.

Example 1: Sample Input with Labels
+61.0°C +63.0°C +50.0°C +58.0°C
+80.0°C +81.0°C +68.0°C +77.0°C
+62.0°C +63.0°C +52.0°C +60.0°C
+83.0°C +82.0°C +70.0°C +79.0°C
+68.0°C +69.0°C +58.0°C +65.0°C
Example 2: Sample Input without Labels
61.0 63.0 50.0 58.0
80.0 81.0 68.0 77.0
62.0 63.0 52.0 60.0
83.0 82.0 70.0 79.0
68.0 69.0 58.0 65.0

Both examples would be a possible input files. Each line represents temperature readings from 4 processor cores. Readings are taken every 30 seconds. In this example:

In practice… we need to look at each of the four cores independently. This means that each input file is really four (4) sets of temperature data

Example 3: Temperature Readings by CPU Core
Time Core 0 Temperature
0 61.0
30 80.0
60 62.0
90 83.0
120 68.0
Time Core 1 Temperature
0 63.0
30 81.0
60 63.0
90 82.0
120 69.0
Time Core 2 Temperature
0 50.0
30 68.0
60 52.0
90 70.0
120 58.0
Time Core 3 Temperature
0 58.0
30 77.0
60 60.0
90 79.0
120 65.0

3.1 Additional Input Data

The Overview listed three input files, as an introduction. If you would like more test data…

3.2 Output Format

All output must be written to text files (one file per core). Each line must take the form:

\(x_{k} <= x < x_{k+1}\); \(y_i=c_0 + c_{1} x\) ; type

where

 

For the example data in described in Section 2.1 (Input Format) you would generate 4 output files.

where {basename} is the input file name without the extension (e.g., without the .txt or .dat).

4 Sample Execution & Output

4.1 Sample Output

Given the five-line sample input…

sample-input.txt
61.0 63.0 50.0 58.0
80.0 81.0 68.0 77.0
62.0 63.0 52.0 60.0
83.0 82.0 70.0 79.0
68.0 69.0 58.0 65.0

we would end up with four output files…

sample-input-core-00.txt
       0 <= x <=       30 ; y =      61.0000 +       0.6333 x ; interpolation
      30 <= x <=       60 ; y =      98.0000 +      -0.6000 x ; interpolation
      60 <= x <=       90 ; y =      20.0000 +       0.7000 x ; interpolation
      90 <= x <=      120 ; y =     128.0000 +      -0.5000 x ; interpolation
       0 <= x <=      120 ; y =      67.4000 +       0.0567 x ; least-squares
sample-input-core-01.txt
       0 <= x <=       30 ; y =      63.0000 +       0.6000 x ; interpolation
      30 <= x <=       60 ; y =      99.0000 +      -0.6000 x ; interpolation
      60 <= x <=       90 ; y =      25.0000 +       0.6333 x ; interpolation
      90 <= x <=      120 ; y =     121.0000 +      -0.4333 x ; interpolation
       0 <= x <=      120 ; y =      69.0000 +       0.0433 x ; least-squares
sample-input-core-02.txt
       0 <= x <=       30 ; y =      50.0000 +       0.6000 x ; interpolation
      30 <= x <=       60 ; y =      84.0000 +      -0.5333 x ; interpolation
      60 <= x <=       90 ; y =      16.0000 +       0.6000 x ; interpolation
      90 <= x <=      120 ; y =     106.0000 +      -0.4000 x ; interpolation
       0 <= x <=      120 ; y =      56.0000 +       0.0600 x ; least-squares
sample-input-core-03.txt
       0 <= x <=       30 ; y =      58.0000 +       0.6333 x ; interpolation
      30 <= x <=       60 ; y =      94.0000 +      -0.5667 x ; interpolation
      60 <= x <=       90 ; y =      22.0000 +       0.6333 x ; interpolation
      90 <= x <=      120 ; y =     121.0000 +      -0.4667 x ; interpolation
       0 <= x <=      120 ; y =      64.6000 +       0.0533 x ; least-squares

Note that the extra padding zeros for the core numbers are optional.

5 Programming Requirements & Constraints

All code must follow the requirements outlined in the Submission (Programming Exercises) section of the syllabus.

Your task is to take the temperature readings and generate for each core:

  1. A piecewise linear interpolation.
  2. A global linear least squares approximation.
  3. (Optional) A cubic spline (or other non-linear) interpolation.

5.1 Arguments & Execution

Your program must accept an input filename as the first command line argument. Your program must NOT prompt the user for a filename.

5.2 Architecture

Your solution must be organized into appropriate “modules” (using each language’s best practices). Start with four modules:

  1. Input (e.g., using the supplied input libraries)
  2. Data pre-processing (i.e., structuring the data for analysis)
  3. Piecewise Linear Interpolation
  4. Least Squares Approximation

5.3 Documentation Requirements

All code must be properly and fully documented using a language appropriate comment style. All functions (including parameters and return types) must be documented.

  1. Doxygen can be used for C++, Java, or JavaScript. Consider the following Doxygen Example:

    Example 4: C++ Doxygen Documentation
    /**
     * Retrieve the value stored in three selected Cells
     *
     * @param cell1Id numeric id representing the 1st desired cell
     * @param cell2Id numeric id representing the 2nd desired cell
     * @param cell3Id numeric id representing the 3rd desired cell
     *
     * @return value stored in the Cell
     *
     * @pre (cell1Id > 0 && cell1Id < 10) &&
     *      (cell2Id > 0 && cell2Id < 10) &&
     *      (cell3Id > 0 && cell3Id < 10)
     */
    CellTriple get3Cells(int cell1Id, int cell2Id, int cell3Id) const;
    
  2. Javadoc can be used for Java. Consider the following Javadoc Example:

    Example 5: Javadoc Documentation
    /**
     * Multi-thread Coin Flip.
     *
     * @param numTrials # flips to simulate
     * @param numThreads number of threads to use
     *
     * @return Completed FlipTasks
     *
     * @throws InterruptedException if a thread is stopped prematurely
     */
    public static FlipTask[] multiThread(long numTrials, int numThreads)
        throws InterruptedException
    
  3. Pydoc or Sphinx can be used for Python. Consider the following Pydoc Example:

    Example 6: Python 3 Pydoc Documentation
    def parse_raw_temps(original_temps: TextIO,
                        step_size: int=30, units: bool=True) -> Iterator[Tuple[float, List[float]] ]:
        """
        Take an input file and time-step size and parse all core temps.
    
        :param original_temps: an input file
        :param step_size:      time-step in seconds
        :param units: True if the input file includes units and False if the file
                      includes only raw readings (no units)
    
        :yields: A tuple containing the next time step and a List containing _n_
                 core temps as floating point values (where _n_ is the number of
                 CPU cores)
        """
    

    or the following Sphinx Example:

    Example 7: Python 3 Sphinx Documentation
    def parse_raw_temps(original_temps: TextIO,
                        step_size: int=30, units: bool=True) -> Iterator[Tuple[float, List[float]] ]:
        """
        Take an input file and time-step size and parse all core temps.
    
        Args:
            original_temps: an input file
            step_size: time-step in seconds
            units: True if the input file includes units and False if the file
                includes only raw readings (no units)
    
        Yields:
            A tuple containing the next time step and a List containing _n_
            core temps as floating point values (where _n_ is the number of
            CPU cores)
        """