Try   HackMD

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繪圖

範例程式碼分析結果