# 2016q3 Homework#1 : raytracing ## Gprof分析 在gcc的指令中加入 `-gp` 的參數 gprof -b raytracing gmon.out | less 先來看看前五名 ``` Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 27.65 0.76 0.76 69646433 0.00 0.00 dot_product 12.74 1.11 0.35 56956357 0.00 0.00 subtract_vector 9.10 1.36 0.25 17836094 0.00 0.00 add_vector 9.10 1.61 0.25 13861875 0.00 0.00 rayRectangularIntersection 8.37 1.84 0.23 13861875 0.00 0.00 raySphereIntersection ``` ## 對math_Toolkik.h做優化 **Function inline** _Execution time of raytracing() : 2.350556 sec_ **Loop unrolling** Loop unrolling的想法很簡單,就是把已知大小的for回圈拆開,聽起來好像很智障,不過在call 6千萬次的function裡面少掉branch的判斷其實就可以大幅提升效能了! _Execution time of raytracing() : 1.633041 sec_ ## 對raytracing.c做優化 **Muti-thread** **CUDA** ## Reference
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up