Top Banner
Integer Linear Programming to Solve Scheduling Problem C. F. Lin
19

ILP Scheduling

Jan 23, 2017

Download

Documents

Chris Lin
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ILP Scheduling

Integer Linear Programming to Solve Scheduling Problem

C. F. Lin

Page 2: ILP Scheduling

Background

• To compile behaviour model to digit circuit with optimized cost and performance

• Example: to find Fibonacci number #5

input A = 1, B = 1output Cloop(3){C = A + BB = CA = B}

A

B

+

+

+

Cloop 0 loop 1 loop 2

Behavior modelCircuit with 3 adders

1

1 2

1

3

2

5

Page 3: ILP Scheduling

Trade‐off between Cost and Performance

• Cost: adder, multiplier, register…• Performance: clock cycles to finish• Example: the followings are functionally equivalent

Combinational cirtuit3 adders, 1 cycle

A

B

+

+

+

C+

A

BC

Sequential Circuit1 adders, 2 register, 3 cycles

Page 4: ILP Scheduling

• Abstract the problem to graph + scheduling problem

Basic Operation Rescheduling

+

x

A B C D

+

+

x

Cycle 0

Cycle 1

Cycle 2

Cycle 3

Cycle 4

Cycle 5

E

+F

2 add, 2 mul, 5 cycles

+

x

A B C D

+

+ x

E

+

1 add, 1 mul, 5 cycles

optimized

F

Page 5: ILP Scheduling

Looped Operation Rescheduling

A

B

Cycle 0

Cycle 1

Cycle 2

Cycle 3

Cycle 4

Cycle 5

Loop Expansion

C

D E

G

F

A0

B0

C0

D0

F0

E0

G0

Cycle 6

Cycle 7

Cycle 8

A0

B0

C0

D0

F0

E0

G0

Page 6: ILP Scheduling

Advanced Tech: Folding Loops

Cycle 0

Cycle 1

Cycle 2

Cycle 3

Cycle 4

Cycle 5

A0

B0

C0

D0

F0

E0

G0

A1

B1

C1

D1

F1

E1

G1

Cycle 6

Cycle 7

Cycle 8

A2

B2

C2

D2

F2

E2

G2

A3

B3

D3

F3

E3

Page 7: ILP Scheduling

Project Flow

A

B

C

D E

GF

DS

A0

B0

C0

D0

F0

E0

G0

Opt

SimFunctional Equivalent

Verification 

C++

Verilog Syn

Page 8: ILP Scheduling

Goal

• To write a program to optimize the given operation dependency

• cost = #cycle * (#adder + #multiplier)• Get minimized cost

Page 9: ILP Scheduling

Strategy

A

B

Cycle 0

Cycle 1

Cycle 2

Cycle 3 C

D E

G

F

A

B

C

D

E

G

F

A B C D E F G

• Move nodes around• Apply different folding level• Calculate cost

Page 10: ILP Scheduling

Strategy• Brute Force – all node combination• Constraint random – randomly put nodes in the valid range

Cycle 0

Cycle 1

Cycle 2

Cycle 3

A B C D E F G

Page 11: ILP Scheduling

Data Structure

• OP – each nodeOP

‐ begin‐ end+ parents <vector <vector <OP *>>>+ children <vector <vector <OP *>>>

A

B

C

D E

GF

in0 in1 in2 in3

DparentsC

DchildrenC

F

beginend

1

1Aparents

children C

Bbeginend

12

0

1

2

3

Bparents

childrenF

Cbeginend

33

Page 12: ILP Scheduling

Data Structure

• OP_LIST: chain all OPs up

OP_LIST

+runSchedule()‐ runILP_RD()‐ runILP_BF()

vector<OP *>

A

B

C

D E

GF

in0 in1 in2 in3

0

1

2

3

Page 13: ILP Scheduling

Approach

cycles

#add + 2#mul

Optimized solution!!

Approach from #adder + #multiplier

Page 14: ILP Scheduling

• Calculate reachable range for each node• Determine minimal folding level and (#add, #mul) to begin with

A0

B0

C0

D0

F0

E0

G0

A1

B1

C1

D1

F1

E1

G1

Algorithm

Cycle 0

Cycle 1

Cycle 2

Cycle 3

A B C D E F G

Page 15: ILP Scheduling

Algorithm• Schedule nodes recursively under constraint2 folding level, 3 adders, and 1 multiplier

A0

B0

C0

D0

F0

G0

E0

Cycle 0

Cycle 1

Cycle 2

Cycle 3

A0

B0

C0

D0

F0

G0

E0Cycle 4

Cycle 5

A solution under (#fold: 2, #add: 3, #mul: 1)

Page 16: ILP Scheduling

• Trade‐off between folding level and #adder

Algorithm

Cycle 0

Cycle 1

Cycle 2

Cycle 3

A0

B0

C0

D0

F0

G0

E0

Cycle 4

Cycle 5

A solution under (#fold: 3, #add: 2, #mul: 1)

A0

B0

C0

D0

F0

G0

E0

Cycle 7

Cycle 8

Page 17: ILP Scheduling

Rescheduled Result 1

20 cycles, 2 adds, 2 muls 14 cycles, 2 adds, 4 muls

Page 18: ILP Scheduling

Rescheduled Result 2

8 cycles, 5 adds, 16 muls

Page 19: ILP Scheduling

Rescheduled Result 2

17 cycles, 2 adds, 3 muls