190 likes | 221 Views
New approach to register allocation and instruction scheduling, using DNA Computing. 2001-30593 이제형 2002-30447 최형규. DNA Computing Register Allocation. 2001-30593 이제형. Register Allocation. Compiler 의 code generation 단계에서 무한개로 가정했던 pseudo register 들을 유한개의 machine register 에 할당하는 작업
E N D
New approach to register allocation and instruction scheduling, using DNA Computing 2001-30593 이제형 2002-30447 최형규
DNA ComputingRegister Allocation 2001-30593 이제형
Register Allocation • Compiler 의 code generation 단계에서 무한개로 가정했던 pseudo register 들을 유한개의 machine register 에 할당하는 작업 • 목적 • 유한개의 machine register 로 assign 이 불가능할 경우 메모리를 불가피하게 사용하는 spill 을 최소화하여 code size 및 memory usage 를 줄임 • Move 명령의 source 와 destination 을 동일한 하나의 register 로 할당하여 move 명령의 제거(coalescing)
Graph Coloring • Map coloring 문제에서 출발. 대표적인 NP-complete 문제의 하나 • Chaitin 이 Register Allocation 을 Graph Coloring 의 범주에 끌어들여 Compiler 에 적용. 그의 algorithm 이 가장 널리 쓰이고 있음 • 현재 DNA computing 분야에서의 Graph Coloring 연구 영역 • Adleman , Lipton 등이 시도한 3-coloring 문제 • 2차 유클리드 공간에서의 4-coloring 문제
c r3 b Interference r2 e r1 a d Precolored Copy Interference Graph enter: c <- r3 a <- r1 b <- r2 d <- 0 e <- a loop: d <- d + b e <- e - 1 if e > 0 goto loop r1 <- d r3 <- c return (r1, r3 live out)
Pseudo register 에 대한 interference graph 생성 Coalescing 을 통한 graph 의 간략화 DNA encoding DNA Computing DNA computing 수행 일부 node 를 spill 해가 존재? DNA decoding 결과에 따라 register allocation 전체적인 시스템 구성
Adleman 의3-coloring Algorithm Input(T) for k = 1 to z : A: Tblue = +(T, bi), Tredor green = -(T, bi) B: Tred = +(Tred or green, ri) Tgreen = -(Tred or green, ri) C: Tgoodblue = -(Tblue, bj) D: Tgoodred = -(Tred, rj) E: Tgoodgreen = -(Tgreen, gj) F: T’ = U(Tgoodred, Tgoodblue) G: T = U(Tgoodgreen, T’) Where ek = <i, j> Output(Detect(T))
v(b, 1) i v(b, i) v(r, i) v(r, 2) v(g, i) v’(b, i) v(r, 3) v’(r, i) v’(g, i) v(b, 4) v(g, 5) e(1; b, r) 1 AACAAG CACCAG GAAGAC e(2; r, r) TTGTTC GTGGTC e(3; r, b) CTTCTG e(4; b, g) 2 AATACA CATCCA GAGGAT TTATGT GTAGGT CTCCTA 3 ACCACG CCGCCT GCAGCC TGGTGC GGCGGA CGTCGG 4 ACTAGA CGACGC GCGGCT TGATCT GCTGCG CGCCGA 5 AGCAGG CGGCGT GTAGTC TCGTCC GCCGCA CATCAG DNA coding 의 예 • node 의 coding(r,g,b 3가지 색, node 가 5개의 경우) • edge 의 coding e(i; b, b), e(i; b, r), e(i; b, g), e(i; r, b), e(i; r, r), e(i; r, g), e(i; g, b), e(i; g, r), e(i; g, g) • 생성될 수 있는 DNA 결합(brrbg)
DNA computing 단계 • 생성된 node, edge DNA 조각들을 시험관 T 에 넣음 • 하나의 edge 에 연결된 node에 대해 동일한 color 로 구성된 염색체를 걸러내고 남은 염색체를 새로운 시험관에 담음 • 모든 색깔에 대해 동일한 과정을 반복하여 새로운 시험관에 담음 • 2와 3의 과정으로 생성된 새로운 시험관의 내용물을 모두 합쳐 새로운 시험관에 담음 • 4의 결과물로 부터 새로운 edge 에 대해 1의 과정부터 반복 • 모든 edge 에 대해 위의 과정을 모두 마쳤으면, 이제 시험관에 남은 DNA 조각 중 어느것이라도 register allocation 의 조건을 만족
DNA ComputingInstruction Scheduling 2002-30447 최형규
1 2 4 4 3 1 4 6 4 5 1 7 Instruction Scheduling Program Dependency DAG Solutions • Solutions • Any topologically sorted order can be solution • Best Solution • We want best solution with least cost . . . 1 r1[r12+0] 2 r2[r12+4] 3 r1r1+r2 4 [r12,0] r1 5 r1r12+8 6 r2[r12+12] 7 r2r1+r2 analysis schedule cost = 13 11
What’s the problem? • Analysis • Program dependency DAG • O(n2), but O(n) in practice • Schedule • Finding any one solution : Easy • Finding best solution : NP-Hard problem
Hybrid Approach 1 • Make Dependency DAGs (silicon computer) • Pre-processing (silicon computer) • Make Hamiltonian graph from Dependency Graph • Solve Hamiltonian Path Problem(DNA Computer) • Get set of all valid path • Post-processing (silicon computer) • Find best solution which have least cost
1 2 4 4 1 2 3 1 3 4 6 0 6 4 4 5 1 5 7 7 PreprocessingDependency DAGHamiltonian Graph • O(n2) algorithm • for each node I { for each node j except I { if(node i and j can be schedule at same time && node i is not reachable from node j) Add bi-directional edge } } add node0 Dependency DAG Hamiltonian Graph
PostProcessing • Assumption • We can count how many kind of valid paths are in set of solutions. • If total k kind of solutions are acquired • Evaluate each kind of solutions • Evaluation time : O(n), where n is # of nodes • Total complexity • O(k*n) • But k can be n! in worst case!!!
Hybrid Approach 2 • Make Dependency DAGs (silicon computer) • Pre-processing (silicon computer) • Make Weighted-Hamiltonian-Graph from Dependency Graph • Solve Travel Salesman Problem (DNA Computer) • Get set of all valid path sorted by total cost • Post-processing (silicon computer) • Calculate cost of solutions in sorted order
1 2 1 2 4 4 4 4 3 3 1 2 0 4 6 6 4 3 4 5 5 4 1 7 7 PreprocessingDependency DAGWeighted Hamiltonian Graph • We can’t conver dependency graph into weighted hamiltonian graph w/o information loss. • Heuristic Algorithm • Almost same with previous O(n2) algorithm • Only difference is this allocate minimum weight for edges in Hamiltonian Graph. Dependency DAG Hamiltonian Graph
Solve Travel Salesman Problem 최소 해를 찾을 때까지 반복
PostProcessing • Almost same as previous Hybrid Approach 1 • But we reduces total complexity! • Hybrid Approach 1 : We should evaluate all solutions • Hybrid Approach 2 : We don’t have to evaluate all. • And in most case, • We have to evaluate only one best solution by DNA computing. • e.g. example case in this material