****************************** Solution C ****************************** One of the choices of benchmarks to measure and compare the performance of computers is using small but heavy-computation programs.In this assignment I used two small programs: Prime testing to determine if a value n is prime or not and Gaussian Integral using the adaptation of the Simpson's rule. I used these programs to compare the performance of three computers: A Linux lab computer, Grendel, and Ozark. The following are my results: 1. T prime,lab: 7.421 seconds 2. T gauss,lab: 4.316 seconds 3. T prime,Grendel: 32.204 seconds 4. T gauss,Grendel: 12.471 seconds 5. T prime,Ozark: 57.070 seconds 6. T gauss,Ozark: 9.416 seconds 7. T prime,Grendel/T prime,lab: 32.204 seconds/7.421 seconds = 4.34 8. T prime,Ozark/T prime,lab: 57.070 seconds/7.421 seconds = 7.69 9. T gauss,Grendel/T gauss,lab: 12.471 seconds/4.316 seconds = 2.89 10. T gauss,Ozark/T gauss,lab: 9.416 seconds/4.316 seconds = 2.18 To obtains these results, I wrote those small programs in C and I used the "time" command in Linux that given a simple program as argument outputs the timing statistics of the program. The "time" command gives you three values: real: the time elapsed between invocation and termination of the program, user: the time that the CPU spends on the program, sys: the time the operating system spends before responding on your program. In this report I chose to user "real" because it provided me accurate information about the program I wanted to test. The following are the exacts steps I used: part A: Here are the terminal commands to get the time for primeTesting.c and gaussian.c (see appendix) on Linux Lab computers: 1. For primeTesting.c step 0: Go in the folder where your primeTesting.c file is saved using "cd" command. step 1: compile the program and rename the executable file: gcc primeTesting.c -o primeTesting step 2: time and execute the program: time ./primeTesting 2. For gaussian.c step 0: Go in the folder where your gaussian.c file is saved using "cd" command. step 1: compile the program and rename the executable file: gcc gaussian.c -lm -o gaussian (make sure to add the math functions library using -lm) step 2: time and execute the program: time ./gaussian The output is the output for the program followed by the time statistics. part B: To test our programs on grendel, we do one step prior to step 0. We have to make sure that commands we execute are being sent to grendel. We ensure this by typing "ssh grendel" in the terminal and after providing the required password; any subsequent command will be sent to grendel. Since Linux lab computers and grendel have the same hierarchy of folders you can access your files just as you access them on Linux labs. The rest is the same as in part A. part C: To test our programs on ozark, we have to use "ssh ozark" just as we did on grendel. However, since on ozark my home directory is different than on linux and grendel I have to do one step before I can run my programs which is to copy the .c files from grendel onto my "www" folder on ozark. Having successfully accessed ozark, you can then type "ls" and you will see that there is a directory called grendel and another called www. You must copy your files from grendel to www before executing them. I used the following commands to copy primeTesting.c and gaussian.c to my www directory. The first argument is the path to my .c files on grendel. "cp grendel/Desktop/Computer Architecture/BenchMarks/primeTesting.c www" "cp grendel/Desktop/Computer Architecture/BenchMarks/gaussian.c www" After copying the files in "www", I used the same steps as in part A. In conclusion, as you can see from the results the linux lab computers are faster in executing these programs than grendel and ozark. Grendel is faster than Ozark on primeTesting.c but slower on gaussian.c. Although, these programs are different than real applications that these computers have to respond to, they do show us a significant comparison between those three computers. Appendix: primeTesting.c #include #include #include typedef enum {false, true} bool; bool primetest(int n){ int d = 2; while ((d*d) < n){ if (n % d == 0){ return false; } d = d+1; } return true; } int main(void) { int n = 2147483647; if(primetest(n)){ printf("%d is prime\n" , n); } else { printf("%d is not prime\n", n); } return EXIT_SUCCESS; } gaussian.c #include "stdio.h" #include "stdlib.h" #include "math.h" double func (double x){ double val = -(x*x)/2; double res = exp(val); return res; } double gauss(int n){ double sum = func(-2.0) + func(2.0); double delta = 4.0/n; int i; for (i=1; i < n;i++){ sum += 3 * (func(-2 + (i*delta))); } return delta * sum/3; } int main(int argc, char** argv) { int n = 100000000; double resp; resp = gauss(n); printf("The response is %f ", resp); return 0; }