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

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

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

+ 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

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/11/3288372/slides/slide_3.jpg", "name": "Addition of a sequence of numbers Master s = n / m; for(i=0, x=0 ; i

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/11/3288372/slides/slide_4.jpg", "name": "Addition of a sequence of numbers Master s = n / m; bcast(numbers, s, Pslave_group); result = 0; for(i=0 ; i

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

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

Addition of a sequence of numbers Analysis.

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); }

Divide-and-Conquer Divide problem

Divide-and-Conquer P0 P4 P0P2 P0P1P2P3 P6P4 P7P6P5P4

Divide-and-Conquer P0 P4 P0P2 P0P1P2P3 P6P4 P7P6P5P4

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

analysis communication

Divide-and-Conquer analysis computation

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); }

M-way Divide-and-Conquer

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

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

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

Numerical Integration AB

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/11/3288372/slides/slide_22.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

N-body problem

Three dimension space

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

N-body problem Center of mass distance cluster of bodies

N-body problem Barnes-Hut algorithm

N-body problem

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

N-body problem

Buckets Sort

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

Similar presentations