Improving Firewall Performance by Eliminating Redundancies In Access Control Lists
Global Optimization by Suppression of Partial Redundancies について
description
Transcript of Global Optimization by Suppression of Partial Redundancies について
![Page 1: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/1.jpg)
Global Optimizationby Suppression of
Partial Redundanciesについて
野崎 晋也
![Page 2: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/2.jpg)
部分冗長性除去 (PRE) とは
• PRE:Partial Redundancy Elimination
• プログラム内において不要な部分を取り除く
• 最初に提案したのは E. Morel and C. Renviose– Global Optimization by Suppression of Partial Re
dundanciesCommunications of the ACM, 22(2):96--103, February 1979
![Page 3: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/3.jpg)
概要
• 冗長な計算の除去と、不変な計算のループ外への移動は別に行われる事が多い
• 2 回実行される部分の削除によって、上記 2 つを一度にやり、最外ループへ移動
• プログラムの形に関係なくコストはほぼ線形
![Page 4: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/4.jpg)
Local Properties(1)
• ブロック i 内のある expression( 式 ) に対して– Transparency:TRANSP
• ブロック i 内のコマンドの実行によって、その式のオペランドに修正がなければその式は“ transparent” ・・・
y=c+dx=a+b
z=e・・・
青の式のオペランドに対する
変更文がない
![Page 5: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/5.jpg)
Local Properties(2)
• ブロック i 内のある expression( 式 ) に対して– Local Availability:COMP
• ブロック i 内に最低 1 つ式の計算があり、その式の最後の計算より後に出てくるコマンドがオペランドを修正しなければ“ locally available”・・・
a=cx=a+b
z=e・・・
・・・a=cz=e・・・
x=a+b
![Page 6: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/6.jpg)
Local Properties(3)
• ブロック i 内の expression( 式 ) に対して– Local Anticipability:ANTLOC
• ブロック i 内に最低 1 つ式の計算があり、その式の最初の計算より前に出てくるコマンドがオペランドを修正しなければ“ locally anticipated”
・・・z=e
x=a+ba=c・・・
x=a+b・・・
z=ea=c・・・
![Page 7: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/7.jpg)
Global Properties(1)
• I の入口挿入点で上安全であるのは、 I のすべての先行ブロックが、出口計算を持つか出口挿入点で上安全である場合
• ※ 開始ノードでは上安全ではない
• I の出口挿入点で上安全であるのは、 I に変更文がなく、かつ、 I に入り口計算があるかI の入口挿入点で上安全である場合
Availability= 上安全 (up-safe)
![Page 8: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/8.jpg)
上安全の例
I
x=a+b x=a+b
• プログラムの入口から I に達するどの道にも同じ値を与える計算がある場合
![Page 9: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/9.jpg)
Global Properties(2)Anticipability= 下安全 (downsafe)
• I の入口挿入点で下安全であるのは、 I に入口計算があるか、 I の出口挿入点で下安全かつ I に変更文がない場合
• I の出口挿入点で下安全であるのは、 I に出口計算があるか、 I のすべての後続ブロックの入口挿入点で下安全である場合
• ※ 後続ブロックがない場合は、後続ブロックは下安全ではないと考える
![Page 10: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/10.jpg)
• I からプログラムの出口へのどの道へも同じ値を与える計算がある ( 変更文を通らずにその計算に達する )
下安全の例
x=a+b x=a+b
I
![Page 11: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/11.jpg)
Global Properties(3)
![Page 12: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/12.jpg)
Global Utilization of Partial Redundancy Elimination
• The steps of the algorithm are as follows:– (a)Resolution of the Boolean systems for availability ,
anticipability , and partial availability.
– 上安全、下安全、そして部分的に上安全である場所の決定
![Page 13: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/13.jpg)
Global Utilization of Partial Redundancy Elimination
• The steps of the algorithm are as follows:– (b)Determination of predecessors of the blocks containi
ng the partial redundancies and where a new computation may be introduced. This involves the computation of the Boolean properties PPIN and PPOUT (Placement Possible on Entry and Placement Possible on Exit).
– 部分冗長を含み、新しい計算を挿入できる先行ノードの決定
![Page 14: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/14.jpg)
Determination of PPIN and PPOUT
• PPIN の決定の為の各 block i の CONSTi
– CONSTi :
• 各 block の PPIN/PPOUT
![Page 15: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/15.jpg)
Global Utilization of Partial Redundancy Elimination
• The steps of the algorithm are as follows:– (c)Determination of a subset of these blocks on exit of
which a computation must be inserted. These blocks satisfy the Boolean property INSERT.
– プログラム中の各 block i の INSERTi
![Page 16: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/16.jpg)
Global Utilization of Partial Redundancy Elimination
• The steps of the algorithm are as follows:– (d)Insertion of new computations at the exit of the bloc
ks satisfying INSERT = TRUE and suppression of the partially redundant computations which are now redundant.
– その後、 INSERT=TRUE を満たす部分に新たな計算を挿入
– を満たすものは部分冗長から冗長に→除去可能
![Page 17: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/17.jpg)
a+b
a+b
a+b
a+b
a+b aa+b
a
Local Boolean Properties.ANTLOC is TRUE for nodes 6,7,8,9; FALSE elsewhere.COMP is TRUE for nodes 6,7,8,9; FALSE elsewhere.TRANSP is FALSE for node 4; TRUE elsewhere.
Global Boolean Properties(obtained by resolution of Boolean Systems).ANTIN is FALSE for nodes 1,2,4; TRUE elsewhere.AVOUT is TRUE for nodes 6,7,8,9; FALSE elsewhere.PAVIN is FALSE for node 1; TRUE elsewhere.
Value of PPIN and PPOUT (obtained by resolution of Boolean Systems).
PPIN is FALSE for nodes 1,2,3,4; TRUE elsewhere.
PPOUT is FALSE for nodes 1,2,8,9; TRUE elsewhere.
Computation of INSERT.
INSERT is TRUE for nodes 3,4; FALSE elsewhere.
Insertion and Suppression of Computations.ANLOC . PPIN is TRUE for nodes 6,7,8,9;FALSE elsewhere.
![Page 18: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/18.jpg)
Lazy Code Motion
M2 小川健一
![Page 19: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/19.jpg)
従来の PRE 技術• PRE のアルゴリズムはデータフロー方程式を
分析する• データは前向きの流れと、後向きの流れ、両
方向分析が主流 →しかし最もよい手法でも O(n^2)• 1979 年ビットベクトルアルゴリズムが生み出
される( Morel 等) →単方向分析に変化 →計算量が O(n log n) に
![Page 20: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/20.jpg)
予備変数を利用し、出来るだけ前で計算(Busy な手法 )
PRE のアルゴリズムのひとつ• Code Motion→ 不必要な再計算を避け効率のよい改良を行う技術
問題点・過剰なレジスタプレッシャーを引き起こす →予備変数を長時間保持してしまう解決策
・ lazy な方法を用いる ( 安全かつ適当なところで計算 )
![Page 21: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/21.jpg)
Busy Code Motion の特徴• 単方向分析 →計算量は O(n log n)• コードの安全性の保ちながら改良 → 2 つの集合 (D-safe,Earliest) を求めてコード移
動を• 出来るだけ前で計算を行う ○→冗長な計算の多くを削除できる ×→ レジスタを長く占有する可能性がある →不必要なコード移動の存在
![Page 22: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/22.jpg)
Code Motion (Busy) の具体例
a=x+y
a=x+y
a=x+y
1
23
4 5
6
7
h=x+y
a=h
a=h
a=h
1
23
4 5
6
7
ブロック1から7まで変数 h,x,y がレジスタを占有
![Page 23: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/23.jpg)
Lazy Code Motion の特徴• 単方向分析 →計算量は O(n log n)• コードの安全性の保ちながら改良 →4つの集合 (D-safe,Earliest,Latest,Isolated) を求めてコード移動を• 可能な限り遅く計算を行う ○→レジスタプレッシャーの軽減 →不必要なコードを除去できる ×→ 正確な除去が出来ない
![Page 24: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/24.jpg)
Code Motion (Lazy) の具体例
a=x+y
a=x+y
a=x+y
1
3
4 5
6
7
a=x+y
h=x+ya=h h=x+y
a=h
1
3
4 5
6
7
レジスタ占有時間を減らすことに成功
2 2
![Page 25: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/25.jpg)
Code Motion Algorithm0. 危険辺の除去1.v を変数、 t を計算式、 G(N,E,s,e) をフローグラフ
とする2.Used 、 Transp を求める3.D-Safe 、 Earliest を求める( busy なら 4 、 Lazy
なら 5 へ)4. コードの変形を行う → Busy5.Delay を求める6.Isolated 、 Latest を求める7.OCP 、 RO を求めコードの変形を行う → Lazy
![Page 26: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/26.jpg)
安全なポイントをさがすために
• 危険辺 (Critical Edge) の除去
a=x+y
b=x+y
h=x+ya=h
b=h
h=x+y
1 2
3
1 2
3
4
![Page 27: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/27.jpg)
Used Transp の計算• 両値ともに T か F で表現されるため、ノード1つに
必要な情報量は 1 ビット• Used :対象式 t がノード N に含まれていれば True• Transp :透過性の意、対象式が x+y の時にノード N
に x や y への代入文が含まれていないと True
Used(n,t´) = t´ ∈ SubTerms(t)Transp(n,t´) = v ∈ Var(t´)
![Page 28: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/28.jpg)
集合計算1
![Page 29: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/29.jpg)
The Busy Code Motion Transformation
• 対象計算式 t のために新たな変数 h を作成
• D-Safe と Earliest を満たすノード全ての入口部分に h = t を挿入
• 全ての対象計算式 t を h で置換する
![Page 30: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/30.jpg)
集合計算2
![Page 31: Global Optimization by Suppression of Partial Redundancies について](https://reader031.fdocuments.net/reader031/viewer/2022020417/56814374550346895daff488/html5/thumbnails/31.jpg)
The Lazy Code Motion Transformation
• 対象計算式 t のために新たな変数 h を作成
• OCP を満たすノード全ての入り口部分に h = t を挿入
• RO を満たすノード全てに計算式 t を h で置換OCP = { n|Latest(n)∧ ¬ Isolated(n) }
RO = { n|Used(n)∧ ¬ (Latest(n)∧Isolated(n)) }
OCP ( optional computation point ) RO ( redundant occurrence )