Semester Project - CPU Temps
Thomas J. Kennedy
1 Overview - Milestones
The Semester Project has intermediary milestones (in addition to the final submission):
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 Labels61.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:
- line 1 is 0 sec
- line 2 is 30 sec,
- line 3 is 60 sec.
- line 4 is 90 sec.
- line 5 is 120 sec.
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…
- sensors-2018.12.26.txt
- sensors-2019.01.26.txt
- sensors-2019.02.09.txt
- sensors-2019.06.07.txt
- sensors-2019.06.14.txt
- sensors-2019.07.12.txt
- sensors-2019.08.04.txt
- sensors-2019.08.12.txt
- sensors-2019.08.25.txt
- sensors-2019.09.07.txt
- sensors-2019.12.24.txt
- sensors-2019.12.25.txt
- sensors-2019.12.26.txt
- sensors-2019.12.29.txt
- sensors-2020.01.02.txt
- sensors-2018.12.26-no-labels.txt
- sensors-2019.01.26-no-labels.txt
- sensors-2019.02.09-no-labels.txt
- sensors-2019.06.07-no-labels.txt
- sensors-2019.06.14-no-labels.txt
- sensors-2019.07.12-no-labels.txt
- sensors-2019.08.04-no-labels.txt
- sensors-2019.08.12-no-labels.txt
- sensors-2019.08.25-no-labels.txt
- sensors-2019.09.07-no-labels.txt
- sensors-2019.12.24-no-labels.txt
- sensors-2019.12.25-no-labels.txt
- sensors-2019.12.26-no-labels.txt
- sensors-2019.12.29-no-labels.txt
- sensors-2020.01.02-no-labels.txt
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
-
\(x_{k}\) and \(x_{k+1}\) are the domain in which \(y_k\) is applicable
-
\(y_k\) is the \(k^{th}\) function
-
type is either least-squares or interpolation
For the example data in described in Section 2.1 (Input Format) you would generate 4 output files.
{basename}-core-0.{txt}
{basename}-core-1.{txt}
{basename}-core-2.{txt}
{basename}-core-3.{txt}
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…
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…
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
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
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
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:
- A piecewise linear interpolation.
- A global linear least squares approximation.
- (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:
- Input (e.g., using the supplied input libraries)
- Data pre-processing (i.e., structuring the data for analysis)
- Piecewise Linear Interpolation
- 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.
-
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;
-
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
-
Pydoc or Sphinx can be used for Python. Consider the following Pydoc Example:
Example 6: Python 3 Pydoc Documentationdef 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 Documentationdef 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) """