Docsity

Parallel Processing of Irregular Computations: VHDL and Depth-First Search, Slides of Parallel Computing and Programming

Partial preview of the text

Download Parallel Processing of Irregular Computations: VHDL and Depth-First Search and more Slides Parallel Computing and Programming in PDF only on Docsity!

Lecture 10: Parallel

Processing of Irregular

Computations

Discrete Even Simulation—Basics

Discrete Even Simulation—Basics (cont’d)

Parallel DES for Logic Simulation

Search Techniques

A

B C

D

E

F

G

A

B C

D

E

F

G

1

2

3

4

5 6

7

DFS (black arcs) and Soln_DFS (black+red arcs)

Graph BFS

dfs(v) /* for basic graph visit or for soln finding when nodes are partial or full solns */ v.mark = 1; for each (v,u) in E if (u.mark != 1) then dfs(u)

Algorithm Depth_First_Search_Soln for each v in V v.mark = 0; for each v in V if v.mark = 0 then if G has partial soln nodes then dfs(v); else soln_dfs(v);

soln_dfs(v) /* used when nodes are basic elts of the problem and not partial soln nodes, and a soln. is a path / v.mark = 1; If path to v is a soln, then return(1); for each (v,u) in E if (u.mark != 1) then soln_found = soln_dfs(u) if (soln_found = 1) then return(soln_found) end for; v.mark = 0; / can visit v again to form another soln on a different path */ return(0)

A

B C

D

E

F

G

1

2

3

4 5

6

7

8

9

Soln found (A,B,E,C,F)

10

Best-First Search

BeFS (root) begin open = {root} /* open is list of gen. but not expanded nodes—partial solns / best_soln_cost = infinity; while open != nullset do begin curr = first(open); if curr is a soln then return(curr) / curr is an optimal soln / else children = Expand_&_est_cost(curr); / generate all children of curr & estimate their costs---cost(u) should be a lower bound of cost of the best soln reachable from u / for each child in children do begin if child is a soln then delete all nodes w in open s.t. cost(w) >= cost(child); endif store child in open in increasing order of cost; endfor endwhile end / BFS */

Expand_&est_cost(Y) begin children = nullset; for each basic elt x of problem “reachable” from Y & can be part of current partial soln. Y do begin if x not in Y and if feasible child = Y U {x}; path_cost(child) = path_cost(Y) + cost(Y, x) /* cost(Y, x) is cost of reaching x from Y / est(child) = lower bound cost of best soln reachable from child; cost(child) = path_cost(child) + est(child); children = children U {child}; endfor end / Expand&_est_cost(Y);

Y = partial soln. = a path from root to current “node” (a basic elt. of the problem, e.g., a city in TSP, a vertex in V0 or V1 in min-cut partitioning). We go from each such “node” u to the next one u that is “reachable “ from u in the problem “graph” (which is part of what you have to formulate)

u 10

(^12 ) 19

18 17

18

16

(1)

(2)

(3)

costs

root

Best-First Search

Proof of optimality when cost

is a LB

  • The current set of nodes in

“open” represents a complete

front of generated nodes, i.e.,

the rest of the nodes in the

search space are descendants

of “open”

  • Assuming the basic cost (cost

of adding an elt in a partial soln

to contruct another partial soln

that is closer to the soln) is

non-negative, the cost is

monotonic , i.e., cost of child >=

cost of parent

  • If first node curr in “open” is

a soln, then cost(curr) <=

cost(w) for each w in “open”

  • Cost of any node in the search

space not in “open” and not

yet generated is >= cost of its

ancestor in “open” and thus >=

cost(curr). Thus curr is the

optimal (min-cost) soln

u 10

(^12 ) 19

18

17

18

16

(1)

(2)

(3)

costs

root

Y = partial soln.