Optimal Instruction Scheduling Using Integer Programming

Optimal Instruction Scheduling Using Integer Programming

Optimal Instruction Scheduling Using Integer Programming Kent Wilken Jack Liu Mark He ernan Department of Electrical and Computer Engineering UniversityofCalifornia,Davis, CA 95616 fwilken,jjliu,[email protected] Abstract { This paper presents a new approach to 1.1 Lo cal Instruction Scheduling local instruction scheduling based on integer programming The lo cal instruction scheduling problem is to nd a min- that produces optimal instruction schedules in a reasonable imum length instruction schedule for a basic blo ck. This time, even for very large basic blocks. The new approach instruction scheduling problem b ecomes complicated (inter- rst uses a set of graph transformations to simplify the data- esting) for pip elined pro cessors b ecause of data hazards and dependency graph while preserving the optimality of the nal structural hazards [11 ]. A data hazard o ccurs when an in- schedule. The simpli edgraph results in a simpli ed integer struction i pro duces a result that is used bya following in- program which can be solved much faster. A new integer- struction j, and it is necessary to delay j's execution until programming formulation is then applied to the simpli ed i's result is available. A structural hazard o ccurs when a graph. Various techniques are used to simplify the formu- resource limitation causes an instruction's execution to b e lation, resulting in fewer integer-program variables, fewer delayed. integer-program constraints and fewer terms in some of the The complexity of lo cal instruction scheduling can de- remaining constraints, thus reducing integer-program solu- p end on the maximum data-hazard latency which occurs tion time. The new formulation also uses certain adap- among the target pro cessor's instructions. In this pap er, tively addedconstraints (cuts) to reduce solution time. The latency is de ned to be the di erence between the cycle proposed optimal instruction scheduler is built within the in which instruction i executes and the rst cycle in which Gnu Compiler Col lection (GCC) and is evaluated experi- data-dep endent instruction j can execute. Note that other mental ly using the SPEC95 oating point benchmarks. Al- authors de ne latency (delay) to b e the cycle di erence mi- though optimal scheduling for the target processor is consid- nus one, e.g., [2 , 17 ]. We prefer the present de nition b e- eredintractable, al l of the benchmarks' basic blocks areop- cause it naturally allows write-after-read data dep endencies timal ly scheduled, including blocks with up to 1000 instruc- to b e represented by a latency of 0 (write-after-read dep en- tions, while total compile time increases by only 14%. dent instructions can execute in the same cycle on a typical multiple-issue pro cessor, b ecause the read o ccurs b efore the 1 Intro duction write within the pip eline). Instruction scheduling for a single-issue pro cessor with Instruction scheduling is one of the most imp ortant compiler a maximum latency of two is easy. Instructions can be optimizations b ecause of its role in increasing pip eline uti- optimally scheduled in p olynomial time following the ap- lization. Conventional approaches to instruction scheduling proach prop osed by Bernstein and Gertner [2 ]. Instruc- are based on heuristics and may pro duce schedules that are tion scheduling for more complex pro cessors is hard. No sub optimal. Prior work has considered optimal instruction p olynomial-time algorithm is known for optimally schedul- scheduling, but no approach has been prop osed that can ing a single-issue pro cessor with a maximum latency of three optimally schedule a large numb er of instructions in reason- or more [2 ]. Optimal scheduling is NP-complete for realistic able time. This pap er presents a new approachtooptimal multiple-issue pro cessors [3 ]. Because optimal instruction instruction scheduling which uses a combination of graph scheduling for these more complex pro cessors is considered transformations and an advanced integer-programming for- intractable, pro duction compilers use sub optimal heuristic mulation. The new approach pro duces optimal schedules approaches. The most common approachislist scheduling, in reasonable time even for scheduling problems with 1000 where instructions are represented as no des in a directed instructions. acyclic data-dep endency graph (DAG) [15 ]. A graph edge represents a data dep endency, an edge weight represents the This research was supp orted by Equator Technologies, Men- tor Graphics' Emb edded Software Division, Microsoft Research, the corresp onding latency, and each DAG no de is assigned a National Science Foundation's CCR Division under grant #CCR- priority. Critical-path list scheduling is a common variation, 9711676, and by the University of California's MICRO program. where an instruction's priority is based on the maximum- AG from the no de representing Permission to make digital or hard copies of all or part of this work for length path through the D personal or classroom use is granted without fee provided that copies the instruction to anyleafnode[15]. While critical-path list Permissionare not madeto make or distributed digital or for hard profit copies or commercial of all or advantage part of thisand thatwork for heduling is usually e ective, it can pro duce sub optimal re- personalcopies or bear classroom this notice use and is the granted full citation without on the fee first provided page. To copy that copies sc en for small scheduling problems. Consider the DAG are nototherwise, made or or distributed republish, to forpost profit on servers or commercial or to redistribute advantage to lists, and that sults ev en from [17 ], where each edge is lab eled with copiesrequires bear thisprior notice specific and permission the full and/or citation a fee. on the first page. To copy in Figure 1, tak PLDI 2000, Vancouver, British Columbia, Canada. its latency and each no de is lab eled with its critical-path otherwise,Copyright or republish,2000 ACM 1-58113-199-2/00/0006to post on servers or$5.00. to redistribute to lists, requires prior specific permission and/or a fee. PLDI 2000, Vancouver, British Columbia, Canada. Copyright 2000 ACM 1-58113-199-2/00/0006…$5.00. 121 us the approach do es not app ear practical for large 222 onds). Th heduling problems. Chang, Chen and King [5] A B C instruction sc teger programming formulation that combines 2 2 22 prop ose an in instruction scheduling with lo cal register allo cation. 0 0 lo cal D E Exp erimental results are given for one simple 10-instruction example whichtakes 20 minutestosolve optimally. These results suggest that the approach has very limited practical- Figure 1: Simple example where critical-path list scheduling ity. can pro duce a sub optimal schedule. Although prior work using integer programming has pro- duced limited success for optimal instruction scheduling, in- teger programming has b een used successfully to optimally priority. For this DAG, no des A, B and C all have the same solvevarious other compiler optimization problems, includ- priority,sothescheduler can arbitrarily select the order of ing array dep endence analysis [19 ], data layout for paral- these instructions. If the initial order is A, C , B or C , A, lel programs [4 ] and global register allo cation [9 ]. Inte- B , the next cycle will b e a stall b ecause the latency from B ger programming is the metho d of choice for solving many to D or from B to E is not satis ed. Other orders of A, B large-scale real-world combinatorial optimization problems and C will pro duce an optimal schedule which has no stall. in other elds [16 ], including other scheduling problems such as airline crew scheduling. This successful use of integer 1.2 Optimal Instruction Scheduling programming elsewhere suggests that improved integer pro- gramming formulations maybethekey to solving large-scale Although optimal instruction scheduling for complex pro ces- instruction scheduling problems. sors is hard in theory, in practice it maybepossibletoop- This pap er presents a new approach to optimal instruc- timally solve imp ortant instances of instruction scheduling tion scheduling based on integer programming, the rst ap- problems in reasonable time using metho ds from combinato- proach which can solve very large scheduling problems in rial optimization. Prior work has used various combinatorial reasonable time. The pap er is organized as follows. Section optimization approaches to optimally schedule instructions 2 describ es a basic integer-programming formulation for op- for complex pro cessors. However none of these approaches timal instruction scheduling, which is representativeoffor- can optimally schedule large basic blo cks in reasonable time. mulations prop osed in prior work. The material in Section Ertl and Krall [8] use constraint logic programming and 2provides the reader with background on how instruction consistency techniques to optimally schedule instructions for scheduling can be formulated as an integer programming a single-issue pro cessor with a maximum latency greater problem, and provides a basis for comparing the new integer- than two. Vegdahl [23 ] and Kessler [13 ] use dynamic pro- programming formulation. Exp erimental results in Section gramming to optimally schedule instructions. Chou and 2show that the basic formulation cannot solve large instruc- Chung [6 ] and Tomiyama et al. [22 ] use approaches that tion scheduling problems in reasonable time, which is consis- implicitly enumerate all p ossible schedules to nd an opti- tent with the results from prior work. Section 3 intro duces mal schedule. For eciency, [6 ] and [22 ] prop ose techniques a set of DAG transformations which can signi cantly sim- to prune the enumeration tree so that redundantorequiv- plify the DAG, while preserving the optimalityofthesched- alentschedules are not explicitly enumerated.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    13 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us