contributed by <snoopy831002
>
reviewed by <janetwei
>
make check
開使編繹分別產生5個執行檔make gencsv
將執行結果輸入至csv檔中
gencsv: default
for i in `seq 100 5000 25000`; do \
printf "%d " $$i;\
./benchmark_clock_gettime $$i; \
done > result_clock_gettime.csv
make plot
plot: result_clock_gettime.csv
gunplot runtime.gp
set title "compute-pi"
set xlabel "N"
set ylabel "Time(second)"
set term png enhanced font 'Verdana,10'
set datafile separator ","
set output 'runtime.png'
plot "result_clock_gettime.csv" using 1:2 title 'baseline' with lines lt rgb 'blue' , \
"result_clock_gettime.csv" using 1:4 title 'openmp_2' with lines lt rgb 'red' , \
"result_clock_gettime.csv" using 1:6 title 'openmp_4' with lines lt rgb 'orange' , \
"result_clock_gettime.csv" using 1:8 title 'avx' with lines lt rgb 'green' , \
"result_clock_gettime.csv" using 1:10 title 'avxunroll' with lines lt rgb 'purple'
如果此時出現Skipping data file with no valid points
請在runtime .gp檔案中增加 set datafile separator","
(因為CSV檔案中
以下為250筆資料之結果
以下為500筆資料之結果
在benchmark_clock_gettime.c中意外發現所測之clock其實是疊代25次之結果(原執行時間之25倍),所以應將程式改為取25次運算時間之平均
clock_gettime(CLOCK_ID, &start);
for(i = 0; i < loop; i++){
compute_pi_baseline(N);
}
clock_gettime(CLOCK_ID, &end);
printf("%lf",(double)((end.tv_sec-start.tv_sec)+(end.tv_nsec-start.tv_nsec)/ONE_SEC))/loop);
統計學上,我們可以預測在95%信心水準下,95%以上的正確資料會出現在此信賴區間內。
公式:
以下為50筆資料之結果
以下為250筆資料之結果
以下為500筆資料之結果
由這幾張圖可以發現資料跳動已經不如未修正之前了
以下為50筆資料之結果
以下為250筆資料之結果
以下為500筆資料之結果