# 2016q3 Homework1(compute-pi)
contributed by <`LitSnow`>
## 開發環境
* Linux核心:Ubuntu 14.04.3 LTS
* linux系統版本: Linux version 3.19.0-25-generic
## Gnuplot
* 新增一個 runtime.gp檔 ,這個檔案用來存用gnuplot繪圖時所要用到的指令
```=
set xlabel 'N'
set ylabel 'Time(sec)'
set style fill solid
set title 'Compute_pi Time by clock_gettime() '
set term png enhanced font 'Verdana,10'
set output 'runtime.png'
set term pngcairo size 1280,960
set datafile separator ","
plot "result_clock_gettime.csv" using 1:2 title 'baseline' with lines lt rgb 'red' , \
"result_clock_gettime.csv" using 1:3 title 'openmp_2' with lines lt rgb 'blue' , \
"result_clock_gettime.csv" using 1:4 title 'openmp_4' with lines lt rgb 'green' ,\
"result_clock_gettime.csv" using 1:5 title 'AVX' with lines lt rgb 'orange' ,\
"result_clock_gettime.csv" using 1:6 title 'AVX + loop untolling' with lines lt rgb 'brown'
```
第8行:要plot "*csv" 必須加上`set datafile separator ","`這行,不然會有一些莫名其妙的錯誤訊息
例如:
```
all points y value undefined
```
```
x range is invalid
```
* Makefile中的 gencsv 區塊調整資料取樣區間與個數 :seq `起始數字` `取樣區間` ` 終止數字`
```
gencsv: default
for i in `seq 100 5000 1000000`; do \
printf "%d," $$i;\:
./benchmark_clock_gettime $$i; \
done > result_clock_gettime.csv
```
* Makefile新增以下程式碼
```=
plot: result_clock_gettime.csv
gnuplot runtime.gp
```
在終端機輸入 `make plot` 就會執行gnuplot繪圖
* 參考資料
* [A01: phonebook](https://hackmd.io/s/S1RVdgza)
* [Plotting using a CSV file](http://stackoverflow.com/questions/14871272/plotting-using-a-csv-file)
* [王紹華同學共筆](https://hackmd.io/KYQwjARgZgTArAZgLQgJwAYpICyoMYAmSAHJiEggGzzqQEIDsqYQA===?view#%E5%AF%A6%E4%BD%9C)
## 範例程式碼分析結果

* 參考資料
* [A03: compute-pi](https://hackmd.io/s/rJARexQT)