Top Banner
Library of Efficient Data types and Algorithms (LEDA)
31

Library of Efficient Data types and Algorithms (LEDA)

Dec 26, 2015

Download

Documents

Delphia Tucker
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: Library of Efficient Data types and Algorithms (LEDA)

Library of Efficient Data types and Algorithms (LEDA)

Page 2: Library of Efficient Data types and Algorithms (LEDA)

Outline

• Introduction to LEDA- Basic data type- Graphs- GraphWin

• Resources of LEDA

Page 3: Library of Efficient Data types and Algorithms (LEDA)

LEDA Overview

• C++ class library for efficient data types and algorithms- Graph and network

problems, geometric computations, combinatorial optimizationGraph

s

Embedded Graphs

Graph Algorithms

Advance Data Types

Basic Data Types

GraphWin

Windows

Geometry Kernels

Geometry Algorithms

Numbers

Ref: "LEDA A Platform for Combinatorial and Geometric Computing" CH.0 P.14 Fig.A

Page 4: Library of Efficient Data types and Algorithms (LEDA)

Basic Data Type

• String• Tuple

#include <LEDA/core/string.h>

int main()

{

leda::string a="thomas";

leda::string b="christian";

leda::string c="thomas";

if (a==c) std::cout << "a==c\n";

//strings can be compared with ==

std::cout << b(0,4) << std::endl;

//outputs the first five letters of b

return 0;

}

#include <LEDA/core/tuple.h>

#include <LEDA/core/string.h>

using namespace leda;

int main()

{

three_tuple<int,string,double>

triple(17,"triple",3.1413);

std::cout << triple << std::endl;

return 0;

}

Page 5: Library of Efficient Data types and Algorithms (LEDA)

Container

• Array• Dictionary Array

leda::array<int> A(1,100);

int i;

for (i=A.low(); i<=A.high(); i++)

A[i]=i;

std::cout << A[73] << " " << A[99] << std::endl;

d_array<string,string> D;

//objects of type string, keys of type string

D["hello"]="hallo"; D["world"]="Welt"; D["book"]="Buch";

string s;

forall_defined(s,D) std::cout << s <<

" " << D[s] << std::endl;

Page 6: Library of Efficient Data types and Algorithms (LEDA)

GraphWin

• The GraphWin combines Graphs and Windows

• Applications- An Interactive GUI- Construct and

display graphs- Visualize graphs and

the results of graph algorithms

Page 7: Library of Efficient Data types and Algorithms (LEDA)

Create a GraphWin

GRAPH<int, int> G;

GraphWin gw;

//initial the graph

random_simple_undirected_graph(G, 4, 3);

Make_Connected(G);

//set graphwin

gw.set_graph(G);

gw.set_edge_direction(undirected_edge);

//show graphwin

gw.display(window::center,window::center);

gw.edit();

Page 8: Library of Efficient Data types and Algorithms (LEDA)

Graph

• Elements in a Graph- Node set- Edge set

Node

Edge

Page 9: Library of Efficient Data types and Algorithms (LEDA)

Graph Representation

1

2

3

1

2

3

Page 10: Library of Efficient Data types and Algorithms (LEDA)

Graph Data Structure

• Node- Node name- Neighbor- Serial number- Weight

• Edge- Edge name- Serial number- Weight- Source- Sink

class NODE{

string name;

vector<NODE> neighbor;

int sn;

int weight;

};

class EDGE {

string name;

int sn;

int weight;

NODE source;

NODE sink;

};

Page 11: Library of Efficient Data types and Algorithms (LEDA)

Basic Graph Operation

• Insert a node• Delete a node• Insert an edge• Delete an edge

Page 12: Library of Efficient Data types and Algorithms (LEDA)

GraphsGRAPH<string, string> G;

node n_temp1, n_temp2, n_temp3, n_temp4, n_temp5;

n_temp1 = G.new_node(“A”);

n_temp2 = G.new_node(“B”);

n_temp3 = G.new_node(“C”);

n_temp4 = G.new_node(“D”);

n_temp5 = G.new_node(“E”);

G.new_edge(n_temp1, n_temp2);

G.new_edge(n_temp2, n_temp3);

G.new_edge(n_temp3, n_temp4);

G.new_edge(n_temp3, n_temp5);

A

B

C

D

E

Page 13: Library of Efficient Data types and Algorithms (LEDA)

Graph Traversal Example

• Depth-First Search Bread-First Search

3

5

1

0

24

6

5046132

3

5

1

0

24

6

5012436

Page 14: Library of Efficient Data types and Algorithms (LEDA)

Example Code

Graph construction

DFS

BFS

Page 15: Library of Efficient Data types and Algorithms (LEDA)

Graph Traversal Visualization

BFS

DFS

Page 16: Library of Efficient Data types and Algorithms (LEDA)

Min Cut Example

2

0

3

11

2

2

3

The minimum cut has value: 3

cut:[3][1]

Page 17: Library of Efficient Data types and Algorithms (LEDA)

Example Code

Graph construction

Min cut algorithm

Page 18: Library of Efficient Data types and Algorithms (LEDA)

Outline

• Introduction to LEDA- Basic data type- Graphs- GraphWin

• Resources of LEDA

Page 19: Library of Efficient Data types and Algorithms (LEDA)

Resource of LEDA

• LEDA Office Page- http://www.algorithmic-so

lutions.com/leda/

• LEDA User Manual- http://www.algorithmic-soluti

ons.info/leda_manual/manual.html

• LEDA Guide- http://www.algorithmic-soluti

ons.info/leda_guide/Index.html

• The LEDA Platform of Combinatorial and Geometric Computing- http://www.mpi-inf.mpg.de/~

mehlhorn/LEDAbook.html

Page 20: Library of Efficient Data types and Algorithms (LEDA)

Compilation on Workstation

• In NTHU-CAD- g++ -c –g -I/users/student/yourid/LEDA_lib/LEDA/incl -c -o test.o

test.cpp- g++ -o test test.o -L/users/student//yourid/LEDA_lib/LEDA -lG -lL -lm;

• g++ parameters- -I: location of the LEDA header files- -L: location the LEDA library files

Page 21: Library of Efficient Data types and Algorithms (LEDA)

Appendix

Page 22: Library of Efficient Data types and Algorithms (LEDA)

Final Project (FPGA Technology Mapping)

Logic description

Decomposition process

Technology mapping

A mapped logic description ( a general graph)

Minimize the number of required Boolean

operations from primary input to primary output

Use K-input LUTs to cover networks for

timing optimal

Page 23: Library of Efficient Data types and Algorithms (LEDA)

Two-input Decomposition

• Decompose multi-input operation to two-input operation

• Minimize the number of operation from inputs to outputs

Page 24: Library of Efficient Data types and Algorithms (LEDA)

Decomposed Network (1)

• The level of the decomposed network is 4

Page 25: Library of Efficient Data types and Algorithms (LEDA)

Decomposed Network (2)

• The level of the decomposed network is 5

Page 26: Library of Efficient Data types and Algorithms (LEDA)

Technology Mapping in FPGA

• Logic function is composed of LUT• Minimize the level and number of LUT

a

b c

d e

v

Fv

3-feasible cone Cv

PIs

Delay of 2

Page 27: Library of Efficient Data types and Algorithms (LEDA)

Inputs & Outputs

Page 28: Library of Efficient Data types and Algorithms (LEDA)

Overall Flow

Two-input Decomposition

FPGA technology mapping

Your algorithm

Page 29: Library of Efficient Data types and Algorithms (LEDA)

Notice

• Both the number of LUT and the height of the circuit are scored - the level of LUT is the main consideration- the number of LUT minimization is optional

• The Boolean functionality of your mapped circuit must be equivalent to that of original circuit. - SIS command (eq. verify)

• You can download the static library file of LEDA from course web site and use the graph algorithm provided by LEDA API in your code.- http://www.algorithmic-solutions.com/leda/index.htm

Page 30: Library of Efficient Data types and Algorithms (LEDA)

Most Important …

• Please follow the format of run-time example. - map –k 4 map01.blif output.blif

TA will test your program with

different K-input size

Page 31: Library of Efficient Data types and Algorithms (LEDA)

Due Day

1/14 (Tue) 2014Come to TA office (R227 EECS building) and demo

your program & report