Re: [問題] 追求效能下,在Do Loop下用IF敘述?

看板Programming作者 ( )時間17年前 (2008/03/12 12:34), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串6/10 (看更多)
※ 引述《noguest (guest)》之銘言: : 如果演算法方面已經優化的差不多的話,可以從 compiler 的參數下手。假如 : 你的程式還沒有使用 profiling 來最佳化,一定要先試這部份。根據經驗, : 最好的情況是可以讓執行速度快 30%,當然 profiling 對不同的程式和不同的 : 平台的幫助不一定,但一般對越複雜且計算越多的程式幫助比較大。用 profiling : 可以明顯看到對 branch prediction 和 CPI 有幫助。 : icc 的話,profiling 的 flag 是 -prof_gen, -prof_use, 和 -prof_dir,其 : 他的 compiler 大多也有類似的 flag。要注意一點就是用來產生 feedback : 的 workload,越接近實際要跑的計算對效率幫助越大,跑個半小時到一小時就 :  夠了,收集到的資料已夠讓 compiler 做很多的最佳化。 沒錯,還是跑 profiling 最實際, 不過我的建議是先看看 profiling 的資訊, 如果你的架構是 intel 的那可以想辦法去弄到 vTune, 只要你對 architecture (不一定要修過課) 夠瞭解的話, 它可以提供你相當多的資訊, 當然也包括 branch prediction 的準確度等等, 這樣也能順便測試一下你的 compiler 水準到哪裡。 最內層 loop 要是有 call function 的話, 那個 function 內容最好也能同時被 compiler 看到, 這樣才有機會完成 inline; 另外有 if else 並不一定代表一定有 branch instruction 被產生, 因為有可能被 if-conversion 這項最佳化處理掉, 所以做 profiling feedback optimization 可能收到的效果還是有限。 -- Ling-hua Tseng (uranus@it.muds.net) Department of Computer Science, National Tsing-Hua University Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design Researching: Software pipelining for VLIW architectures Homepage: https://it.muds.net/~uranus -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.230.224.95 ※ 編輯: tinlans 來自: 61.230.224.95 (03/12 12:37)
文章代碼(AID): #17rrralG (Programming)
討論串 (同標題文章)
文章代碼(AID): #17rrralG (Programming)