1 / 27

An Associative Program for the MST Problem using ClearSpeed

An Associative Program for the MST Problem using ClearSpeed. Hassan AL- Maksousy halmakso@kent.edu. a. 2. 8. 7. b. c. 4. 3. 9. 6. e. d. 3. f. Graph used for Data Structure. Figure 6 in [Potter, Baker, et. al.]. current_best$. candidate$. node$. parent$. mask$. PEs. d$.

kalli
Download Presentation

An Associative Program for the MST Problem using ClearSpeed

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  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-PRIM • Initially assign any node to root. • All processors set • candidate$ to “wait” • current-best$ to  • the candidate fieldfor the root node to “no” • All processors whose distance d from their node to root node is finite do • Set their candidate$ field to “yes • Set 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 zin the next_node column of a processor is less than its current_best$ value, then • Set 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 • //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'; • //---------------------------------------------------------- • // 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;

  23. MST in Cn By Hassan AL-Maksousy • //---------------------------------------------------------- • 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; • (*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

  24. MST in Cn By Hassan AL-Maksousy • // 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); • } • 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]); • }

  25. MST in Cn By Hassan AL-Maksousy • 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'; • 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);

  26. MST in Cn By Hassan AL-Maksousy • 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 • //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"); • }//endifget_penum() • } //main • // Compiling and running the program • -bash-3.00$ csreset • -bash-3.00$ cscn asc.cn mst.cn • -bash-3.00$ csruna.csx

  27. MST in Cn By Hassan AL-Maksousy Next Node = f 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: 3 Node e: Candidate n, Parent: b, Current Best: 3 Node f: Candidate n, Parent: c, Current Best: 9 End of program Next Node = e 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 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: 3 Node e: Candidate n, Parent: b, Current Best: 3 Node f: Candidate y, Parent: c, Current Best: 9

More Related