Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement a C Language program that measures the performance of given

ID: 3682120 • Letter: D

Question

Design and implement a C Language program that measures the performance of given processors.

There are several metrics that measure the performance of a processor. We will be using the following 3 measures:

Typically, processors’ performance is measured using a wide selection of software applications and system software. These specific programs are called “benchmarks”. We will test a set of processors using one such benchmark, and our selected software program is a compiler. The complier program is written using a high level language that will be translated to the Assembly Language instructions that are native to each processor. Next, the number of Assembly Language instructions needed will be counted and used in the equations, above, plus the recorded clock speed and CPU cycles used by the processor’s CPU (central processing unit).

You must implement the following:

You are to use pointers and a function named “performance” to measure the performance of a given processor as described, above. The performance function must be a void function (does not return a value).

Your code should read the input from a data file named “data.txt” which has the data organized in rows such that each row contains the input values of a specific processor, in this order: # clock cycles, CPU speed (clock rate) in Giga Hertz (1 Giga Hertz = 1 x 10+9 Hertz), and # instructions.

Your code should be general and continue reading the data file till EOF is reached.

Your code should be modular. The main function should contain only function calls.

The output of code should be saved to an output file named “results.txt” and should also be echoed to the display.

5/100 points will be allocated for a Minimum Design feature of your code. A minimum design is the implemented code that has the minimum number of instructions that would successfully execute the desired task. Code that is unnecessarily long with unneeded structures or variables is not a minimum design.

Here is a sample run for data file that has data for 2 processors:

To understand the first line of data, processor 1 has executed the complier program using 10 billion Assembly instructions and 7 billion clock cycles. Its processor speed (clock rate) is 4 Giga Hertz.

Note: Both the input data file and the results file contain numbers in scientific notation. Please refere to Task03 of ICS 103 Lab02 for an explanation on how to read and display a number in scientific notation.

# clock cycles instructions CPI (clock cycles per instruction) CPU execution time-#instructions x CPI x clock cycle time Notice that the Cycle Time- 1. 2. CPU Clock Rate in Hertz units per second)Execution Time X 100 # instructions CPU Execution Time X 1000000 3. MIPS (mega instructions per second)

Explanation / Answer

Kindly change the <<File Path>> with the path where the file is located

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
FILE * fp;
char * line = NULL;
size_t len = 0;
ssize_t read;

fp = fopen(<<File_PATH>>, "r");
if (fp == NULL)
exit(EXIT_FAILURE);

while ((read = getline(&line, &len, fp)) != -1) {
   char *token;
   double data[3];
   int i=0;
while ((token = strsep(&line, " ")) != NULL)
   {
  
       data[i]=atof(token);
       i++;
   }
   printf(" Processor performance measure values are : ");
   double cpi=data[0]/data[2];
   double cpu_execution_time=(data[2]*cpi*(1/(data[1]*10000000000)));
   double mips=(data[2]/(cpu_execution_time*1000000));
   printf("CPI: %e ",cpi);
   printf("Execution Time: %e ",cpu_execution_time);
   printf("MIPS : %e",mips);
}

fclose(fp);
if (line)
free(line);
exit(EXIT_SUCCESS);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote