This commit is contained in:
Michael Zhang 2023-10-09 08:38:30 -05:00
parent bfcb5764d6
commit a2f9e4a954

View file

@ -10,14 +10,20 @@ author: |
1. _A short description of how you went about parallelizing the classification algorithm. You should include how you decomposed the problem and why, i.e., what were the tasks being parallelized._
The parallelization I used was incredibly simple, just parallelizing outer iterations. I used this same trick for both the OpenMP and the pthreads implementations.
The parallelization I used was incredibly simple, primarily just parallelizing outer iterations. For the OpenMP version I also went ahead and parallelized by the rows, but only if there were more cores than the number of dimensions, as a simple heuristic.
The reason I didn't go further was that further breaking down of the for loops incurred more overhead from managing the parallelization than was actually gained. I have run this several times and the gains were either neglient, or it actually ran slower than the serial version.
This also had to do with the fact that I had already inlined most of the calculations to require as few loops as possible, moved all allocations to the top level, and arranged my data buffer in column-major order instead since the iteration pattern was by dimension rather than by row.
Some other optimizations I did are:
- inlined most of the calculations to require as few loops as possible
- moved all allocations to the top level
- arranged my data buffer in column-major order instead since the iteration pattern was by dimension rather than by row
2. _Timing results for 1, 2, 4, 8, and 16 threads for the classification. You should include results with outer iterations set to 10._
Run on my local machine:
```
./lc_pthreads ./dataset/small_data.csv ./dataset/small_data.csv 10 1
Program time (compute): 0.0069s
@ -61,6 +67,51 @@ author: |
Program time (compute): 3.5328s
```
Run on `csel-plate` (slower clock speed but significantly more cores):
```
./lc_pthreads ./dataset/small_data.csv ./dataset/small_data.csv 10 1
Program time (compute): 0.0519s
./lc_pthreads ./dataset/small_data.csv ./dataset/small_data.csv 10 2
Program time (compute): 0.0288s
./lc_pthreads ./dataset/small_data.csv ./dataset/small_data.csv 10 4
Program time (compute): 0.0248s
./lc_pthreads ./dataset/small_data.csv ./dataset/small_data.csv 10 8
Program time (compute): 0.0335s
./lc_pthreads ./dataset/small_data.csv ./dataset/small_data.csv 10 16
Program time (compute): 0.0299s
./lc_pthreads ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 1
Program time (compute): 739.2866s
./lc_pthreads ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 2
Program time (compute): 375.7334s
./lc_pthreads ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 4
Program time (compute): 187.6661s
./lc_pthreads ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 8
Program time (compute): 93.6721s
./lc_pthreads ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 16
Program time (compute): 46.9217s
./lc_openmp ./dataset/small_data.csv ./dataset/small_data.csv 10 1
Program time (compute): 0.0298s
./lc_openmp ./dataset/small_data.csv ./dataset/small_data.csv 10 2
Program time (compute): 0.0163s
./lc_openmp ./dataset/small_data.csv ./dataset/small_data.csv 10 4
Program time (compute): 0.0122s
./lc_openmp ./dataset/small_data.csv ./dataset/small_data.csv 10 8
Program time (compute): 0.0108s
./lc_openmp ./dataset/small_data.csv ./dataset/small_data.csv 10 16
Program time (compute): 0.0099s
./lc_openmp ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 1
Program time (compute): 730.4170s
./lc_openmp ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 2
Program time (compute): 375.2444s
./lc_openmp ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 4
Program time (compute): 187.1316s
./lc_openmp ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 8
Program time (compute): 93.7702s
./lc_openmp ./dataset/MNIST_data.csv ./dataset/MNIST_label.csv 10 16
Program time (compute): 46.7320s
```
This data was generated using the `run_benchmark.sh > out.txt` script.
## NOTES