Vous êtes sur la page 1sur 18

Lino a pro

ess algebra for multi ores


Paul Co kshott1
1

S hool of Computing S ien e

Paul Co kshott,

And the SICSA multi- ore hallenge

Motivation

Moore's Law implies that as the s ale of transistors shrinks, the


number of gates that an be tted onto a hip of a standard size,
say of the order of 1 m2 , will double every two years. Histori ally
this has been used by pro essor manufa tures to in rease the
omplexity of individual pro essor ores.
A redu tion in feature sizes potentially allows the speed of gates to
rise, allowing a rise in lo k speeds. This rise was pretty ontinuous
until the last few years sin e when it has leveled o.

Paul Co kshott,

And the SICSA multi- ore hallenge

How parallelism is hanging


1

Higher lo k speeds in rease the heat dissipation per m2 due


to apa itive losses, at around 3Ghz the heat losses are at the
limit of what an be sustained with air ooling, even with heat
pipes et .
As lo k speeds rise, lo k skew a ross the die be omes a
signi ant fa tor whi h ultimately limits the ability to
onstru t syn hronous ma hines.

A result of these pressures has been that the mode of elaboration of


hips has swit hed from omplexifying individual ores, to the
adding of multiple ores to ea h hip. We an now expe t the
number of ores to grow exponentially: perhaps doubling roughly
every two years. This implies that in 10 years time a mass produ ed
standard PC hip ould ontain around 256 or 512 ores.
Paul Co kshott,

And the SICSA multi- ore hallenge

The SCC

Paul Co kshott,

And the SICSA multi- ore hallenge

Inside the SCC

Paul Co kshott,

And the SICSA multi- ore hallenge

Paul Co kshott,

And the SICSA multi- ore hallenge

Need new types of languages

This growth in the number of ores and the problems of


ommuni ating between arbitrary pro essors is going to require a
fundamental rethink in the way we design programming languages.
In this talk I present Lino, a novel notation for programming
arbitrarily large arrays of pro essors, based on abstra tions over
patterns of pro ess adja en ies.

Paul Co kshott,

And the SICSA multi- ore hallenge

Lino Tiles and Tilings


Lino programs des ribe arrays of square tiles. Figure shows an
atomi square tile and an array of tiles. A tile has one input stream
and one output stream on ea h fa e, with inputs numbered 0..3
and outputs 4..7 in lo kwise fa e order starting at the
top\footnote{This is the onvention for all fa e orderings.}. Fa es
are identied as North, East , South and West .

Paul Co kshott,

And the SICSA multi- ore hallenge

Syntax of Lino
omm::= dev | alias
omms ::= omm[; omms ]
prog ::= oms ; main = exp

ommands
ommand seq
a program is a sequen e of ommands
ending with a nominated main expression
dene tile id

def ::= id :fa es < path


fa es ::=
((ty0 ,ty4 ),...(ty3 ,ty7 ) I/O stream types
ty ::= ...
type
path::= ...
le path
alias ::= id = exp
id aliases exp
A ommand is a tile denition or an alias ed expression. A
denition provides the tile name, the types of the input and output
for ea h fa e, and a path to an exe utable body.

Paul Co kshott,

And the SICSA multi- ore hallenge

Syntax ontinued

blo k ::= [ redir [; redir ]


redir ::= path dirio [dirio ]
dirio ::= inout dire tion
inout ::= < | >
dire tion::= North | South | East | West
exp ::= ...
id

Paul Co kshott,

shell blo k
redire ted shell omman
standard redire tions
dire tion names
expressions
name of dened tile or
aliased expression

And the SICSA multi- ore hallenge

More syntax
I
Mirror
0
( exp )
exp1 |exp2
exp1 _ exp2
exp * int
exp ^int
Flip exp
Rotate exp

As in

identity
redire ts fa e I/O
sink
bra keting for priority
pro ess row
pro ess olumn
horizontal repli ation
verti al repli ation
ree tion about verti al axis
rotate 90 degrees lo kwise
5
1

a) identity

b) mirror

c) null
Paul Co kshott,

a) flip

7
0
1

b) rotate

And the SICSA multi- ore hallenge

Lino programs

A program is a sequen e of ommands ending with a nominated


main expression. A ommand is a tile denition or an alias ed
expression. A denition provides the tile name, the types of the
input and output for ea h fa e, and a path to an exe utable body.

Paul Co kshott,

And the SICSA multi- ore hallenge

Agebrai rules
Lino has algebrai re-writing rules
input
is equivalent to
e*1
e*N
e^1
e^N
Flip I
Flip Mirror
Flip 0
Flip(e|f)
Flip (e_f)
a|(b| )
a_(b_ )

e
e|(e*N-1)
e
e^(e*N-1)
I
Mirror
0
Flip f| Flip e
(Flip e)_(Flip f)
(a|b)|
(a_b)_

Paul Co kshott,

And the SICSA multi- ore hallenge

Algebrai rules ontinued


input

is equivalent to

Rotate I
Rotate Mirror
Rotate 0
Rotate (e|f)
Rotate (e_f)
Flip Flip e
Rotate Rotate Rotate Rotate e
(a_b)|( _d)

I
Mirror
0
(Rotate f) _ (Rotate e)
(Rotate f)|(Rotate e)
e
e
(a| )_(b|d)

Paul Co kshott,

And the SICSA multi- ore hallenge

What the rules mean


The rules shown apply to expressions.
Horizontal and verti al repli ation apply a xed (and known)
number of times.
Flip and rotate preserve identity, mirror and null tiles .
Asso iativity holds for horizontal and verti al omposition
Flipping a row reates a row of ipped elements in reverse
order; ipping a olumn reates a olumn of ipped elements.
Rotating a row reates a olumn of rotated elements; rotating
a olumn reates a row of rotated elements in reverse order
Two ips an el .
Four rotates an el .
Columns distribute over rows .
Paul Co kshott,

And the SICSA multi- ore hallenge

Status
A prototype implementation was ompleted last autumn.
Implementation pro eeds in two stages. First, the main expression
is fully expanded to olumn-major order. Then, the overall olumn
of rows drives the generation of an equivalent shell s ript in whi h,
for ea h tile position, approprite exe utable alls are made with
stream redire tion to linking FIFOs.
This rst version runs on standard multi- ore linux. It translates
dire tly into shell s ript to generate the parallelism using &
operations.
A new implementation being made targeted expli itly at the SCC.

Paul Co kshott,

And the SICSA multi- ore hallenge

Examples
/* a very simple example */
main = ( Flip ( [ls > East |[ at <West )) ;

This is ompiled to the shell s ript:


rm fifos/*
mkfifo fifos/North0_0
mkfifo fifos/East0_0
mkfifo fifos/South0_0
mkfifo fifos/West0_0
mkfifo fifos/North0_1
mkfifo fifos/East0_1
mkfifo fifos/South0_1
mkfifo fifos/West0_1
# starting blo k
# ommand 0 = at
at < fifos/East0_1 &
# starting blo k
# ommand 0 = ls
ls > fifos/East0_1 &
e ho lino tasks laun hed
Paul Co kshott,

And the SICSA multi- ore hallenge

Another example s ript

life ell:((int,int),(int,int),(int,int),(int,int)) <- ./


liferow = Mirror|(Flip (life ell *3) )|I|Mirror;
lifeblo k = Flip (liferow ^ 3);
mirrorrow = Mirror * 6;
main = Rotate(mirrorrow _ lifeblo k _ mirrorrow

Paul Co kshott,

And the SICSA multi- ore hallenge

Vous aimerez peut-être aussi