slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Simulated Annealing in 512 bytes PowerPoint Presentation
Download Presentation
Simulated Annealing in 512 bytes

Loading in 2 Seconds...

play fullscreen
1 / 19

Simulated Annealing in 512 bytes - PowerPoint PPT Presentation


  • 115 Views
  • Uploaded on

Simulated Annealing in 512 bytes. Marcelo Johann. EMICRO200 4 Microelectronics School. B R A Z I L. P lacement. minimiz e total wire length (WL) ; minimiz e maximum local congestion (MLC) ;. thanks to Renato Hentschke. General A pproaches. Abstraction Placement with Overlaps Steps

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Simulated Annealing in 512 bytes' - graceland


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

Simulated Annealing in 512 bytes

Marcelo Johann

EMICRO2004

Microelectronics School

B R A Z I L

p lacement
Placement
  • minimize total wire length (WL);
  • minimizemaximum local congestion (MLC);

thanks to Renato Hentschke

general a pproaches
General Approaches

Abstraction

Placement with Overlaps

Steps

  • Global Placement
  • Detailed Placement
    • eliminate overlaps and set exact positions
  • Legalization
    • Fit intoslots, grid position, mirroring
basic algorit h ms
Basic Algorithms
  • Recursive Bisection
  • Cluster Growth, Force-Directed, ...
  • General combinatorial optimization:
    • Simulated annealing, simulated evolution, linear programming, quadratic assignment, resistivenetworks, neural networks, etc...
  • Analytical Placement
    • integer programming to spread cells
  • Most used:
    • simulated annealing, recursive bisection;
    • multi-level, Analytical;
simulated annealing
Simulated Annealing

thanks to Renato Hentschke

Perturbation

Cost

Reject / Accept

Three basic functions: Temperature Schedule (above), Cost (wire length) and Perturbation (changes in current solution).

s a in 5 12 bytes
S. A. in 512+ bytes

Looks crazy, but works!

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes1
S. A. in 512+ bytes

A big number!!!

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes2
S. A. in 512+ bytes

Loop a times

Read a from stdin

Exchange k[a] with k[b]

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes3
S. A. in 512+ bytes

x,y position of each node

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes4
S. A. in 512+ bytes

source and target of each arc

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes5
S. A. in 512+ bytes

Input graph reading: number of

cells and wires, number of rows

and list of wires (node node)

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes6
S. A. in 512+ bytes

Input graph reading: number of

cells and wires, number of rows

and list of wires (node node)

initial placement

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes7
S. A. in 512+ bytes

Cost function: adds the length

of all arcs in the graph

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes8
S. A. in 512+ bytes

Temperature scheduling

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes9
S. A. in 512+ bytes

Perturbation: exchange a

random selected pair of cells

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes10
S. A. in 512+ bytes

Accepting criteria (inverted)

Reject if the cost is higher

and the probability is not

satisfied

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes11
S. A. in 512+ bytes

Probabilistic: inversely

proportional to the temperature

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d %d\n",i,X[i],Y[i],w());}

s a in 5 12 bytes12
S. A. in 512 bytes

Take off cost reports to get

your 512-byte SA placer!

#include<stdio.h>

#include<math.h>

#define z 9999

#define F(a)for(i=0;i<a;++i)

#define R(a)scanf("%d",&a);

#define T(k)d=k[a];k[a]=k[b];k[b]=d;

long a,b,c=0,i,v,e,d,l,X[z],Y[z],E[9*z],G[9*z];double t;

w(){int i;d=0;F(e)d+=abs(X[E[i]]-X[G[i]])+abs(Y[E[i]]-Y[G[i]]);return d;}

main(){R(v)R(e)R(a)F(v){X[i]=i/a;Y[i]=i%a;}F(e){R(E[i])R(G[i])}

for(t=z*a;c++<z*9;t*=.9){F(1){a=rand()%v;b=rand()%v;l=w();T(X)T(Y);

if(d=(w()-l)>0)if(rand()%z>z*exp(-d/t)){T(X)T(Y)}}}

F(v)printf("%d %d %d%d\n",i,X[i],Y[i],w());}

slide19

Marcelo Johann

johann@inf.ufrgs.br

www.inf.ufrgs.br/~johann

Simulated Annealing in 512 bytes

EMICRO2004

Microelectronics School

That’s it!