" CS"#$I&"'$B ") Lo op sk ewing Used with lo op in terc hange to exploit parallelism in w a v efron t computations5 do i # $% n'( do j#$% m'( a,i%j-#a,i'(%j-. a,i %j '(- .a ,i. (% j-. a, i%j .( -/ enddo enddo Dep endence 789:;9 7:98; do i # $% n'( do j#i.$% i.m'( j1#j'i/ a,i%j1-#a,i'(%j1- .a, i% j1' (- .a, i. (%j 1- .a, i% j1. (-/ enddo enddo de < Dep endence 7898;9 7:98; Sk ew ed co ! # CS* UCSB T ao Y ang
" CS"#$I&"'$B "' Original iteration space Sk ew ed space j j i i do j#$% m'n)* do i # max.*%j)m'/0% min.n)/%j)*0 j1#j)i2 a3i%j14#a3i)/%j14 'a3 i% j1) /4 'a3 i' /%j 14 'a3 i% j1' /42 enddo enddo de Dep endence '()*+) Sk ew ed and in terc hanged co '()(+, Inner lo op can b e executed in parallel, ! # CS) UCSB T ao Y ang
" CS"#$I&"'$B ") Strip mining Adjust the gran ularit y of an op eration2 do i # $% n a(i)#a(i)*c enddo TN#/n0123412 do TI#$% TN% 12 a(TI6TI*17)#a(TI 6TI *1 7)* c enddo do i # TN% n a(i)#a(i)*c enddo ! # CS* UCSB T ao Y ang
" CS"#$I&"'$B ") Lo op tiling F or i$% to n F or j$% to n new $ ) ! *+, u - - - ./ u u u u i *+ $j i + $j i$j *+ i$j + i$j EndF or EndF or Iteration space partitioning ! # CS, UCSB T ao Y ang
" CS"#$I&"'$B ") T ransformation pro cess Step $% In tro duce con trol v ariables% F or bi # $ to p F or # & b $' # ( $ to i b # i i F or # $ to bj p F or j # & b $' # ( $ to b # j j new # ) & *+& u ( ( ( ', u u u u i *+ %j i + %j *+ + i%j i%j i%j EndF or EndF or EndF or EndF or Step 3% In terc hange lo ops% F or bi # $ to p F or # $ to bj p F or i # & b $' # ( $ to b # i i F or # & b $' # ( $ to j b # j j new # ) & *+& u ( ( ( ', u u u u i *+ %j i + %j i%j *+ i%j + i%j EndF or EndF or EndF or ! # EndF or CS, UCSB T ao Y ang
" CS"#$I&"'$B ") Tiling for matrix m ultiplication ! for i to n do ! for j to n do ! to for k n do c $ i% % c $ i% % & a $ i% % b $ k %' j j k % j Endfor Endfor Endfor ! # CS* UCSB T ao Y ang
Recommend
More recommend