From 4c5835625d95111543426ef44b39ae3ecd64e392 Mon Sep 17 00:00:00 2001 From: Ziad Arafat Date: Thu, 28 Oct 2021 16:49:58 -0600 Subject: [PATCH] midterm --- Midterm/gauss.c | 41 ++++ Midterm/midterm.html | 381 ++++++++++++++++++++++++++++++++ Midterm/midterm.md | 85 ++++++++ Program2/outs.txt | 505 +++++++++++++++++++++++++------------------ Program2/readthem.py | 19 +- 5 files changed, 816 insertions(+), 215 deletions(-) create mode 100644 Midterm/gauss.c create mode 100644 Midterm/midterm.html create mode 100644 Midterm/midterm.md diff --git a/Midterm/gauss.c b/Midterm/gauss.c new file mode 100644 index 0000000..04d713f --- /dev/null +++ b/Midterm/gauss.c @@ -0,0 +1,41 @@ +#include +#include +int main() +{ + int a[10][10], b[10][10], mul[10][10], r, c, i, j, k; + system("cls"); + printf("enter the number of row="); + scanf("%d", &r); + printf("enter the number of column="); + scanf("%d", &c); + printf("enter the first matrix element=\n"); + for (i = 0; i < r; i++) { + for (j = 0; j < c; j++) { + scanf("%d", &a[i][j]); + } + } + printf("enter the second matrix element=\n"); + for (i = 0; i < r; i++) { + for (j = 0; j < c; j++) { + scanf("%d", &b[i][j]); + } + } + + printf("multiply of the matrix=\n"); + for (i = 0; i < r; i++) { + for (j = 0; j < c; j++) { + mul[i][j] = 0; + for (k = 0; k < c; k++) { + mul[i][j] += a[i][k] * b[k][j]; + } + } + } + //for printing result + for (i = 0; i < r; i++) { + for (j = 0; j < c; j++) { + printf("%d\t", mul[i][j]); + } + printf("\n"); + } + return 0; +} \ No newline at end of file diff --git a/Midterm/midterm.html b/Midterm/midterm.html new file mode 100644 index 0000000..beef09e --- /dev/null +++ b/Midterm/midterm.html @@ -0,0 +1,381 @@ + + midterm + + + + + + + + + + + + + + + + +
+

Parallel Programming Midterm

+ +

1

+ +
Q
+ +
    +
  1. Provide a clear example of how the “localize()” function works in Peril-L and why it is an important concept in parallel programming.
  2. +
+
A
+ +
    +
  • localize() allows us to map the global memory to a local memory of a thread.
  • +
  • This is important because we need a standard way to talk about how we distribute and access the global data accross threads without going into detail of how that's being done in pseudocode.
  • +
  • It also allows us to think about the section of global data allocated for a thread in a relative way. +
      +
    • Such that if we give a thread the last quarter of a global array we can access that section of the array starting at 0 rather than having to compute where we are in the global array.
    • +
    +
  • +
  • Here is an example of how we could use localize in Peril-L +
      +
    • This is a modified version of the example used in the book p.93.
    • +
    • This version will also demonstrate writing to the local reference.
    • +
    +
  • +
+
int _allData_ [n]; // This is a global array
+
+forall( threadID in(0..P-l)) // let's spawn P threads
+{
+        int size=n/P; // The size of the section for this thread
+
+        // This will map the appropriate section of
+        // the _allData_ array based on size to the locData array. 
+        int locData[size]=localize(_allData_[]); 
+
+        // This will set all the values of our chunk of the array
+        // to be equal to our threadID. Since this is mapped to 
+        // the global array we can assume the global array will be
+        // updated because the local and global are references to
+        // the same location. 
+        for (int i = 0; i < size; i++) {
+                locData[i] = threadID;
+        }
+}
+

2

+ +
Q
+ +
    +
  1. Provide a description, detailed history, and performance characteristics of the Infiniband communications infrastructure. I am interested in when the subsystem becomes saturated, what is the normal connection topology, what systems support it, studies on how it performs both as a bench requirement as well as how well it performs with real applications. You need to have more than 3 references.
  2. +
+
A
+ +
    +
  • The Infiniband Trade Association started when two competing ideas, Future I/O and Next Generation I/O merged in 1999 [1]
  • +
  • +
+ +

3

+ +
Q
+ +
    +
  1. What are the differences between Speedup and
    +Relative Speedup. Convince me that you
    +understand why we have the two terms.
  2. +
+
A
+ +
    +
  • Speedup tells us the difference in performance between the Parallel computation using PP processors and the best serial computation TsT_s.
  • +
  • Relative Speedup on the other hand doesn't use the performance of the serial program TsT_s but rather the performance of the parallel program with only one Process/Thread so it compares the parallel code when P=1P=1 vs when we add more processors.
  • +
  • The reason we have these separate terms is because the overhead of setting up a parallel program will mean that using 1 processor in a parallel version will be different from running it in serial sometimes.
  • +
  • Another reason is that Relative Speedup allows us to analyze how the parallel code scales up starting with one process.
  • +
+

4

+ +
Q
+ +
    +
  1. Define and explain “efficiency” as it applies to parallel computing. Is it possible to have an efficiency greater than 1? If so, give examples. If not, state why not.
  2. +
+
A
+ +
    +
  • Efficiency is defined as the speedup/Pspeedup / P where PP is the number of processors used and speedupspeedup is the improvement in performance from the serial algorithm to the parallel algorithm.
  • +
  • Because speedup is based on the serial time divided by the parallel time we can only expect to get something higher than 1 if the serial time is significantly higher than the parallel time.
  • +
  • This can happen if the serial time is artificially inflated whether on accident or on purpose.
  • +
  • It can also happen in rare cases like Program 1 in the book when all the memory needed by the processes can fit into the cache of the processors and so the parallel code has more efficient memory access.
  • +
+

5

+ +
Q
+ +
A
+ + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/Midterm/midterm.md b/Midterm/midterm.md new file mode 100644 index 0000000..98b2db7 --- /dev/null +++ b/Midterm/midterm.md @@ -0,0 +1,85 @@ +# Parallel Programming Midterm + +### 1 + +##### Q +1) Provide a clear example of how the “localize()” function works in Peril-L and why it is an important concept in parallel programming. + +##### A + +- `localize()` allows us to map the global memory to a local memory of a thread. +- This is important because we need a standard way to talk about how we distribute and access the global data accross threads without going into detail of how that's being done in pseudocode. +- It also allows us to think about the section of global data allocated for a thread in a relative way. + - Such that if we give a thread the last quarter of a global array we can access that section of the array starting at 0 rather than having to compute where we are in the global array. +- Here is an example of how we could use localize in Peril-L + - This is a modified version of the example used in the book p.93. + - This version will also demonstrate writing to the local reference. + +```c +int _allData_ [n]; // This is a global array + +forall( threadID in(0..P-l)) // let's spawn P threads +{ + int size=n/P; // The size of the section for this thread + + // This will map the appropriate section of + // the _allData_ array based on size to the locData array. + int locData[size]=localize(_allData_[]); + + // This will set all the values of our chunk of the array + // to be equal to our threadID. Since this is mapped to + // the global array we can assume the global array will be + // updated because the local and global are references to + // the same location. + for (int i = 0; i < size; i++) { + locData[i] = threadID; + } +} +``` + +### 2 + +##### Q +2) Provide a description, detailed history, and performance characteristics of the Infiniband communications infrastructure. I am interested in when the subsystem becomes saturated, what is the normal connection topology, what systems support it, studies on how it performs both as a bench requirement as well as how well it performs with real applications. You need to have more than 3 references. + +##### A + +- The Infiniband Trade Association started when two competing ideas, Future I/O and Next Generation I/O merged in 1999 [1] +- + + +- References + 1. https://www.eetimes.com/warring-ngio-and-future-i-o-groups-to-merge/ + 2. + +### 3 + +##### Q +3) What are the differences between Speedup and +Relative Speedup. Convince me that you +understand why we have the two terms. + +##### A + +- Speedup tells us the difference in performance between the Parallel computation using $P$ processors and the best serial computation $T_s$. +- Relative Speedup on the other hand doesn't use the performance of the serial program $T_s$ but rather the performance of the parallel program with only one Process/Thread so it compares the parallel code when $P=1$ vs when we add more processors. +- The reason we have these separate terms is because the overhead of setting up a parallel program will mean that using 1 processor in a parallel version will be different from running it in serial sometimes. +- Another reason is that Relative Speedup allows us to analyze how the parallel code scales up starting with one process. + +### 4 + +##### Q +4) Define and explain “efficiency” as it applies to parallel computing. Is it possible to have an efficiency greater than 1? If so, give examples. If not, state why not. +##### A +- **Efficiency** is defined as the $speedup / P$ where $P$ is the number of processors used and $speedup$ is the improvement in performance from the serial algorithm to the parallel algorithm. +- Because speedup is based on the serial time divided by the parallel time we can only expect to get something higher than 1 if the serial time is significantly higher than the parallel time. +- This can happen if the serial time is artificially inflated whether on accident or on purpose. +- It can also happen in rare cases like Program 1 in the book when all the memory needed by the processes can fit into the cache of the processors and so the parallel code has more efficient memory access. + +### 5 + +##### Q + + + +##### A \ No newline at end of file diff --git a/Program2/outs.txt b/Program2/outs.txt index 6214916..b27729f 100644 --- a/Program2/outs.txt +++ b/Program2/outs.txt @@ -3,191 +3,254 @@ ##### 1 Thread ```bash -doge@godemperordoge1998 ~/D/p/padded (main)> make -gcc -O0 -Wall -Werror -Wextra -pedantic -pthread -lpthread -o padded padded.c -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 1 -Time parallel: 79589173 -Time serial: 76582925 -parallel count is 2499295 -serial count is 2499295 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 1 -Time parallel: 77817021 -Time serial: 76191186 -parallel count is 2501600 -serial count is 2501600 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 1 -Time parallel: 78369396 -Time serial: 76075458 -parallel count is 2501212 -serial count is 2501212 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 1 -Time parallel: 77878131 -Time serial: 75789878 -parallel count is 2497788 -serial count is 2497788 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 1 -Time parallel: 78617891 -Time serial: 76074550 -parallel count is 2499979 -serial count is 2499979 -doge@godemperordoge1998 ~/D/p/padded (main)> +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> make clean +rm -rf padded_shm +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> make +gcc -O0 -Wall -Werror -Wextra -pedantic -pthread -o padded_shm padded_shm.c +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 1 +Time process: 31300629 +Time thread: 27381486 +Time serial: 38851311 +process count is 2500157 +thread count is 2500157 +serial count is 2500157 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 1 +Time process: 30117308 +Time thread: 28445308 +Time serial: 38232656 +process count is 2498865 +thread count is 2498865 +serial count is 2498865 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 1 +Time process: 33679214 +Time thread: 27455518 +Time serial: 38993926 +process count is 2498865 +thread count is 2498865 +serial count is 2498865 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 1 +Time process: 36710465 +Time thread: 27729854 +Time serial: 38804797 +process count is 2501939 +thread count is 2501939 +serial count is 2501939 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 1 +Time process: 31838897 +Time thread: 28574026 +Time serial: 38197665 +process count is 2501939 +thread count is 2501939 +serial count is 2501939 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ``` ##### 2 Threads ```bash -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 2 -Time parallel: 39898720 -Time serial: 76881427 -parallel count is 2498665 -serial count is 2498665 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 2 -Time parallel: 38993717 -Time serial: 75975306 -parallel count is 2498665 -serial count is 2498665 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 2 -Time parallel: 43756962 -Time serial: 75922017 -parallel count is 2499470 -serial count is 2499470 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 2 -Time parallel: 39628155 -Time serial: 75874106 -parallel count is 2499470 -serial count is 2499470 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 2 -Time parallel: 38768479 -Time serial: 83936863 -parallel count is 2499249 -serial count is 2499249 -doge@godemperordoge1998 ~/D/p/padded (main)> +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 2 +Time process: 19765293 +Time thread: 14919286 +Time serial: 38001761 +process count is 2500756 +thread count is 2500756 +serial count is 2500756 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 2 +Time process: 16166721 +Time thread: 17203375 +Time serial: 39284676 +process count is 2500756 +thread count is 2500756 +serial count is 2500756 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 2 +Time process: 19934239 +Time thread: 17330976 +Time serial: 38693330 +process count is 2501132 +thread count is 2501132 +serial count is 2501132 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 2 +Time process: 18905617 +Time thread: 16755903 +Time serial: 39231666 +process count is 2501132 +thread count is 2501132 +serial count is 2501132 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 2 +Time process: 16863108 +Time thread: 14817806 +Time serial: 38020199 +process count is 2495477 +thread count is 2495477 +serial count is 2495477 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ``` ##### 4 Threads ```bash -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 4 -Time parallel: 20135731 -Time serial: 76379757 -parallel count is 2500818 -serial count is 2500818 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 4 -Time parallel: 20184131 -Time serial: 76066309 -parallel count is 2500619 -serial count is 2500619 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 4 -Time parallel: 20012671 -Time serial: 76159618 -parallel count is 2500619 -serial count is 2500619 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 4 -Time parallel: 20407135 -Time serial: 76091592 -parallel count is 2501896 -serial count is 2501896 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 4 -Time parallel: 19932075 -Time serial: 75735192 -parallel count is 2501896 -serial count is 2501896 -doge@godemperordoge1998 ~/D/p/padded (main)> +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 4 +Time process: 11948587 +Time thread: 9570700 +Time serial: 39345088 +process count is 2500645 +thread count is 2500645 +serial count is 2500645 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 4 +Time process: 11596517 +Time thread: 9400218 +Time serial: 38839228 +process count is 2502182 +thread count is 2502182 +serial count is 2502182 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 4 +Time process: 12134085 +Time thread: 9552821 +Time serial: 39723767 +process count is 2502182 +thread count is 2502182 +serial count is 2502182 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 4 +Time process: 11011317 +Time thread: 8547107 +Time serial: 38454333 +process count is 2502182 +thread count is 2502182 +serial count is 2502182 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 4 +Time process: 11576543 +Time thread: 9165971 +Time serial: 39198422 +process count is 2496859 +thread count is 2496859 +serial count is 2496859 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> + ``` ##### 8 Threads ```bash -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 8 -Time parallel: 10802910 -Time serial: 76379477 -parallel count is 2499488 -serial count is 2499488 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 8 -Time parallel: 10938262 -Time serial: 75819630 -parallel count is 2499488 -serial count is 2499488 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 8 -Time parallel: 10780422 -Time serial: 75986271 -parallel count is 2499970 -serial count is 2499970 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 8 -Time parallel: 10738028 -Time serial: 75738055 -parallel count is 2499970 -serial count is 2499970 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 8 -Time parallel: 10694446 -Time serial: 76413770 -parallel count is 2498866 -serial count is 2498866 -doge@godemperordoge1998 ~/D/p/padded (main)> +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 8 +Time process: 11371838 +Time thread: 12433425 +Time serial: 39216161 +process count is 2503298 +thread count is 2503298 +serial count is 2503298 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 8 +Time process: 10912631 +Time thread: 7882986 +Time serial: 38051697 +process count is 2503298 +thread count is 2503298 +serial count is 2503298 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 8 +Time process: 11806390 +Time thread: 8301336 +Time serial: 38027532 +process count is 2498370 +thread count is 2498370 +serial count is 2498370 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 8 +Time process: 11366879 +Time thread: 8129595 +Time serial: 39016136 +process count is 2498370 +thread count is 2498370 +serial count is 2498370 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 8 +Time process: 11057761 +Time thread: 7882287 +Time serial: 39576961 +process count is 2500216 +thread count is 2500216 +serial count is 2500216 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> + ``` ##### 16 Threads ```bash -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 16 -Time parallel: 15428848 -Time serial: 76461611 -parallel count is 2499356 -serial count is 2499356 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 16 -Time parallel: 10718332 -Time serial: 76038093 -parallel count is 2497083 -serial count is 2497083 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 16 -Time parallel: 11129069 -Time serial: 76266824 -parallel count is 2497083 -serial count is 2497083 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 16 -Time parallel: 12962264 -Time serial: 76701516 -parallel count is 2500337 -serial count is 2500337 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 16 -Time parallel: 12169984 -Time serial: 76016583 -parallel count is 2500337 -serial count is 2500337 -doge@godemperordoge1998 ~/D/p/padded (main)> - +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 16 +Time process: 11814072 +Time thread: 6241576 +Time serial: 38765056 +process count is 2497673 +thread count is 2497673 +serial count is 2497673 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 16 +Time process: 9966212 +Time thread: 6230471 +Time serial: 38180415 +process count is 2500316 +thread count is 2500316 +serial count is 2500316 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 16 +Time process: 9616237 +Time thread: 6556700 +Time serial: 37949799 +process count is 2500316 +thread count is 2500316 +serial count is 2500316 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 16 +Time process: 9161779 +Time thread: 5917163 +Time serial: 38628656 +process count is 2499673 +thread count is 2499673 +serial count is 2499673 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 16 +Time process: 10823443 +Time thread: 7500745 +Time serial: 38676428 +process count is 2499673 +thread count is 2499673 +serial count is 2499673 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ``` ##### 32 Threads ```bash -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 32 -Time parallel: 13191343 -Time serial: 76977528 -parallel count is 2501573 -serial count is 2501573 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 32 -Time parallel: 11433019 -Time serial: 75182119 -parallel count is 2499230 -serial count is 2499230 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 32 -Time parallel: 11259742 -Time serial: 76361110 -parallel count is 2499230 -serial count is 2499230 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 32 -Time parallel: 13108860 -Time serial: 76463636 -parallel count is 2497643 -serial count is 2497643 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 32 -Time parallel: 12005927 -Time serial: 76738602 -parallel count is 2500608 -serial count is 2500608 -doge@godemperordoge1998 ~/D/p/padded (main)> +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 32 +Time process: 12711114 +Time thread: 6997469 +Time serial: 38191590 +process count is 2500219 +thread count is 2500219 +serial count is 2500219 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 32 +Time process: 11968282 +Time thread: 6127246 +Time serial: 38613780 +process count is 2501608 +thread count is 2501608 +serial count is 2501608 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 32 +Time process: 11430993 +Time thread: 5560414 +Time serial: 37915367 +process count is 2501608 +thread count is 2501608 +serial count is 2501608 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 32 +Time process: 14200340 +Time thread: 6254566 +Time serial: 37790770 +process count is 2499008 +thread count is 2499008 +serial count is 2499008 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 32 +Time process: 12473234 +Time thread: 5559227 +Time serial: 38884904 +process count is 2499008 +thread count is 2499008 +serial count is 2499008 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> @@ -196,62 +259,82 @@ doge@godemperordoge1998 ~/D/p/padded (main)> ##### 64 Threads ```bash -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 64 -Time parallel: 13443889 -Time serial: 75998703 -parallel count is 2501406 -serial count is 2501406 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 64 -Time parallel: 13066536 -Time serial: 80285631 -parallel count is 2498365 -serial count is 2498365 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 64 -Time parallel: 12961145 -Time serial: 76057230 -parallel count is 2497858 -serial count is 2497858 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 64 -Time parallel: 13297153 -Time serial: 76248665 -parallel count is 2497858 -serial count is 2497858 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 64 -Time parallel: 12780816 -Time serial: 75720945 -parallel count is 2500354 -serial count is 2500354 -doge@godemperordoge1998 ~/D/p/padded (main)> +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 64 +Time process: 24745535 +Time thread: 6127106 +Time serial: 38006859 +process count is 2497175 +thread count is 2497175 +serial count is 2497175 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 64 +Time process: 28722368 +Time thread: 7104116 +Time serial: 37991215 +process count is 2497175 +thread count is 2497175 +serial count is 2497175 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 64 +Time process: 21233986 +Time thread: 8111716 +Time serial: 38107081 +process count is 2500353 +thread count is 2500353 +serial count is 2500353 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 64 +Time process: 22752056 +Time thread: 6638275 +Time serial: 38377438 +process count is 2500353 +thread count is 2500353 +serial count is 2500353 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 64 +Time process: 23279567 +Time thread: 7179544 +Time serial: 38014053 +process count is 2500353 +thread count is 2500353 +serial count is 2500353 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ``` ##### 128 Threads ```bash -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 128 -Time parallel: 14702009 -Time serial: 75864468 -parallel count is 2497320 -serial count is 2497320 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 128 -Time parallel: 15708353 -Time serial: 76406018 -parallel count is 2497320 -serial count is 2497320 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 128 -Time parallel: 14599762 -Time serial: 76125185 -parallel count is 2499108 -serial count is 2499108 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 128 -Time parallel: 18146093 -Time serial: 76192373 -parallel count is 2496782 -serial count is 2496782 -doge@godemperordoge1998 ~/D/p/padded (main)> ./padded 10000000 128 -Time parallel: 15152136 -Time serial: 76688875 -parallel count is 2496782 -serial count is 2496782 -doge@godemperordoge1998 ~/D/p/padded (main)> +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 128 +Time process: 39314847 +Time thread: 7729894 +Time serial: 38421158 +process count is 2497777 +thread count is 2497777 +serial count is 2497777 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 128 +Time process: 50211345 +Time thread: 6592179 +Time serial: 38824352 +process count is 2497777 +thread count is 2497777 +serial count is 2497777 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 128 +Time process: 48485636 +Time thread: 7374960 +Time serial: 37748656 +process count is 2500180 +thread count is 2500180 +serial count is 2500180 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 128 +Time process: 49846494 +Time thread: 6228096 +Time serial: 37988352 +process count is 2500180 +thread count is 2500180 +serial count is 2500180 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ./padded_shm 10000000 128 +Time process: 40951717 +Time thread: 7092033 +Time serial: 38300263 +process count is 2500334 +thread count is 2500334 +serial count is 2500334 +doge@godemperordoge1998 ~/D/p/P/padded_shm (main)> ``` \ No newline at end of file diff --git a/Program2/readthem.py b/Program2/readthem.py index b2a2a8b..33d04ec 100644 --- a/Program2/readthem.py +++ b/Program2/readthem.py @@ -7,9 +7,11 @@ times of the runs. outs.txt must contain the raw console outputs from statistics import mean par = [] ser = [] +pro = [] avgp = [] avgs = [] +avgpr = [] threads = 0 vals = 0 @@ -22,18 +24,27 @@ with open('./outs.txt') as reader: if vals == 5: avgp.append(mean(par)) avgs.append(mean(ser)) + avgpr.append(mean(pro)) par=[] ser=[] + pro = [] vals = 0 threads += 1 word = line.split(' ') - if 'parallel:' in word: - par.append(int(word[2])) + if 'process:' in word: + pro.append(int(word[2])) + # print(word) + if 'thread:' in word: + par.append(int(word[3])) + # print(word) if 'serial:' in word: - ser.append(int(word[4])) + # print(word) + ser.append(int(word[3])) vals += 1 + + -print("ser: ", avgs, "par: ", avgp, threads) +print("ser: ", avgs, "par: ", avgp, "pro: ", avgpr, "threads: ", threads)