/
1 An Associative Program for the MST Problem using 1 An Associative Program for the MST Problem using

1 An Associative Program for the MST Problem using - PowerPoint Presentation

mitsue-stanley
mitsue-stanley . @mitsue-stanley
Follow
345 views
Uploaded On 2020-01-13

1 An Associative Program for the MST Problem using - PPT Presentation

1 An Associative Program for the MST Problem using ClearSpeed Hassan AL Maksousy halmaksokentedu 2 Graph used for Data Structure Figure 6 in Potter Baker et al a b c d e f 8 9 6 3 3 4 7 2 ID: 772714

candidate node parent current node candidate current parent set root nodearray mst field data int nextnode processors poly penum

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "1 An Associative Program for the MST Pro..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1 An Associative Program for the MST Problem using ClearSpeed Hassan AL- Maksousy halmakso@kent.edu

2 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

3 Data Structure for MST Algorithmcurrent_best$ candidate$ next- node a IS ∞ ∞ ∞ 9 ∞ ∞ f ∞ ∞ 3 6 3 ∞ e ∞ 3 ∞ ∞ 4 ∞ d 9 6 ∞ ∞ 7 8 c ∞ 3 4 7 ∞ 2 b ∞ ∞ ∞ 8 2 ∞ a PEs mask$ node$ a$ b$ parent$ root c$ d$ e$ f$

4 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

5 Data Structure for MST Algorithmcurrent_best$ candidate$ next- node b a IS wait ∞ ∞ ∞ 9 ∞ ∞ f wait ∞ ∞ 3 6 3 ∞ e wait ∞ 3 ∞ ∞ 4 ∞ d 8 a yes 9 6 ∞ ∞ 7 8 c 2 a yes ∞ 3 4 7 ∞ 2 b no ∞ ∞ ∞ 8 2 ∞ a PEs mask$ node$ a$ b$ parent$ root c$ d$ e$ f$

6 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

7 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

8 Data Structure for MST Algorithmcurrent_best$ candidate$ next- node e a IS wait ∞ ∞ ∞ 9 ∞ ∞ f 3 b yes ∞ ∞ 3 6 3 ∞ e 4 b yes ∞ 3 ∞ ∞ 4 ∞ d 7 b yes 9 6 ∞ ∞ 7 8 c 2 a no ∞ 3 4 7 ∞ 2 b no ∞ ∞ ∞ 8 2 ∞ a PEs mask$ node$ a$ b$ parent$ root c$ d$ e$ f$

9 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

10 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

11 Data Structure for MST Algorithmcurrent_best$ candidate$ next- node d a IS wait ∞ ∞ ∞ 9 ∞ ∞ f 3 b no ∞ ∞ 3 6 3 ∞ e 3 e yes ∞ 3 ∞ ∞ 4 ∞ d 6 e yes 9 6 ∞ ∞ 7 8 c 2 a no ∞ 3 4 7 ∞ 2 b no ∞ ∞ ∞ 8 2 ∞ a PEs mask$ node$ a$ b$ parent$ root c$ d$ e$ f$

12 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

13 Data Structure for MST Algorithmcurrent_best$ candidate$ next- node c a IS wait ∞ ∞ ∞ 9 ∞ ∞ f 3 b no ∞ ∞ 3 6 3 ∞ e 3 e no ∞ 3 ∞ ∞ 4 ∞ d 6 e yes 9 6 ∞ ∞ 7 8 c 2 a no ∞ 3 4 7 ∞ 2 b no ∞ ∞ ∞ 8 2 ∞ a PEs mask$ node$ a$ b$ parent$ root c$ d$ e$ f$

14 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

15 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

16 Data Structure for MST Algorithmcurrent_best$ candidate$ next- node f a IS yes ∞ ∞ ∞ 9 ∞ ∞ f 3 b no ∞ ∞ 3 6 3 ∞ e 3 e no ∞ 3 ∞ ∞ 4 ∞ d 6 e no 9 6 ∞ ∞ 7 8 c 2 a no ∞ 3 4 7 ∞ 2 b no ∞ ∞ ∞ 8 2 ∞ a PEs mask$ node$ a$ b$ parent$ root c$ d$ e$ f$ c 9

17 Graph used for Data StructureFigure 6 in [Potter, Baker, et. al.] a b c d e f 8 9 6 3 3 4 7 2

18 Short Version of Algorithm: ASC-MST-PRIM(root)Initialize candidates to “waiting” If there are any finite values in root’s field, set candidate$ to “yes” set parent$ to root set current_best$ to the values in root’s field set root’s candidate field to “no” Loop while some candidate$ contain “yes” for them restrict mask$ to mindex(current_best$) set next_node to a node identified in the preceding step set its candidate to “no” if the value in their next_node’s field are less than current_best$, then set current_best$ to value in next_node’s field set parent$ to next_node if candidate$ is “waiting” and the value in its next_node’s field is finite set candidate$ to “yes” set parent$ to next_node set current_best to the values in next_node’s field

19 Algorithm: ASC-MST-PRIMInitially assign any node to root . All processors set candidate$ to “wait” current-best$ to  the candidate field for the root node to “no” All processors whose distance d from their node to root node is finite do Set their candidate$ field to “yesSet their parent$ field to root .Set current_best$ = d.

20 Algorithm: ASC-MST-PRIM (cont. 2/3)While the candidate field of some processor is “yes”, Restrict the active processors to those whose candidate field is “yes” and (for these processors) do Compute the minimum value x of current_best$. Restrict the active processors to those with current_best$ = x and do pick an active processor, say node y .Set the candidate$ value of node y to “no” Set the scalar variable next-node to y.

21 Algorithm: ASC-MST-PRIM (cont. 3/3)If the value z in the next_node column of a processor is less than its current_best $ value , thenSet current_best$ to z . Set parent$ to next_node For all processors, if candidate$ is “waiting” and the distance of its node from next_node y is finite, then Set candidate$ to “yes” Set current_best $ to the distance of its node from y. Set parent$ to y

22 MST in Cn By Hassan AL-Maksousy//---------------------------------------------------------- // mst.cn // by Hassan AL-Maksousy // 2012-02-02 //----------------------------------------------------------   #include <lib_ext.h> #include <stdiop.h> #include "asc.h"   struct nodes { char nodeId; char candidate; int nodeArray[6]; int current_best; int parent; }; //---------------------------------------------------------- void initialize(poly struct nodes* node) { poly int i; //Initialize candidates to 'waiting' (*node).candidate = 'w'; (*node).parent = -1; //All active processor set current_best to infinit (*node).current_best = 32; for(i=0;i<6;i++) { (*node).nodeArray[i]=32; }   if (get_penum() == 0) { (*node).nodeId = 'a'; (*node).nodeArray[1] = 2; (*node).nodeArray[2] = 8; }   if (get_penum() == 1) { (*node).nodeId = 'b'; (*node).nodeArray[0] = 2; (*node).nodeArray[2] = 7; (*node).nodeArray[3] = 4; (*node).nodeArray[4] = 3; }   if (get_penum() == 2) { (*node).nodeId = 'c';

23 (*node).nodeArray[0] = 8; (*node).nodeArray[1] = 7; (*node).nodeArray[4] = 6; (*node).nodeArray[5] = 9; } if (get_penum() == 3) { (*node).nodeId = 'd'; (*node).nodeArray[1] = 4; (*node).nodeArray[4] = 3; } if (get_penum() == 4) { (*node).nodeId = 'e'; (*node).nodeArray[1] = 3; (*node).nodeArray[2] = 6; (*node).nodeArray[3] = 3; } if (get_penum() == 5) { (*node).nodeId = 'f'; (*node).nodeArray[2] = 9; }   } //initilize //---------------------------------------------------------- void showNodes(poly struct nodes node) { poly char letter[7]={' ','a','b','c','d','e','f'}; //Print nodeID, candidate, parent, and current best //distance. printfp("Node %c: Candidate %c, Parent: %c, Current Best: %d\n" , node.nodeId , node.candidate , letter[node.parent+1] , ((node.current_best < 32) ? node.current_best : 0) ); printf("\n");   } //End of showNodes(poly struct nodes)   //----------------------------------------------------------   int main() { poly int mask = 0; //Initially assign any node to root. poly int root = 0; // we choose the root here // a poly int minimum = 0; MST in Cn By Hassan AL-Maksousy

24 poly struct nodes node; poly int nextNode; int control=0; int i; poly int minCpu=100; poly char letter[6]={'a','b','c','d','e','f'};     if ( get_penum() < 6 ) { //All processors set //candidate$ to 'wait' //current-best$ to infinit initialize(&node); showNodes(node); //the candidate field for the root node to 'no' if (get_penum() == root) { node.candidate = 'n'; control+=1; printfp("Root = %c\n", letter[root]); } // All processors whose distance d from their node to //root node is finite do if ((node.nodeArray[root] >= 0)&& (node.nodeArray[root] != 32)) { //Set their candidate$ field to 'yes' node.candidate = 'y'; //Set their parent$ field to root. node.parent = root; //Set current_best$ = d node.current_best=node.nodeArray[root]; } //While the candidate field of some processor is 'yes' while (control < 6 ) { //Restrict the active processors to those whose //candidate field //is 'yes' and (for these processors) do if (node.candidate == 'y') { mask = 1; //Compute the minimum value x of current_best$. minimum = min_int(node.current_best); } MST in Cn By Hassan AL-Maksousy

25 nextNode = -1; showNodes(node);   //Restrict the active processors to those with //current_best$ = x and do if ((mask == 1) && (minimum == node.current_best)) { minCpu=get_penum(); minCpu=min_int(minCpu); } //pick an active processor, say node y if ( minCpu == get_penum()) { //Set the candidate$ value of node y to 'no' node.candidate = 'n'; control+=1; nextNode = get_penum(); printfp("Next Node = %c\n", letter[nextNode]); } // save nextNode value to all processor nextNode = max_int(nextNode); if(node.candidate != 'n') { //If the value z in the next_node column of a //processor is less than //its current_best$ value, then if (node.nodeArray[nextNode] < node.current_best) { //Set current_best$ to z. node.current_best = node.nodeArray[nextNode]; //Set parent$ to next_node node.parent = nextNode; }   //For all processors, if candidate$ is "waiting" and //the distance of its //node from next_node y is finite, then if ((node.nodeArray[nextNode] < 32) && (node.candidate == 'w')) { //Set candidate$ to "yes" node.candidate = 'y'; MST in Cn By Hassan AL-Maksousy

26 //Set current_best$ to the distance of its node from y. node.current_best = node.nodeArray [ nextNode ]; //Set parent$ to y. node.parent = nextNode; } } // endif 'n' mask = 0; minCpu = 100 ; } //end while showNodes(node); printf ("End of program \n"); }//endif get_penum() } //main // Compiling and running the program -bash-3.00$ csreset -bash-3.00$ cscn asc.cn mst.cn -bash-3.00$ csrun a.csx Node a: Candidate w, Parent: , Current Best: 0 Node b: Candidate w, Parent: , Current Best: 0 Node c: Candidate w, Parent: , Current Best: 0 Node d: Candidate w, Parent: , Current Best: 0 Node e: Candidate w, Parent: , Current Best: 0 Node f: Candidate w, Parent: , Current Best: 0 Root = a Node a: Candidate n, Parent: , Current Best: 0 Node b: Candidate y, Parent: a, Current Best: 2 Node c: Candidate y, Parent: a, Current Best: 8 Node d: Candidate w, Parent: , Current Best: 0 Node e: Candidate w, Parent: , Current Best: 0 Node f: Candidate w, Parent: , Current Best: 0 Next Node = b Node a: Candidate n, Parent: , Current Best: 0 Node b: Candidate n, Parent: a, Current Best: 2 Node c: Candidate y, Parent: b, Current Best: 7 Node d: Candidate y, Parent: b, Current Best: 4 Node e: Candidate y, Parent: b, Current Best: 3 Node f: Candidate w, Parent: , Current Best: 0 MST in Cn By Hassan AL-Maksousy

27 Next Node = eNode a: Candidate n, Parent: , Current Best: 0Node b: Candidate n, Parent: a, Current Best: 2 Node c: Candidate y, Parent: e, Current Best: 6 Node d: Candidate y, Parent: e, Current Best: 3 Node e: Candidate n, Parent: b, Current Best: 3 Node f: Candidate w, Parent: , Current Best: 0 Next Node = d Node a: Candidate n, Parent: , Current Best: 0 Node b: Candidate n, Parent: a, Current Best: 2 Node c: Candidate y, Parent: e, Current Best: 6 Node d: Candidate n, Parent: e, Current Best: 3 Node e: Candidate n, Parent: b, Current Best: 3 Node f: Candidate w, Parent: , Current Best: 0 Next Node = c Node a: Candidate n, Parent: , Current Best: 0 Node b: Candidate n, Parent: a, Current Best: 2 Node c: Candidate n, Parent: e, Current Best: 6 Node d: Candidate n, Parent: e, Current Best: 3Node e: Candidate n, Parent: b, Current Best: 3 Node f: Candidate y, Parent: c, Current Best: 9 Next Node = f Node a: Candidate n, Parent: , Current Best: 0Node b: Candidate n, Parent: a, Current Best: 2 Node c: Candidate n, Parent: e, Current Best: 6Node d: Candidate n, Parent: e, Current Best: 3Node e: Candidate n, Parent: b, Current Best: 3Node f: Candidate n, Parent: c, Current Best: 9 End of program MST in Cn By Hassan AL-Maksousy