Presentation is loading. Please wait.

Presentation is loading. Please wait.

Partitioning and Divide-and-Conquer Strategies Data partitioning (or Domain decomposition) Functional decomposition.

Similar presentations


Presentation on theme: "Partitioning and Divide-and-Conquer Strategies Data partitioning (or Domain decomposition) Functional decomposition."— Presentation transcript:

1 Partitioning and Divide-and-Conquer Strategies Data partitioning (or Domain decomposition) Functional decomposition

2 + x 0 …….x (n/m)-1 + x n/m …….x (2n/m)-1 ……. + x (m-1)n/m …….x n-1 + sum Partitioning and Divide-and-Conquer Strategies

3 Addition of a sequence of numbers Master s = n / m; for(i=0, x=0 ; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3288372/11/slides/slide_2.jpg", "name": "Addition of a sequence of numbers Master s = n / m; for(i=0, x=0 ; i

4 Addition of a sequence of numbers Master s = n / m; bcast(numbers, s, Pslave_group); result = 0; for(i=0 ; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3288372/11/slides/slide_3.jpg", "name": "Addition of a sequence of numbers Master s = n / m; bcast(numbers, s, Pslave_group); result = 0; for(i=0 ; i

5 Addition of a sequence of numbers Analysis. Phase I. communication Phase II. computation

6 Addition of a sequence of numbers Analysis. Phase III. communication Phase VI. computation

7 Addition of a sequence of numbers Analysis.

8 Divide-and-Conquer int add(int* s) { if(number(s)=<2) return (n1+n2); else{ divide(s, s1, s2); part_sum1 = add(s1); part_sum2 = add(s2); retunr(part_sum1 + part_sum2); }

9 Divide-and-Conquer Divide problem

10 Divide-and-Conquer P0 P4 P0P2 P0P1P2P3 P6P4 P7P6P5P4

11 Divide-and-Conquer P0 P4 P0P2 P0P1P2P3 P6P4 P7P6P5P4

12 Process P0 divide(s1, s1, s2); send(s2, P4); divide(s1, s1, s2); send(s2, P2); divide(s1, s1, s2); send(s2, P0); part_sum = *s1; recv(&part_sum1, P0); part_sum = part_sum + part_sum1; recv(&part_sum1, P2); part_sum = part_sum + part_sum1; recv(&part_sum1, P4); part_sum = part_sum + part_sum1; Process P4 recv(s1, P0) divide(s1, s1, s2); send(s2, P6); divide(s1, s1, s2); send(s2, P5); part_sum = *s1; recv(&part_sum1, P5); part_sum = part_sum + part_sum1; recv(&part_sum1, P6); part_sum = part_sum + part_sum1; send(&part_sum, P0); Divide-and-Conquer

13 analysis communication

14 Divide-and-Conquer analysis computation

15 M-way Divide-and-Conquer int add(int* s) { if(number(s) =<4) return(n1+n2+n3+n4); esle{ divide(s, s1, s2, s3, s4); part_sum1 = add(s1); part_sum2 = add(s2); part_sum3 = add(s3); part_sum4 = add(s4); return(part_sum1 + part_sum2 + part_sum3 + part_sum4); }

16 M-way Divide-and-Conquer

17

18 Numerical Integration a p q b f(p) f(q) f(x)

19 Numerical Integration a p q b f(p) f(q) f(x)

20 a p q b f(p) f(q) Numerical Integration f(x)

21 Numerical Integration AB

22 Process Pi if( i== master ){ printf("Enter number of intervals"); scanf("%d", &n); } bcast(&n, Pgroup); region = (b-a) / p; start = a + region * i; end = start + region; d = (b-a) / n; area = 0.0; for(x=start ; x { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3288372/11/slides/slide_21.jpg", "name": "Process Pi if( i== master ){ printf( Enter number of intervals ); scanf( %d , &n); } bcast(&n, Pgroup); region = (b-a) / p; start = a + region * i; end = start + region; d = (b-a) / n; area = 0.0; for(x=start ; x

23 N-body problem

24 Three dimension space

25 N-body problem Sequential Code for(t=0 ; t { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3288372/11/slides/slide_24.jpg", "name": "N-body problem Sequential Code for(t=0 ; t

26 N-body problem Center of mass distance cluster of bodies

27 N-body problem Barnes-Hut algorithm

28 N-body problem

29 for( t=0 ; t { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3288372/11/slides/slide_28.jpg", "name": "for( t=0 ; t

30 N-body problem

31 Buckets Sort

32

33


Download ppt "Partitioning and Divide-and-Conquer Strategies Data partitioning (or Domain decomposition) Functional decomposition."

Similar presentations


Ads by Google