LIPLaboratoire

de

l'Informatique

du

Parall?lisme

Ecole

Normale

Sup?rieure

de

Lyon

Institut

IMAG

Unit

de

recherche

associ?e

au

CNRS

n

Construction

of

DO

Loops

from

Systems

of

Affine

Constraints

Jean-Fran

cois

Collard

Paul

Feautrier

Tanguy

Risset

May

Research

Report

No

Ecole

Normale

Sup?rieure

de

Lyon

All?e

d'Italie

Lyon

Cedex

France

T?l?phone

T?l?copieur

Adresses

lectroniques

lip@lip.ens-lyon.fr

-LRB-

uucp

-RRB-

Construction

of

DO

Loops

from

Systems

of

Affine

Constraints

Jean-Fran

cois

Collard

Paul

Feautrier

Tanguy

Risset

May

Abstract

Most

parallelization

techniques

for

DO

loop

nests

are

based

on

reindexation

Reindexation

yields

a

new

iteration

space

which

is

a

convex

integer

polyhedron

defined

by

a

set

of

affine

constraints

Parallel

code

generation

needs

thus

to

scan

all

the

integer

points

of

this

convex

thereby

requiring

the

construction

of

a

new

DO

loop

nest

We

detail

an

algorithm

for

this

purpose

which

relies

on

a

parametrized

version

of

the

Dual

Simplex

We

show

how

the

resulting

loop

nest

and

especially

the

loop

bounds

can

be

kept

simple

and

streamlined

so

as

not

to

reduce

the

benefits

of

parallelization

R?esum?e

La

plupart

des

techniques

de

parall?elisation

des

nids

de

boucles

DO

sont

bas?ees

sur

la

reindexation

La

reindexation

g?en?ere

un

nouvel

espace

d'it

eration

qui

est

un

poly?edre

convexe

entier

d?efini

par

un

syst?eme

d'in

equations

affines

La

g?en?eration

du

code

parall?ele

n?ecessite

donc

d'

enum?erer

tous

les

points

entiers

de

ce

convexe

ce

qui

s

obtiendra

gr

ace

a

un

nouveau

nid

de

boucles

Nous

pr?esentons

un

algorithme

construisant

ces

boucles

qui

repose

sur

une

version

param?etr?ee

du

Simplexe

Dual

Nous

montrons

comment

les

boucles

g?en?er?ees

et

en

particulier

leurs

bornes

peuvent

etre

gard?ees

simples

de

fa?con

a

obtenir

un

code

efficace

o?u

les

b?en?efices

de

la

parall?elisation

ne

soient

pas

amoindris

Mots-cl

es

parall?elisation

automatique

poly?edre

convexe

entier

g?en?eration

de

code

Construction

of

DO

Loops

from

Systems

of

Affine

Constraints

Jean-Fran

cois

Collard

Tanguy

Risset

Paul

Feautrier

LIP

MASI

Laboratory

URA

CNRS

ENS

Lyon

Universit?e

de

Versailles

All?ee

d'Italie

Avenue

des

Etats-Unis

Lyon

Cedex

Versailles

Cedex

fjfcollar,rissetg@lip.ens-lyon.fr

feautrier@masi.ibp.fr

May

Introduction

Parallel

computing

is

one

of

the

most

promising

way

to

increase

the

computational

power

available

to

scientists

Recent

experiences

on

parallel

machines

confirm

what

has

been

foreseen

the

dramatic

need

of

automation

in

parallelization

-LSB-

-RSB-

Most

parallelization

techniques

for

DO

loop

nests

are

based

on

reindexation

i.e.

on

a

change

of

basis

of

the

iteration

space

Since

the

values

of

the

new

loop

counters

will

be

enumerated

in

a

DO

loop

nest

innermost

loop

bounds

have

to

be

expressed

as

functions

of

the

outermost

ones

These

computations

must

be

exact

so

as

to

preserve

the

semantics

of

the

original

program

Furthermore

they

need

to

be

as

simple

as

possible

control

overhead

should

not

reduce

the

benefits

of

parallelization

The

problem

of

finding

loop

bounds

of

a

reindexed

loop

nest

is

tightly

connected

to

various

problems

on

integer

convex

polyhedra

-LSB-

-RSB-

Few

algorithms

have

been

designed

to

solve

this

problem

The

Fourier-Motzkin

pairwise

elimination

method

is

relevant

here

but

this

method

generates

redundant

constraints

An

interesting

alternative

for

this

particular

application

is

the

Simplex

method

A

parametrized

version

of

the

Dual

Simplex

method

has

been

developed

by

Feautrier

and

implemented

in

the

PIP

-LRB-

Parameter

Integer

Programming

-LSB-

-RSB-

-RRB-

software

Unfortunately

the

results

produced

by

the

PIP

algorithm

may

sometimes

be

more

intricate

than

necessary

In

this

paper

we

show

that

the

solution

produced

by

PIP

can

be

simplified

After

setting

the

notations

and

recalling

general

definitions

in

Section

Section

illustrates

some

program

transformations

we

are

dealing

with

in

automatic

parallelization

The

problem

of

scanning

a

polyhedron

and

the

loop

bounds

computation

algorithm

are

explained

in

Section

Section

presents

the

PIP

algorithm

and

gives

an

extensive

example

of

loop

bounds

determination

hinting

at

a

simplification

possibility

Section

formally

describes

and

proves

our

simplification

proposal

The

last

section

summarizes

our

results

and

indicates

directions

for

future

work

General

Definitions

Throughout

this

paper

arrowed

lowercase

letters

denote

column

vectors

with

integer

or

rational

entries

The

k-th

entry

of

vector

x

-LRB-

xn

-RRB-

T

is

denoted

by

x

-LSB-

k

-RSB-

or

if

there

is

no

ambiguity

xk

its

subvector

built

from

components

k

to

l

is

written

as

-LRB-

xk

xl

-RRB-

T

if

k

l

then

this

vector

is

by

convention

the

vector

of

dimension

Vector

concatenation

is

denoted

by

thus

for

example

x

-LRB-

xk

-RRB-

T

-LRB-

xk

xn

-RRB-

T

The

vector

with

appropriate

dimension

is

denoted

Furthermore

we

denote

by

o

-LRB-

resp

o

-RRB-

the

lexicographic

order

-LRB-

resp

the

strict

lexicographic

order

-RRB-

on

such

vectors

Finally

if

A

is

a

matrix

then

Aiffl

represents

the

ith

row

of

A

and

Afflj

the

jth

column

Definition

-LRB-

Structure

parameters

-RRB-

Structure

parameters

are

integer

symbolic

constants

generally

defining

array

sizes

iteration

bounds

etc.

Structure

parameters

may

be

defined

once

in

the

prologue

of

a

program

and

may

not

be

modified

elsewhere

Throughout

this

paper

the

p

structure

parameters

are

merged

into

a

pvector

z.

Definition

-LRB-

Perfect

loop

nest

-RRB-

A

perfect

loop

nest

is

a

nest

of

DO

statements

where

for

a

given

counter

lower

and

upper

bounds

are

affine

functions

of

enclosing

loop

counters

and

possibly

of

structure

parameters

Perfect

loop

nests

thus

follow

the

scheme

below

DO

-LRB-

z

-RRB-

-LRB-

z

-RRB-

DO

-LRB-

z

-RRB-

-LRB-

z

-RRB-

DO

in

lbn

-LRB-

in

z

-RRB-

ubn

-LRB-

in

z

-RRB-

S

ENDDO

ENDDO

ENDDO

Definition

-LRB-

Iteration

vector

-RRB-

For

a

given

statement

S

in

a

perfect

loop

nest

the

iteration

vector

x

is

the

vector

of

the

surrounding

loop

counters

For

instance

the

iteration

vector

of

statement

S

in

the

loop

nest

above

is

x

-LRB-

in

-RRB-

T

Definition

-LRB-

Operation

-RRB-

The

execution

of

S

for

a

given

iteration

vector

x

is

called

an

operation

denoted

by

the

pair

-LRB-

S

x

-RRB-

Definition

-LRB-

Iteration

space

-RRB-

The

iteration

space

of

a

given

statement

S

in

a

given

perfect

loop

nest

is

the

set

of

the

values

taken

by

its

iteration

vector

when

executing

the

loop

nest

Since

the

loop

nests

we

are

dealing

with

are

perfect

the

iteration

spaces

are

finite

convex

polyhedra

of

Zn

Such

polyhedra

can

always

be

defined

by

a

set

of

inequalities

such

as

D

f

x

j

x

Zn

C

x

z

b

where

C

and

are

constraint

matrices

of

size

m?n

and

m?p

respectively

and

b

is

a

constant

m-vector

This

is

equivalent

to

describing

a

polyhedron

as

the

intersection

of

a

set

of

half-spaces

Program

Transformation

Current

parallelizing

methods

are

inherited

from

automatic

systolic

design

and

transform

programs

through

basis

changes

of

iteration

spaces

These

basis

changes

are

affine

or

linear

and

usually

unimodular

transformations

In

the

case

of

unimodular

linear

transformation

-LSB-

-RSB-

vector

coordinates

-LRB-

yn

-RRB-

T

and

-LRB-

xn

-RRB-

T

respectively

in

the

old

and

new

bases

are

related

by

BBBB

xn

CCCCA

U

BBBB

yn

CCCCA

-LRB-

-RRB-

where

U

is

a

n

n

matrix

such

that

det

-LRB-

U

-RRB-

The

generated

code

will

have

to

scan

the

new

iteration

space

and

this

will

be

done

using

a

new

DO-loop

nest

To

illustrate

the

point

consider

the

following

perfect

loop

nest

parametrized

by

z

-LRB-

m

n

-RRB-

T

DO

i

m

DO

j

n

DO

k

i

j

S

ENDDO

ENDDO

ENDDO

The

iteration

space

D

-LRB-

m

n

-RRB-

is

described

by

D

-LRB-

m

n

-RRB-

f

-LRB-

i

j

k

-RRB-

T

j

-LRB-

i

j

k

-RRB-

i

m

j

n

k

i

jg

This

set

is

a

convex

polyhedron

in

which

can

be

written

as

D

-LRB-

m

n

-RRB-

f

x

j

x

C

x

z

b

-LRB-

-RRB-

with

x

B

i

j

k

CA

C

BBBBBBB

CCCCCCCA

BBBBBBB

CCCCCCCA

b

BBBBBBB

CCCCCCCA

We

give

below

two

examples

of

such

basis

changes

Example

Loop

interchange

Assume

data

dependencies

allow

the

loop

nest

above

to

be

transformed

using

loop

interchange

while

preserving

its

semantics

This

transformation

would

rewrite

the

loop

with

counters

in

the

order

k

j

i

instead

of

i

j

k

DO

k

lbk

-LRB-

m

n

-RRB-

ubk

-LRB-

m

n

-RRB-

DO

j

lbj

-LRB-

m

n

k

-RRB-

ubj

-LRB-

m

n

k

-RRB-

DO

i

lbi

-LRB-

m

n

k

j

-RRB-

ubi

-LRB-

m

n

k

j

-RRB-

S

ENDDO

ENDDO

ENDDO

In

this

case

the

corresponding

matrix

U

is

U

B

CA

Example

the

systolic

point

of

view

The

goal

of

the

systolic

method

is

to

find

a

new

iteration

space

basis

in

which

the

first

coordinate

-LRB-

s

-RRB-

represent

the

execution

time

or

schedule

of

the

and

the

remaining

coordinate

-LRB-

s

-RRB-

represent

the

virtual

processor

address

on

which

this

operation

is

to

be

executed

In

this

new

nest

the

loops

on

time

have

to

be

executed

sequentially

but

not

the

loops

on

space

The

loop

above

can

for

example

be

eventually

expressed

with

respect

to

counters

-LRB-

t

x

y

-RRB-

T

where

t

is

the

schedule

and

-LRB-

x

y

-RRB-

the

coordinates

of

virtual

processors

on

a

two-dimensional

grid

The

code

generated

by

such

a

transformation

will

look

like

see

why

this

time

may

be

multidimensional

see

-LSB-

-RSB-

DO

t

lbt

-LRB-

m

n

-RRB-

ubt

-LRB-

m

n

-RRB-

DOALL

-LRB-

x

lbx

-LRB-

m

n

t

-RRB-

ubx

-LRB-

m

n

t

-RRB-

-RRB-

DOALL

-LRB-

y

lby

-LRB-

m

n

t

x

-RRB-

uby

-LRB-

m

n

t

x

-RRB-

-RRB-

S

ENDDOALL

ENDDOALL

ENDDO

Methods

of

dependence

analysis

-LSB-

-RSB-

and

schedule

computation

-LSB-

-RSB-

are

now

well

understood

and

provide

an

appropriate

matrix

U

In

the

transformation

examples

above

the

parallelizer

has

to

compute

new

loop

bounds

and

this

is

all

but

obvious

The

rest

of

this

paper

concentrates

on

the

algorithm

for

this

computation

and

on

the

application

of

the

PIP

algorithm

to

this

purpose

The

Polyhedron

Scanning

Problem

Our

motivation

is

to

show

how

loop

bounds

can

be

computed

algorithmically

from

systems

of

affine

constraints

The

DO

loop

nest

obtained

will

scan

once

and

only

once

all

the

integer

points

of

the

corresponding

polyhedron

The

Input

The

input

of

our

computation

is

a

polyhedron

D

-LRB-

z

-RRB-

expressed

in

the

original

basis

as

a

set

of

m

inequations

D

-LRB-

z

-RRB-

f

x

j

C

x

z

b

-LRB-

-RRB-

where

C

and

are

constraint

matrices

of

size

m?n

and

m?p

respectively

and

b

is

a

constant

m-vector

This

expression

of

polyhedron

D

-LRB-

z

-RRB-

is

obtained

by

parsing

the

program

text

and

writing

two

inequalities

lbk

ik

ubk

per

loop

Observe

that

one

may

still

construct

D

-LRB-

z

-RRB-

if

the

lower

-LRB-

resp

upper

-RRB-

bound

involves

ceiling

and

maximum

-LRB-

resp

floor

and

minimum

-RRB-

operators

In

that

case

there

will

be

more

inequalities

than

in

the

simple

case

The

Output

The

result

must

be

a

loop

nest

L

DO

DO

xn

an

bn

S

ENDDO

ENDDO

whose

iteration

vector

is

x

in

the

new

basis

and

which

enumerates

the

integer

points

in

D

-LRB-

z

-RRB-

in

lexicographic

order

with

respect

to

the

new

coordinate

system

We

have

to

decide

whether

D

-LRB-

z

-RRB-

if

empty

and

if

not

generate

loop

L.

L

is

not

a

perfect

loop

nest

as

defined

in

Section

for

a

given

counter

xk

both

lower

and

upper

bounds

follow

the

requirements

below

Bounds

may

be

affine

functions

of

xk

and

z

Bounds

may

be

ceiling/floor

functions

of

expressions

Bounds

may

be

maxima/minima

of

or

expressions

Thus

the

output

is

a

list

of

bounds

first

the

bounds

of

the

outermost

counter

then

the

bounds

on

as

a

function

of

the

structure

parameters

plus

and

so

on

for

all

entries

in

x.

The

Algorithm

The

basic

method

has

been

presented

in

-LSB-

-RSB-

The

first

question

is

to

know

how

one

can

exactly

scan

the

integer

points

of

D

-LRB-

z

-RRB-

that

is

to

build

the

L

loop

nest

The

method

proceeds

by

constructing

n

polyhedra

Dk

-LRB-

xk

z

-RRB-

f

-LRB-

xk

xn

-RRB-

T

j

C

x

z

b

for

k

n

Obviously

D

-LRB-

z

-RRB-

-LRB-

z

-RRB-

Let

lk

-LRB-

xk

z

-RRB-

min

o

Dk

-LRB-

xk

z

-RRB-

-LRB-

-RRB-

uk

-LRB-

xk

z

-RRB-

max

o

Dk

-LRB-

xk

z

-RRB-

-LRB-

-RRB-

Note

that

we

use

PIP

to

compute

these

lexicographic

extrema

but

the

algorithm

given

here

is

independant

of

PIP

We

assert

that

the

bounds

of

the

k-th

loop

are

ak

l

lk

-LRB-

xk

z

-RRB-

-LSB-

-RSB-

m

bk

b

uk

-LRB-

xk

z

-RRB-

-LSB-

-RSB-

c

Proof

Let

x

be

an

integer

point

in

D

-LRB-

z

-RRB-

For

all

k

-LRB-

xk

xn

-RRB-

T

is

an

element

of

Dk

-LRB-

xk

z

-RRB-

As

a

consequence

lk

-LRB-

xk

z

-RRB-

o

-LRB-

xk

xn

-RRB-

To

uk

-LRB-

xk

z

-RRB-

which

implies

lk

-LRB-

xk

z

-RRB-

-LSB-

-RSB-

xk

uk

-LRB-

xk

z

-RRB-

-LSB-

-RSB-

which

says

in

effect

that

xk

is

within

the

bounds

of

the

k-th

loop

by

the

properties

of

the

floor

and

ceiling

functions

Conversely

let

x

be

an

iteration

vector

of

the

loop

nest

Dn

-LRB-

xn

z

-RRB-

is

a

one

dimensional

polyhedra

Obviously

ln

-LRB-

xn

z

-RRB-

xn

un

-LRB-

xn

z

-RRB-

which

implies

by

convexity

that

xn

Dn

-LRB-

xn

z

-RRB-

which

is

equivalent

to

saying

that

x

D

-LRB-

z

-RRB-

As

a

consequence

we

have

proved

that

the

loop

nest

L

scans

all

integer

points

of

D

-LRB-

z

-RRB-

and

nothing

but

integer

points

of

D

-LRB-

z

-RRB-

We

may

in

fact

prove

a

more

precise

result

The

result

above

would

still

be

true

if

we

enlarged

arbitrarily

the

bounds

of

all

loops

but

the

last

one

The

effect

would

be

that

most

of

the

time

the

bounds

for

the

xn

loop

would

be

undefined

the

end

result

being

that

only

the

proper

iterations

would

be

executed

The

scheme

above

does

not

suffer

from

this

waste

of

processing

power

Let

Pk

-LRB-

z

-RRB-

be

the

projection

of

D

-LRB-

z

-RRB-

on

the

space

of

the

first

k

loop

counters

Pk

-LRB-

z

-RRB-

f

-LRB-

xk

-RRB-

T

j

xn

C

x

z

b

It

is

well

known

that

all

Pk

-LRB-

z

-RRB-

are

convex

polyhedra

Obviously

Pn

-LRB-

z

-RRB-

D

-LRB-

z

-RRB-

We

assert

that

the

first

k

loops

of

L

scan

Pk

-LRB-

z

-RRB-

Proof

The

proof

that

all

points

of

Pk

-LRB-

z

-RRB-

are

visited

by

the

loop

nest

is

exactly

the

same

as

above

The

proof

of

the

reciprocal

is

by

recurrence

on

k

The

property

is

obvious

for

k

since

-LRB-

z

-RRB-

is

one

dimensional

and

convex

Suppose

the

property

is

true

up

to

k

Let

-LRB-

xk

-RRB-

T

be

a

valid

iteration

vector

By

definition

of

a

loop

nest

so

is

-LRB-

xk

-RRB-

T

By

the

induction

hypothesis

-LRB-

xk

-RRB-

T

Pk

-LRB-

z

-RRB-

As

a

consequence

Dk

-LRB-

z

-RRB-

is

not

empty

and

lk

-LRB-

xk

z

-RRB-

and

uk

-LRB-

xk

z

-RRB-

are

well

defined

Both

-LRB-

xk

-RRB-

T

lk

-LRB-

xk

-RRB-

and

-LRB-

xk

-RRB-

T

uk

-LRB-

xk

-RRB-

belong

to

D

-LRB-

z

-RRB-

and

so

does

by

convexity

all

y

-LRB-

-RRB-

-LSB-

-LRB-

xk

-RRB-

T

lk

-LRB-

xk

-RRB-

-RSB-

-LRB-

-RRB-

-LSB-

-LRB-

xk

-RRB-

T

uk

-LRB-

xk

-RRB-

-RSB-

for

Now

since

lk

-LRB-

xk

-RRB-

-LSB-

-RSB-

xk

uk

-LRB-

xk

-RRB-

-LSB-

-RSB-

there

exists

a

value

of

such

that

y

-LRB-

-RRB-

-LSB-

k

-RSB-

xk

Since

y

-LRB-

-RRB-

D

-LRB-

z

-RRB-

we

have

proved

that

-LRB-

xk

-RRB-

T

Pk

-LRB-

z

-RRB-

The

example

revisited

This

section

illustrates

the

use

of

the

Parametric

Integer

Programming

Algorithm

-LRB-

PIP

-RRB-

to

get

new

loop

bounds

after

loop

transformation

In

the

example

-LRB-

Section

-RRB-

the

first

step

consists

in

finding

the

lexical

extrema

of

-LRB-

-LRB-

m

n

-RRB-

-RRB-

f

-LRB-

k

j

i

-RRB-

T

ji

m

j

n

k

i

jg

where

m

and

n

are

structure

parameters

For

this

first

problem

structure

parameters

are

supposed

to

be

non-negative

PIP

has

to

be

called

twice

-LRB-

once

for

upper

bounds

and

once

for

lower

bounds

in

any

order

-RRB-

The

result

is

B

CA

o

B

k

j

i

CA

o

B

m

n

n

m

CA

-LRB-

-RRB-

From

the

definition

of

lexical

ordering

we

know

that

this

entails

k

m

n

We

can

not

however

deduce

anything

about

i

or

j

from

the

above

result

The

second

problem

is

-LRB-

k

-LRB-

m

n

-RRB-

-RRB-

f

-LRB-

j

i

-RRB-

T

ji

m

j

n

k

i

jg

This

yields

the

following

bounds

on

j

if

k

m

then

if

k

m

n

then

else

k

m

else

j

-LRB-

-RRB-

and

j

-LRB-

if

-LRB-

k

m

n

-RRB-

then

else

n

-RRB-

-LRB-

-RRB-

The

bound

of

j

in

-LRB-

-RRB-

is

called

a

quast

-LRB-

for

quasi

affine

solution

tree

-RRB-

These

expressions

are

very

intricate

because

as

we

have

said

earlier

they

include

information

both

on

the

j

loop

and

on

the

k

loop

They

can

be

simplified

by

noticing

that

k

m

n

implies

that

k?m?n

is

never

true

PIP

has

a

mechanism

for

doing

that

The

context

is

a

set

of

constraints

on

the

parameters

which

are

used

to

simplify

-LRB-

if

possible

-RRB-

expressions

such

as

-LRB-

-RRB-

above

If

we

have

k

m

n

as

context

the

new

result

is

-LRB-

if

-LRB-

m

k

-RRB-

then

else

k

m

-RRB-

j

n

-LRB-

-RRB-

The

last

problem

is

-LRB-

j

k

-LRB-

m

n

-RRB-

-RRB-

fiji

m

j

n

k

i

jg

We

may

use

k

m

n

and

j

n

as

context

but

we

can

not

use

the

lower

bound

of

j

in

-LRB-

-RRB-

since

it

is

not

in

the

format

of

a

linear

constraint

The

solution

for

i

is

then

if

j

k

then

else

if

m

k

j

then

k

j

else

-RRB-

i

if

m

k

j

then

m

else

-LRB-

-RRB-

Had

our

program

been

smarter

it

could

have

noticed

that

-LRB-

-RRB-

is

equivalent

to

max

-LRB-

k

m

-RRB-

j

-LRB-

-RRB-

which

implies

j

and

j

k

m.

Using

these

two

constraints

as

context

would

have

given

if

j

k

then

else

k

j

i

m

-LRB-

-RRB-

There

again

the

lower

bound

is

max

-LRB-

k

j

-RRB-

Is

this

a

general

property

From

the

run-time

point

of

view

one

may

say

that

the

computation

of

the

max

in

-LRB-

-RRB-

is

no

easier

than

computation

of

the

if

in

-LRB-

-RRB-

That

is

true

but

the

point

is

not

computation

time

but

useless

bound

intricacy

such

as

for

i

in

-LRB-

-RRB-

However

the

validity

of

such

a

transformation

is

by

no

means

obvious

In

-LRB-

-RRB-

the

two

inequations

were

j

j

k

m

-LRB-

-RRB-

These

inequations

were

valid

on

very

specific

domains

-LRB-

respectively

m

k

and

m

k

-RRB-

Extension

to

the

entire

space

remains

to

be

justified

The

intuition

is

that

this

extension

is

valid

for

convex

domains

according

to

this

intuition

a

convex

polyhedron

is

defined

by

a

system

of

inequalities

which

is

satisfied

by

every

point

included

in

it

Thus

every

point

-LRB-

k

j

-RRB-

is

such

that

j

j

k?m

which

implies

that

j

max

-LRB-

k?m

-RRB-

-LRB-

see

Fig.

where

the

two

equations

of

-LRB-

-RRB-

are

drawn

-RRB-

However

one

should

note

how

error-prone

this

intuition

may

be

Suppose

the

lower

bound

on

j

had

been

defined

by

-LRB-

see

Fig.

-RRB-

j

if

-LRB-

m

k

-RRB-

then

if

-LRB-

k

m

-RRB-

then

k

else

k

m

else

-LRB-

-RRB-

This

is

equivalent

to

the

following

three

equations

with

their

respective

domains

kjm

k-m

Figure

One

can

take

the

maximum

of

the

two

equations

m

k

k

m

j

k

m

k

k

m

j

k

m

m

k

j

Although

this

quast

is

perfectly

correct

since

it

describes

the

same

lower

bound

as

-LRB-

-RRB-

the

first

equation

on

j

-LRB-

j

k

-RRB-

implies

that

the

lower

bound

ca

n't

be

simplified

as

max

-LRB-

k

m

k

-RRB-

In

fact

this

third

equation

is

unsuitable

because

the

corresponding

line

cuts

through

the

polyhedron

In

the

terminology

of

-LSB-

-RSB-

the

hyperplane

fjjj

kg

is

not

a

supporting

plane

of

the

polyhedron

The

key

remark

is

that

the

solutions

given

by

PIP

will

never

cut

the

polyhedron

Parametric

Integer

Programming

Our

problem

is

now

to

compute

the

lexicographical

minimum

in

-LRB-

-RRB-

or

maximum

in

-LRB-

-RRB-

The

problems

are

easily

seen

to

be

linear

programming

problems

with

two

differences

ffl

the

cost

function

is

the

lexicographic

order

ffl

parameter

values

are

generally

unknown

PIP

handles

these

two

We

will

briefly

describe

the

PIP

algorithm

but

the

interested

reader

will

find

a

more

complete

description

in

-LSB-

-RSB-

furthermore

handles

integer

problems

thanks

to

the

Gomory

algorithm

-LSB-

-RSB-

This

part

of

the

algorithm

is

not

described

here

kjm

k-mj

Figure

but

not

the

maximum

of

these

three

Suppose

that

we

want

the

lexicographic

of

D

-LRB-

z

-RRB-

z

is

the

vector

of

structure

parameters

submited

to

the

context

conditions

D

-LRB-

z

-RRB-

is

a

convex

polyhedron

whose

points

are

non

negative

which

can

be

described

as

D

-LRB-

z

-RRB-

f

x

j

C

x

z

c

x

-LRB-

-RRB-

PIP

Algorithm

In

the

Dual

Simplex

algorithm

the

problem

is

solved

by

a

succession

of

variable

changes

until

we

reach

a

stopping

condition

-LRB-

to

be

specified

later

-RRB-

Each

iteration

l

changes

xl

into

xl

by

an

affine

invertible

Since

this

transformation

is

invertible

we

will

express

xl

as

a

function

of

xl

so

as

to

be

able

to

replace

xl

by

xl

in

-LRB-

-RRB-

Furthermore

since

this

transformation

itself

will

change

from

iteration

to

iteration

it

should

also

be

subscripted

with

l

We

can

sum

this

up

with

the

following

relation

xl

Al

xl

z

al

-LRB-

-RRB-

where

Al

and

are

j

x

j

j

x

j

and

j

x

j

j

z

j-matrices

respectively

and

al

is

an

j

xj-vector

Initially

and

are

respectively

the

unit

and

zero-matrices

is

and

x.

Moreover

one

should

note

that

this

basis

change

is

such

that

problems

can

be

transformed

into

minimum

ones

by

a

simple

trick

which

is

described

in

-LSB-

-RSB-

such

as

xl

always

denote

the

lth

element

of

a

sequence

This

convention

does

not

interfere

with

the

power

function

since

the

latter

is

never

used

in

this

paper

ffl

xl

D

-LRB-

z

-RRB-

-RRB-

xl

ffl

xl

and

xl

differ

in

only

one

entry

because

each

Parametric

Dual

Simplex

Algorithm

iteration

step

changes

one

and

only

one

basis

variable

Thus

D

-LRB-

z

-RRB-

is

D

-LRB-

z

-RRB-

fAl

xl

z

al

Al

xl

z

al

Cl

xl

z

cl

-RRB-

-LRB-

-RRB-

where

Cl

and

are

the

m

j

xj

and

m

j

zj-matrices

derived

from

C

and

at

iteration

l

We

may

consider

the

m

j

xj-vector

tl

-LRB-

z

-RRB-

z

al

cl

-LRB-

-RRB-

and

Al

and

Cl

as

two

blocks

of

an

-LRB-

m

j

xj

-RRB-

j

xj

matrix

Sl

Sl

Al

Cl

-LRB-

-RRB-

-LSB-

Sl

tl

-LRB-

z

-RRB-

-RSB-

is

the

problem

tableau

in

the

sense

of

the

simplex

method

A

step

of

PIP

's

algorithm

is

described

as

follows

Determine

the

signs

of

the

components

of

tl

-LRB-

z

-RRB-

If

all

components

are

positive

then

the

solution

is

found

If

there

is

a

negative

component

tl

-LRB-

z

-RRB-

-LSB-

i

-RSB-

then

two

cases

may

occur

ffl

If

all

entries

in

the

i-th

row

of

Sl

are

negative

then

the

solution

does

not

exist

ffl

If

there

is

at

least

a

positive

entry

Slij

then

it

gives

rise

to

a

pivoting

step

and

thus

to

iteration

l

The

new

problem

tableau

is

-LSB-

Sl

tl

-LRB-

z

-RRB-

-RSB-

where

Sl

fflj

-LRB-

Slij

-RRB-

Slfflj

Sl

fflk

Slfflk

-LRB-

Slik

Sij

-RRB-

Slfflj

k

j

tl

-LRB-

z

-RRB-

tl

-LRB-

z

-RRB-

-LRB-

tli

-LRB-

z

-RRB-

Slij

-RRB-

Sfflj

In

the

remaining

case

select

a

tl

-LRB-

z

-RRB-

-LSB-

i

-RSB-

whose

sign

is

unknown

This

yields

two

new

subproblems

according

to

the

signs

Both

yield

an

-LRB-

l

-RRB-

th

iteration

This

separation

has

a

crucial

consequence

there

wo

n't

be

one

and

only

one

solution

but

a

binary

tree

whose

nodes

are

predicates

with

respect

to

the

parameters

and

whose

leaves

are

either

an

affine

function

if

a

solution

exists

or

if

not

the

undefined

solution

written

as

Since

each

node

produces

two

subproblems

one

has

to

remember

the

path

taken

and

take

account

of

the

corresponding

predicates

This

is

called

the

problem

context

For

l

this

context

is

a

set

of

inequalities

on

the

parameters

when

point

of

the

step

algorithm

above

is

reached

the

first

subproblem

must

be

computed

in

the

previous

context

augmented

with

tl

-LRB-

z

-RRB-

-LSB-

i

-RSB-

Symmetrically

the

second

context

is

the

parent

's

one

plus

tl

-LRB-

z

-RRB-

-LSB-

i

-RSB-

In

the

end

each

path

in

the

tree

is

exactly

what

the

actual

simplex

algorithm

would

have

done

but

here

the

solution

Sol

-LRB-

z

-RRB-

is

expressed

as

a

function

of

the

parameters

The

entire

binary

tree

is

called

a

quasi-affine

solution

tree

or

quast

whose

leaves

are

thus

associated

with

a

domain

Domi

defined

by

the

conjunction

of

the

predicates

in

the

corresponding

path

These

domains

build

up

a

partition

of

the

problem

space

since

no

point

can

belong

to

two

different

domains

-LRB-

this

would

imply

that

one

predicate

in

the

quast

is

both

true

and

false

-RRB-

and

since

every

predicate

cuts

the

problem

space

in

two

disjoint

half-spaces

Moreover

since

the

quast

leaves

are

affine

functions

in

the

variables

they

define

hyperplanes

in

the

Zp

space

for

a

given

parameter

vector

z

A

quast

can

thus

be

regarded

as

a

multiguard

Sol

-LRB-

z

-RRB-

-LRB-

z

-RRB-

f

-LRB-

z

-RRB-

-LRB-

z

-RRB-

Domq

f

q

-LRB-

z

-RRB-

In

our

particular

case

we

are

only

interested

in

the

first

component

of

the

solution

since

it

gives

us

the

bound

of

our

loop

counter

Thus

we

obtain

BB

-LRB-

z

-RRB-

f

-LRB-

z

-RRB-

-LSB-

-RSB-

-LRB-

z

-RRB-

Domq

f

q

-LRB-

z

-RRB-

-LSB-

-RSB-

CCA

Understanding

PIP

's

behavior

The

aim

of

this

section

is

to

show

how

the

solution

-LRB-

-RRB-

in

the

example

of

section

is

found

and

thus

to

get

an

intuition

of

where

PIP

's

solution

comes

from

We

will

start

at

the

problem

i

j

a

b

and

c

are

the

variables

associated

to

's

inequations

i

j

a

m

i

b

n

j

c

i

j

k

The

initial

Simplex

tableau

is

Table

where

rows

are

labeled

with

their

respective

variables

j

i

k

m

n

j

i

a

m

i

b

n

j

c

i

j

k

Table

First

tableau

According

to

the

notations

in

-LRB-

-RRB-

and

-LRB-

-RRB-

we

have

B

CA

B

CA

Since

the

bounds

on

k

are

known

the

solution

of

has

to

be

computed

in

context

-LRB-

-RRB-

All

rows

have

non-negative

constant

terms

excepted

the

c

row

whose

constant

term

-LRB-

t

-LRB-

z

-RRB-

-RRB-

-LSB-

c

-RSB-

is

k

A

pivoting

step

is

necessary

with

entry

-LRB-

c

i

-RRB-

as

the

pivot

Variable

c

enters

the

basis

and

i

leaves

it

giving

Table

as

the

new

problem

tableau

Now

all

rows

have

non

negative

constant

terms

excepted

the

a

row

whose

constant

term

-LRB-

t

-LRB-

z

-RRB-

-RRB-

-LSB-

a

-RSB-

is

k

m

m?k

If

m?k

then

the

optimum

is

reached

The

basis

variables

are

j

and

c

whose

values

are

as

it

can

be

read

in

Table

in

their

respective

rows

Moreover

c

j

-RRB-

i

k

and

the

tentative

result

is

i

k

j

If

m

k

then

another

pivoting

step

is

necessary

Entry

-LRB-

a

j

-RRB-

is

the

new

pivot

and

variable

a

enters

the

basis

and

j

leaves

it

The

new

tableau

is

the

one

in

Table

j

c

k

m

n

j

i

a

b

c

Table

Second

tableau

a

c

k

m

n

j

i

a

b

c

Table

Third

tableau

In

the

a

row

the

term

m

k

is

necessarily

positive

Basis

variables

are

a

and

c

and

their

values

are

both

a

c

-RRB-

i

m

j

k

m

The

final

lower

bound

on

j

is

thus

-LRB-

if

-LRB-

m

k

-RRB-

then

else

k

m

-RRB-

j

-LRB-

-RRB-

We

thus

have

an

illustration

of

how

the

Parametric

Dual

Simplex

Algorithm

algorithm

finds

a

solution

through

a

sequence

of

basis

changes

it

tests

a

sequence

of

trial

solution

in

ascending

lexicographic

order

until

a

feasible

point

is

found

The

next

section

will

try

and

explain

how

this

can

be

used

for

our

purposes

Simplification

of

the

result

As

we

have

stated

in

section

we

would

like

to

replace

the

solution

given

by

PIP

-LRB-

a

quast

-RRB-

by

a

maximum

upon

the

quast

's

leaves

In

this

section

we

prove

that

this

can

be

done

safely

An

example

Consider

the

following

example

in

context

fz

g

get

the

lexicographic

minimum

of

D

fi

j

i

z

g

The

hatched

zone

in

figure

represents

the

domain

as

a

convex

polyhedron

of

space

-LRB-

z

i

-RRB-

Suppose

that

for

some

reason

one

step

of

the

algorithm

has

to

solve

the

following

problem

in

context

fz

z

z

g

thus

z

get

the

lexicographic

minimum

of

D

fi

j

i

z

g

line

d

on

Figure

We

can

see

that

the

following

solution

is

correct

-LRB-

in

context

fz

the

lexicographic

minimum

of

D

fi

j

i

z

g

is

i

-LRB-

-RRB-

zii

Figure

Domain

D

of

the

example

z

is

a

parameter

i

a

variable

But

this

solution

can

not

be

extended

to

the

complete

parameter

space

Indeed

we

do

not

have

i

for

all

points

of

the

hatched

zone

of

figure

This

situation

appears

when

the

convex

is

not

full

dimensional

-LRB-

in

this

case

we

do

not

have

a

unique

minimal

representation

for

domain

D

-LSB-

-RSB-

-RRB-

As

it

is

hard

to

affirm

that

such

domains

will

never

appear

we

will

prove

that

when

they

appear

the

solution

given

is

not

-LRB-

-RRB-

because

inequalities

such

as

i

do

not

define

domain

D

In

order

to

obtain

this

solution

we

have

taken

the

system

of

inequalities

z

z

i

z

and

we

have

solved

-LRB-

in

i

-RRB-

an

extracted

system

of

equalities

-LRB-

fz

i

zg

for

example

-RRB-

That

is

what

PIP

would

do

choose

n

good

inequalities

and

solve

the

corresponding

system

of

equalities

But

PIP

would

n't

give

solution

-LRB-

-RRB-

but

the

following

solution

-LRB-

in

context

fz

the

minimum

lexicographic

of

D

fi

j

i

z

g

is

i

z

which

can

be

extended

to

the

complete

parameter

space

The

basic

intuitive

idea

is

simple

The

Dual

simplex

algorithm

chooses

n

inequations

from

m

until

it

reaches

a

problem

P

-LRB-

z

-RRB-

such

that

the

solution

is

obvious

-LRB-

x

-RRB-

During

these

transformations

no

additional

constraint

appears

-LRB-

except

in

the

parameter

space

-RRB-

but

the

algorithm

is

doing

two

things

simultaneously

finding

which

constraints

define

the

optimum

-LRB-

i.e.

finding

the

basis

for

which

the

solution

is

x

-RRB-

and

solving

the

corresponding

system

of

n

equalities

-LRB-

because

the

solution

is

directly

given

by

the

constant

term

of

S

x

t

-LRB-

z

-RRB-

-RRB-

As

PIP

will

choose

its

inequalities

from

the

domain

constraints

-LRB-

and

not

from

the

context

constraints

-RRB-

and

as

the

solution

of

the

equality

system

will

correspond

to

a

positive

combination

of

these

equalities

-LRB-

at

least

for

the

first

variable

-RRB-

this

solution

will

be

extensible

to

the

inequalities

system

That

is

what

we

prove

in

the

next

section

Setting

the

problem

PIP

's

algorithm

finds

the

lexicographic

minimum

of

-LRB-

z

-RRB-

f

x

Zn

j

C

x

z

c

x

as

a

function

of

z

in

the

domain

f

z

j

K

z

h

called

the

context

Thus

the

general

form

of

a

parametrized

problem

solved

by

PIP

is

P

-LRB-

z

-RRB-

-LRB-

in

context

z

fK

z

h

get

the

lexicographic

minimum

of

the

domain

-LRB-

z

-RRB-

-LRB-

-RRB-

ffl

n

is

the

dimension

of

x

m

is

the

number

of

inequations

of

the

system

C

x

z

c

p

is

the

number

of

parameters

ffl

C

is

a

m

n

matrix

is

a

m

p

matrix

The

solution

Sol

-LRB-

z

-RRB-

given

by

PIP

in

the

context

is

in

the

form

of

a

multiguard

Sol

-LRB-

z

-RRB-

z

f

-LRB-

z

-RRB-

z

Domq

f

q

-LRB-

z

-RRB-

-LRB-

-RRB-

ffl

-LRB-

Domq

-RRB-

being

a

partition

of

the

context

ffl

f

i

-LRB-

z

-RRB-

being

an

affine

function

from

Zp

to

Zn

We

now

prove

the

following

proposition

Proposition

Given

a

parametrized

problem

P

-LRB-

z

-RRB-

-LRB-

-RRB-

the

solution

Sol

-LRB-

z

-RRB-

-LRB-

-RRB-

given

by

PIP

is

such

that

for

each

solution

f

i

-LRB-

z

-RRB-

the

inequation

x

-LSB-

-RSB-

f

i

-LRB-

z

-RRB-

-LSB-

-RSB-

-LRB-

-RRB-

is

a

positive

linear

combination

of

n

inequations

of

-LRB-

z

-RRB-

Proof

In

the

following

we

will

deal

with

basis

changes

Thus

it

is

important

to

know

in

which

basis

the

coordinates

of

x

are

expressed

For

the

sake

of

clarity

we

introduce

the

following

notations

ffl

-LRB-

-RRB-

is

the

original

-LRB-

canonical

-RRB-

coordinates

system

of

Zn

We

will

note

the

corresponding

canonical

basis

ffl

xl

-LRB-

xln

-RRB-

is

another

coordinate

system

of

Zn

We

will

note

Bl

the

corresponding

basis

ffl

We

will

use

the

problem

tableau

notation

-LRB-

z

-RRB-

f

j

S

t

-LRB-

z

-RRB-

-LRB-

here

S

I

C

t

-LRB-

z

-RRB-

z

c

-RRB-

ffl

The

ith

row

of

S

t

-LRB-

z

-RRB-

represents

an

expression

denoted

by

ineqi

-LRB-

z

-RRB-

ineqi

-LRB-

z

-RRB-

-LRB-

S

t

-LRB-

z

-RRB-

-RRB-

-LSB-

i

-RSB-

Siffl

ti

-LRB-

z

-RRB-

We

have

seen

in

section

that

when

solving

-LRB-

-RRB-

PIP

's

algorithm

executes

a

succession

of

steps

each

step

having

to

solve

a

problem

P

l

-LRB-

z

-RRB-

whose

form

is

P

l

-LRB-

z

-RRB-

in

context

z

fK

z

h

Kl

z

hl

get

the

lexicographic

minimum

of

the

domain

Dl

-LRB-

z

-RRB-

fAl

xl

z

al

Al

xl

z

al

Cl

xl

z

cl

g

-LRB-

-RRB-

Remind

that

we

denote

Sl

Al

Cl

tl

-LRB-

z

-RRB-

z

al

cl

We

will

show

that

at

each

step

P

l

-LRB-

z

-RRB-

has

the

following

properties

Dl

-LRB-

z

-RRB-

represents

exactly

the

points

of

-LRB-

z

-RRB-

xl

being

expressed

in

a

basis

Bl

such

that

the

expressions

of

xl

in

terms

of

are

given

by

the

left

parts

of

n

inequalities

defining

-LRB-

z

-RRB-

This

can

be

expressed

by

-LSB-

n

-RSB-

-LSB-

m

-RSB-

injective

such

that

-LSB-

n

-RSB-

xli

ineqoel

-LRB-

i

-RRB-

-LRB-

z

-RRB-

Each

line

of

Sl

xl

tl

-LRB-

z

-RRB-

is

the

expression

in

the

new

basis

of

the

corresponding

inequality

of

-LRB-

z

-RRB-

i.e

-LSB-

m

-RSB-

Sliffl

xl

tli

-LRB-

z

-RRB-

ineqi

-LRB-

z

-RRB-

The

coefficients

of

the

first

row

of

Sl

are

non

negative

As

one

could

argue

that

PIP

's

algorithm

is

not

exactly

the

Dual

simplex

method

-LRB-

due

to

the

lexicographical

cost

function

-RRB-

we

give

a

technical

demonstration

of

these

intuitive

properties

based

on

the

implemented

algorithm

itself

We

will

show

these

properties

by

recurrence

on

the

steps

of

the

algorithm

The

three

properties

are

true

for

the

first

problem

P

-LRB-

z

-RRB-

-LRB-

-RRB-

Indeed

we

have

ineqi

-LRB-

z

-RRB-

thus

oe

is

the

identity

Property

is

verified

by

definition

of

ineqi

-LRB-

x

z

-RRB-

and

as

the

first

line

of

is

-LRB-

-RRB-

it

has

all

its

coefficients

non

negative

thus

property

holds

too

Consider

now

a

problem

P

l

-LRB-

z

-RRB-

generated

by

PIP

from

-LRB-

z

-RRB-

P

l

-LRB-

z

-RRB-

in

context

z

fK

z

h

Kl

z

hl

get

the

lexicographic

minimum

of

the

domain

Dl

-LRB-

z

-RRB-

fAl

xl

z

al

j

Sl

xl

tl

-LRB-

z

-RRB-

g

and

suppose

that

the

three

properties

are

true

for

this

problem

We

will

study

the

different

subproblems

that

can

be

generated

by

PIP

in

one

step

and

see

that

the

three

properties

hold

for

each

of

these

subproblems

A

step

of

PIP

's

algorithm

is

divided

into

four

possible

cases

ffl

if

each

component

of

tl

-LRB-

z

-RRB-

is

non

negative

then

the

solution

is

reached

-LRB-

it

is

given

by

the

first

n

components

of

tl

-LRB-

z

-RRB-

-RRB-

No

subproblem

is

generated

ffl

if

no

component

of

tl

-LRB-

z

-RRB-

is

known

as

negative

and

if

there

is

a

tli

-LRB-

z

-RRB-

whose

sign

is

unknown

then

the

two

subproblems

generated

are

P

l

-LRB-

z

-RRB-

in

context

z

z

j

K

z

h

Kl

z

hl

tli

-LRB-

z

-RRB-

get

the

lexicographic

minimum

of

the

domain

Dl

-LRB-

z

-RRB-

and

P

l

-LRB-

z

-RRB-

in

context

z

z

j

K

z

h

Kl

z

hl

tli

-LRB-

z

-RRB-

get

the

lexicographic

minimum

of

the

domain

Dl

-LRB-

z

-RRB-

P

l

-LRB-

z

-RRB-

and

P

l

-LRB-

z

-RRB-

have

obviously

the

three

properties

requested

-LRB-

these

properties

do

not

take

the

context

into

account

-RRB-

ffl

if

there

is

a

negative

tli

-LRB-

z

-RRB-

such

that

all

the

elements

of

Siffl

are

negative

then

there

is

no

solution

in

this

leaf

no

subproblem

is

generated

ffl

in

the

remaining

case

a

pivoting

step

is

performed

There

is

an

such

that

-LRB-

z

-RRB-

is

negative

and

some

elements

are

positive

Among

all

the

possible

j

we

choose

such

that

it

minimizes

-LRB-

lexicographically

speaking

-RRB-

the

vector

Then

we

consider

a

new

basis

Bl

of

Zn

such

that

xl

i

xli

for

i

xl

ffl

xl

-LRB-

z

-RRB-

-LRB-

-RRB-

-LRB-

We

say

that

leaves

the

basis

and

xl

enters

it

-RRB-

This

basis

change

is

valid

because

If

we

note

BBBBBBBBB

CCCCCCCCCA

BBBBBBB

-LRB-

z

-RRB-

CCCCCCCA

then

we

have

xl

xl

-RRB-

xl

P

-LRB-

xl

-RRB-

If

we

want

to

express

the

problem

tableau

in

the

new

basis

we

obtain

Sl

xl

tl

-LRB-

z

-RRB-

SlP

-LRB-

xl

-RRB-

tl

-LRB-

z

-RRB-

The

problem

P

l

-LRB-

z

-RRB-

expressed

in

basis

Bl

is

P

l

-LRB-

z

-RRB-

in

context

z

fK

z

h

Kl

z

hl

get

the

lexicographic

minimum

of

the

domain

Dl

-LRB-

z

-RRB-

fAlP

-LRB-

xl

-RRB-

z

al

j

Sl

xl

tl

-LRB-

z

-RRB-

g

with

the

relations

Sl

-LRB-

-RRB-

Sl

fflk

Slfflk

-LRB-

-RRB-

k

tl

-LRB-

z

-RRB-

tl

-LRB-

z

-RRB-

-LRB-

-LRB-

z

-RRB-

-RRB-

And

this

is

exactly

the

subproblem

generated

by

PIP

as

P

l

-LRB-

z

-RRB-

This

implies

several

things

-LCB-

P

l

-LRB-

z

-RRB-

and

P

l

-LRB-

z

-RRB-

are

the

same

problems

expressed

in

different

bases

thus

they

have

the

same

solution

-LRB-

indeed

PIP

takes

the

solution

of

P

l

-LRB-

z

-RRB-

as

the

solution

of

P

l

-LRB-

z

-RRB-

-RRB-

-LCB-

As

P

l

-LRB-

z

-RRB-

has

property

from

-LRB-

-RRB-

we

have

ffl

xl

-LRB-

z

-RRB-

-LRB-

z

-RRB-

-RRB-

xl

-LRB-

z

-RRB-

P

l

-LRB-

z

-RRB-

has

also

property

thus

-LSB-

n

-RSB-

i

-RRB-

xl

i

ineqoel

-LRB-

i

-RRB-

-LRB-

z

-RRB-

If

we

note

oel

-LRB-

i

-RRB-

oel

-LRB-

i

-RRB-

for

i

and

oel

-LRB-

-RRB-

we

have

property

for

P

l

-LRB-

z

-RRB-

with

oel

We

just

have

to

check

that

oel

is

injective

This

is

enforced

by

the

fact

that

Bl

is

a

basis

If

oel

was

not

injective

two

components

of

xl

would

always

be

equal

-LRB-

we

could

also

note

that

if

line

had

already

been

chosen

the

corresponding

line

of

Sl

-LRB-

z

-RRB-

tl

-LRB-

z

-RRB-

would

be

xlj

for

some

j

thus

-LRB-

z

-RRB-

would

n't

be

negative

-RRB-

Finally

we

have

property

for

P

l

-LRB-

z

-RRB-

-LCB-

Property

becomes

obvious

too

-LSB-

m

-RSB-

Sl

iffl

xl

tl

i

-LRB-

z

-RRB-

Sliffl

xl

tli

-LRB-

z

-RRB-

ineqi

-LRB-

z

-RRB-

-LCB-

The

coefficients

of

the

first

line

of

Sl

are

still

non

negative

because

has

been

chosen

in

such

a

way

that

the

first

component

of

the

column

that

will

be

subtracted

to

all

columns

is

minimum

-LRB-

If

-LRB-

-RRB-

k

would

have

been

chosen

instead

of

-RRB-

Thus

property

holds

for

P

l

-LRB-

z

-RRB-

We

have

the

partial

result

ffl

Properties

and

hold

for

any

subproblem

generated

by

PIP

Consider

now

a

subproblem

P

l

-LRB-

z

-RRB-

for

which

a

solution

is

found

-LRB-

i.e

all

the

components

of

tl

-LRB-

z

-RRB-

are

positive

-RRB-

We

have

seen

that

the

solution

to

P

l

-LRB-

z

-RRB-

-LRB-

thus

to

P

-LRB-

z

-RRB-

with

the

additional

context

fKl

z

hl

-RRB-

is

given

by

the

first

n

components

of

tl

-LRB-

z

-RRB-

f

-LRB-

z

-RRB-

-LRB-

-LRB-

z

-RRB-

tln

-LRB-

z

-RRB-

-RRB-

T

From

property

we

know

that

xl

-LRB-

z

-RRB-

-LRB-

z

-RRB-

-LRB-

-RRB-

From

Property

we

know

how

to

express

each

components

of

xl

in

terms

of

's

components

xli

ineqoel

-LRB-

i

-RRB-

-LRB-

z

-RRB-

-LRB-

-RRB-

Thus

from

-LRB-

-RRB-

and

-LRB-

-RRB-

we

get

-LRB-

-RRB-

-LRB-

z

-RRB-

-LRB-

n

-RRB-

-LRB-

z

-RRB-

-LRB-

z

-RRB-

-LRB-

-RRB-

Finally

consider

the

positive

linear

combination

of

the

n

inequations

numbered

by

oel

-LRB-

-RRB-

oel

-LRB-

n

-RRB-

as

indicated

in

equation

-LRB-

-RRB-

-LRB-

remember

that

from

property

each

element

of

is

non

negative

-RRB-

We

get

ineqoel

-LRB-

-RRB-

-LRB-

z

-RRB-

ineqoel

-LRB-

n

-RRB-

-LRB-

z

-RRB-

-RRB-

-LRB-

z

-RRB-

Thus

we

have

proposition

We

are

now

able

to

prove

our

result

which

is

stated

in

Proposition

Proposition

Given

a

parametrized

problem

P

-LRB-

z

-RRB-

-LRB-

-RRB-

the

solution

Sol

-LRB-

z

-RRB-

-LRB-

-RRB-

given

by

PIP

is

such

that

the

relation

-LSB-

q

-RSB-

-LRB-

z

Domi

x

-LRB-

z

-RRB-

-RRB-

-RRB-

x

-LSB-

-RSB-

f

i

-LRB-

z

-RRB-

-LSB-

-RSB-

can

be

replaced

by

x

-LRB-

z

-RRB-

-RRB-

x

-LSB-

-RSB-

max

i

q

-LRB-

f

i

-LRB-

z

-RRB-

-LSB-

-RSB-

-RRB-

Proof

Directly

from

proposition

The

inequation

x

-LSB-

-RSB-

f

i

-LRB-

z

-RRB-

-LSB-

-RSB-

is

implied

by

the

inequations

defining

-LRB-

z

-RRB-

Thus

the

relation

-LRB-

z

Domi

x

-LRB-

z

-RRB-

-RRB-

-RRB-

x

-LSB-

-RSB-

f

i

-LRB-

z

-RRB-

-LSB-

-RSB-

can

be

extended

to

x

-LRB-

z

-RRB-

-RRB-

x

-LSB-

-RSB-

f

i

-LRB-

z

-RRB-

-LSB-

-RSB-

Conclusion

In

this

paper

we

have

presented

a

method

to

solve

the

loop

rewriting

problem

This

problem

is

present

in

most

automatic

parallelization

techniques

Generalizations

of

the

simplex

algorithm

like

PIP

are

particularly

wellsuited

for

this

problem

except

that

the

output

of

the

PIP

algorithm

could

not

be

directly

transformed

into

a

loop

nest

conforming

to

the

definition

given

in

Section

We

have

shown

that

if

the

parameters

z

are

such

that

the

polyhedron

D

-LRB-

z

-RRB-

is

not

empty

the

result

can

be

rewritten

as

the

maximum

of

a

finite

number

of

affine

forms

in

z

A

symmetrical

result

holds

for

the

upper

bound

In

some

languages

-LRB-

notably

Fortran

-RRB-

expressing

loop

bounds

as

maxima

or

minima

is

simpler

than

using

conditional

expressions

which

must

be

converted

to

conditional

instructions

by

the

introduction

of

temporaries

When

rewriting

a

single

loop

nest

after

a

transformation

like

loop

interchange

we

have

shown

-LRB-

see

Section

-RRB-

that

the

values

of

the

outer

loop

bounds

are

such

that

the

range

of

inner

loop

is

never

empty

Hence

we

may

directly

use

the

results

of

PIP

in

the

form

of

maxima

and

minima

In

the

systolic

approach

however

we

may

have

to

construct

the

union

of

two

or

more

iteration

domains

and

the

above

property

will

no

longer

be

true

In

that

case

each

inner

loop

must

be

guarded

by

a

test

For

example

take

an

instruction

whose

iteration

space

is

the

one

below

where

a

f

are

affine

forms

in

z

The

first

application

of

PIP

yields

z

and

the

second

one

gives

max

-LRB-

e

d

-RRB-

x

min

-LRB-

a

b

-RRB-

If

the

statement

is

to

be

executed

alone

we

may

write

DO

z

ff

DO

x

max

-LRB-

e

d

-RRB-

min

-LRB-

a

b

-RRB-

S

ENDDO

ENDDO

Suppose

however

that

we

are

forced

to

enlarge

the

z

loop

possibly

because

it

represents

logical

time

over

the

whole

program

Since

zones

and

must

not

be

scanned

we

must

write

DO

z

L

IF

z

DO

x

max

-LRB-

e

d

-RRB-

min

-LRB-

a

b

-RRB-

S

ENDDO

ENDIF

other

statements

ENDDO

The

expressions

of

the

bounds

as

maxima

or

minima

have

the

added

advantage

that

they

may

be

converted

to

linear

constraints

They

thus

can

be

used

as

context

for

the

computation

of

the

next

inner

loop

This

is

optional

since

PIP

will

find

equivalent

results

whenever

the

parameters

belong

to

the

context

Choice

between

the

two

methods

must

be

based

on

considerations

of

compile

time

performance

Results

of

Chamski

in

-LSB-

-RSB-

tend

to

show

that

omitting

the

context

gives

a

faster

algorithm

but

this

has

to

be

confirmed

by

more

extensive

experiments

Our

aim

now

is

to

use

this

method

in

the

back-end

of

the

PAF

parallelizer

-LRB-

Parall?eliseur

Automatique

pour

Fortran

-RRB-

-LSB-

-RSB-

In

PAF

the

hidden

parallelism

of

the

sequential

code

is

expressed

according

to

the

systolic

point

of

view

of

section

We

thus

hope

to

be

able

to

produce

in

a

mechanical

way

streamlined

parallel

code

from

PAF

's

front

end

systolic

descriptions

Acknowledgments

This

work

has

been

partially

supported

by

the

Coordinated

Research

Project

on

Concurrency

Communication

and

Cooperation

of

the

French

Council

for

Research

CNRS

The

first

author

-LRB-

J.F.C.

-RRB-

wishes

to

acknowledge

the

support

of

PRC/MRE

contract

ParaDigme

and

DRET

contract

The

third

author

-LRB-

T.R.

-RRB-

has

also

been

partially

supported

by

the

ESPRIT

Basic

Research

Action

of

the

European

Economic

Community

References

-LSB-

-RSB-

C.

Ancourt

and

F.

Irigoin

Scanning

polyhedra

with

DO

loops

In

Proc

ACM

SIGPLAN

pages

-LCB-

June

-LSB-

-RSB-

M.

Barnett

and

Ch

Lengauer

Loop

parallelization

and

unimodularity

In

Algorithmique

parall?ele

pages

-LCB-

Paris

Masson

-LSB-

-RSB-

M.

Barnett

and

Ch

Lengauer

Unimodularity

considered

nonessential

In

Proc

CONPAR

-LCB-

VAPP

V

LNCS

pages

-LCB-

Lyon

September

-LSB-

-RSB-

Z.

Chamski

Environnement

logiciel

de

programmation

d'un

acc?el?erateur

de

calcul

parall?ele

PhD

thesis

Univ.

Rennes

I

Rennes

February

-LSB-

-RSB-

A.

Darte

T.

Risset

and

Y.

Robert

Loop

nest

scheduling

and

transformations

In

J.J.

Dongarra

and

B.

Tourancheau

editors

Environments

and

Tools

for

Parallel

Scientific

Computing

North

Holland

-LSB-

-RSB-

P.

Feautrier

Parametric

integer

programming

RAIRO

Recherche

Op?erationnelle

-LCB-

September

-LSB-

-RSB-

P.

Feautrier

Semantical

analysis

and

mathematical

programming

application

to

parallelization

and

vectorization

In

P.

Quinton

M.

Cosnard

Y.

Robert

and

M.

Raynal

editors

Workshop

on

Parallel

and

Distributed

Algorithms

Bonas

pages

-LCB-

North

Holland

-LSB-

-RSB-

P.

Feautrier

Dataflow

analysis

of

scalar

and

array

references

Int

Journal

of

Parallel

Programming

-LRB-

-RRB-

-LCB-

February

-LSB-

-RSB-

P.

Feautrier

Some

efficient

solution

to

the

affine

scheduling

problem

part

I

one-dimensional

time

Technical

Report

IBP/MASI

May

-LSB-

-RSB-

P.

Feautrier

Some

efficient

solution

to

the

affine

scheduling

problem

part

II

multidimensional

time

Technical

Report

IBP/MASI

October

-LSB-

-RSB-

R.

E.

Gomory

An

algorithm

for

integer

solutions

to

linear

programs

In

R.

L.

Graves

and

P.

Wolfe

editors

Recent

Advances

in

Math

Programming

chapter

pages

-LCB-

Mac-Graw

Hill

New

York

-LSB-

-RSB-

S.

Hiranandani

K.

Kennedy

and

C.-W

Tseng

Compiler

optimizations

for

Fortran

D

on

MIMD

distributed-memory

machines

In

Supercomputing

pages

-LCB-

IEEE

Computer

Society

Press

November

-LSB-

-RSB-

L.

Lamport

The

parallel

execution

of

do

loops

Communications

of

The

ACM

-LRB-

-RRB-

-LCB-

February

-LSB-

-RSB-

L.S.

Liu

C.W.

Ho

and

J.P.

Sheu

On

the

parallelism

of

nested

for-loops

using

index

shift

method

In

Proceedings

of

International

Conference

on

Parallel

Processing

volume

pages

-LCB-

August

-LSB-

-RSB-

P.

Quinton

and

Y.

Robert

Systolic

Algorithms

and

Architectures

Prentice

Hall

and

Masson

-LSB-

-RSB-

P.

Quinton

The

systematic

design

of

systolic

arrays

In

Fran?coise

Fogelman

Soulie

Yves

Robert

and

Maurice

Tchuente

editors

Automata

Networks

in

Computer

Science

chapter

pages

-LCB-

Manchester

University

Press

-LSB-

-RSB-

M.

Raji-Werth

and

P.

Feautrier

Systematic

construction

of

programs

for

distributed

memory

systems

In

P.

Feautrier

and

Fran?cois

Irigoin

editors

Proc

of

the

Int

Workshop

on

Compiler

for

Parallel

Computers

Paris

December

-LSB-

-RSB-

M.

Raji-Werth

and

P.

Feautrier

On

parallel

program

generation

for

massively

parallel

architectures

In

M.

Durand

and

F.

El

Dabaghi

editors

High

Performance

Computing

II

NorthHolland

October

-LSB-

-RSB-

A.

Schrijver

Theory

of

linear

and

integer

programming

Wiley

New

York

-LSB-

-RSB-

W.

Shang

and

A.B.

Fortes

Time

optimal

linear

schedules

for

algorithms

with

uniform

dependencies

IEEE

Trans

on

Computers

-LRB-

-RRB-

-LCB-

June

-LSB-

-RSB-

M.

E.

Wolf

and

M.

S.

Lam

A

loop

transformation

theory

and

an

algorithm

to

maximize

parallelism

IEEE

Trans

Parallel

Distributed

Systems

-LRB-

-RRB-

-LCB-

October

-LSB-

-RSB-

M.

Wolfe

Optimizing

Supercompilers

for

Supercomputers

MIT

Press

Cambridge

MA

-LSB-

-RSB-

H.

Zima

and

B.

Chapman

Supercompilers

for

Parallel

and

Vector

Computers

ACM

Press

automatic parallelization
code generation
convex integer polyhedron