# 2016q3 Homework 1 (compute-pi) ###### tags: `sysprog21` `not-done` `louielu` contributed by <`louielu`> github: https://gtihub.com/grapherd/compute-pi ## 開發環境 * CPU: Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz * MEM: 8GB ## Read The Code ### `computepi.h` 這個檔案放有待測試 function 的宣告 ### `computepi.c` compute pi function 實做的地方 ### `time_test.c` 透過 gcc -Dmacro 的方式來產生不同的測試程式,舉例來說想要產生 openmp_2 的測試程式 `$ gcc -DOPENMP_2 -O0 time_test.c computepi.o -o time_test_openmp_2` 就能產生,相關的指令參看 `Makefile default:` 部份。 這邊所產生的測試檔,都是測試單一函式的程式,同時預設的 N 是 400,000,000 次。 ### `benchmark_clock_gettime.c` 測試全部的函式,然後輸出每個函式執行的時間。 有 args `int N`,代表函式迭代的次數。 時間使用 `clock_gettime` 來取得,預設使用的 clock 是 `CLOCK_MONOTONIC_RAW`。取樣次數預設為 25 次,參看 `loop` 變數。 #### example output ``` $ ./benchmark_clock_gettime 250 0.000084,0.000117,0.008408,0.000041,0.000038 ``` ### TODO list * `benchmark_clock_gettime` 應該要變更為 95% 信賴區間的統計資料。 * 可參考 [許元杰的筆記](https://hackpad.com/Hw1-Extcompute_pi-geXUeYjdv1I) * proof critical path (why baseline unroll can't see perf improve?) ## Wounderful Math: Pi Formulas * [Pi Formulas](http://mathworld.wolfram.com/PiFormulas.html) by wolfram * 共計提出 132 條算算式 * 總能在裏面找到幾個 CPU friendly 的公式吧?