---
# System prepended metadata

title: 'Solutions: Final Project Part 3 Vectors'

---

# Solutions: Final Project Part 3 Vectors


#### P1 (1pts) Add `-O3 -fopt-info-vec-optimized` to `MICROBENCH_OPTIMIZE` in `config.env` and then `runlab --run-git-remotely -- make build/microbench.o` to generate the optimization report.  It'll show up in the terminal and `STDOUT.txt`.  Paste in the lines that contain the string `microbench.cpp` below (there will be less than 10 of them).

```

build/microbench.cpp:46:13: note: loop vectorized
build/microbench.cpp:97:13: note: loop vectorized
build/microbench.cpp:211:25: note: basic block vectorized
build/microbench.cpp:74:12: note: loop vectorized
build/microbench.cpp:117:12: note: loop vectorized



```

#### P2 (1pts) Which functions contain loops that were vectorized?

```
serial_improved
openmp_simd
openmp_threads
openmp_threads_simd

```

Set `MICROBENCH_CMD_LINE_ARGS=--stat-set PE.cfg --impl openmp_simd serial` (leave `MICROBENCH_OPTIMIZE` as it is) and then `runlab --run-by-proxy -- make microbench.csv` (or commit and use `--run-git-remotely`).  Use the resulting `microbench.csv` to answer the following question.

#### P3 (3pt) Compute the impact of SIMD on the following terms of the performance equation using the data for `openmp_simd` and `serial`.  For each term, compute `(value for serial)/(value for openmp_simd)`.

```

omp_threads|size    |function   |IC      |cycles  |runtime|PAPI_REF_CYC|MHz  |IPC  |CT      |CPI  |ET  |
-----------|--------|-----------|--------|--------|-------|------------|-----|-----|--------|-----|----|
1.0        |5.37e+08|openmp_simd|4.16e+09|5.16e+09|2.76   |4.3e+09     |2e+03|0.806|5.35e-10|1.24 |2.76|
1.0        |5.37e+08|serial     |1.23e+10|1.07e+10|5.12   |8.98e+09    |2e+03|1.15 |4.77e-10|0.869|5.12|


IC: 12.3/4.16 = 2.96
CT: 4.77/5.35 = 0.89
CPI: 0.869/1.24 = 0.70
ET: 5.12/2.76 = 1.85
```

#### P4 (2pt) If Intel improved their processors so that the CPI for vector instructions matched that of normal instructions, how much speedup would `openmp_simd` achieve relative to `serial`?

```
Speedup: (1.23*4.77*cpi)/(4.16*0.535*cpi) = 2.63
```

#### P5 (10pt)  Here's 10 free points because we couldn't get vectorization to do anything useful on our code base.  Put whatever you'd like below.

```
+10





```

---
# YOU ARE DONE!  PLEASE ENJOY YOUR SUMMER!
---
