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

Slides:



Advertisements
Similar presentations
The Build-up of the Red Sequence at z
Advertisements

Back to Sorting – More efficient sorting algorithms.
Partitioning and Divide-and-Conquer Strategies ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, Jan 23, 2013.
Parallel Strategies Partitioning consists of the following steps –Divide the problem into parts –Compute each part separately –Merge the results Divide.
Quicksort Quicksort     29  9.
CS223 Advanced Data Structures and Algorithms 1 Divide and Conquer Neil Tang 4/15/2010.
Algorithms Recurrences Continued The Master Method.
1 Friday, September 29, 2006 If all you have is a hammer, then everything looks like a nail. -Anonymous.
Determine whether the sequence 6, 18, 54, is geometric. If it is geometric, find the common ratio. Choose the answer from the following :
Proof Methods & Strategy
MergeSort Source: Gibbs & Tamassia. 2 MergeSort MergeSort is a divide and conquer method of sorting.
11 and 6 3 and 9 2, 5, 10 and 4, 8 Divisibility Rules.
Notes Over 11.3 Geometric Sequences
Geometric Sequences and Series
Section 11.2 Arithmetic Sequences IBTWW:
12-1 Arithmetic Sequences and Series. Sequence- A function whose domain is a set of natural numbers Arithmetic sequences: a sequences in which the terms.
Notes Over 11.4 Infinite Geometric Sequences
Geometric Sequences and Series Unit Practical Application “The company has been growing geometrically”
Nattee Niparnan. Recall  Complexity Analysis  Comparison of Two Algos  Big O  Simplification  From source code  Recursive.
Series and Convergence
Notes Over 11.2 Arithmetic Sequences An arithmetic sequence has a common difference between consecutive terms. The sum of the first n terms of an arithmetic.
Section 12-1 Sequence and Series
This is the series In other words it is Consider the bars and how the represent the numbers in the sequence, and how the total sum of all.
DIVISIBILITY RULES.
Sequence – a function whose domain is positive integers. Section 9.1 – Sequences.
0-6: Operations on and Composition of Functions
Geometric Sequences & Series
Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
Multiple Answer Questions. Multiple Answer Question Types Look for patterns in the answers Questions with two “sets” of answers – The answer is one from.
Adding a Sequence of numbers (Pairing Method)
Primary Maths Calculation Strategies. Addition
Divisibility Rules. What Are Divisibility Rules? They are a quick way to tell if one number can be completely divided into another without a remainder.
Sorting Quick, Merge & Radix Divide-and-conquer Technique subproblem 2 of size n/2 subproblem 1 of size n/2 a solution to subproblem 1 a solution to.
9.3 Geometric Sequences and Series. 9.3 Geometric Sequences A sequence is geometric if the ratios of consecutive terms are the same. This common ratio.
Geometric Sequences. Warm Up What do all of the following sequences have in common? 1. 2, 4, 8, 16, …… 2. 1, -3, 9, -27, … , 6, 3, 1.5, …..
Adding, Subtracting, Multiplying, and Dividing Rational Numbers.
1Computer Sciences Department. 2 QUICKSORT QUICKSORT TUTORIAL 5.
1 CS4402 – Parallel Computing Lecture 7 - Simple Parallel Sorting. - Parallel Merge Sort.
Addition Flashcards Sum of
Partitioning & Divide and Conquer Strategies Prof. Wenwen Li School of Geographical Sciences and Urban Planning 5644 Coor Hall
DIVISIBILITY RULES. A number is divisible by: If the number ends in 0 the number is also divisible by 2 and 3 the sum of the number's digits.
ADDITION AND SUBTRACTION KS2. The key to successful addition and subtraction is a solid understanding of place value and number bonds. Year 3 – fluent.
Introduction to Algorithms: Divide-n-Conquer Algorithms
Year 3 Multiplication Count in 2s, 3s, 4s, 5s, 8s and 10s Games
11.2 Arithmetic Sequences.
JEOPARDY! 7th Grade WMS Fall 2009.
The Art of Problem Solving
CS 584 Lecture 3 How is the assignment going?.
JEOPARDY! 8th Grade WMS Fall 2009.
Sequences and Series.
Section 3.4 – Combinations of Functions
MergeSort Source: Gibbs & Tamassia.
Software Modules in Software Design
بسم الله الرحمن الرحيم هل اختلف دور المعلم بعد تطبيق المنهج الحديث الذي ينادي بتوفير خبرات تعليمية مناسبة للطلبة ؟ هل اختلف دور المعلم ؟ ن.ن. ع.
פחת ורווח הון סוגיות מיוחדות תהילה ששון עו"ד (רו"ח) ספטמבר 2015
شیوه های موازی سازی parallelization methods
Algorithms Lecture #07 Dr.Sohail Aslam.
Divide-and-Conquer 7 2  9 4   2   4   7
1.5 Combination of Functions
Sullivan Algebra and Trigonometry: Section 13.1
x/÷ Numbers Year 3-4 – Multiply and divide a multiple of 10
X values y values. x values y values Domain Range.
Divisibility Rules.
Geometric Sequences and series
Combinations of Functions
Divisibility Rules Dividing by 2
Use elimination to get rid of a1 and solve for d.
Arithmetic and Geometric Sequences
Divide 9 × by 3 ×
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<m ; i++, x=x+s) send(&number[x], s, Pi); result = 0; for(i=0 ; i<m ; i++){ recv(&part_sum, Pany); sum = sum + part_sum; } Slave recv(numbers, s, Pmaster); sum = 0; for(i=0 ; i<s ; i++) part_sum = part_sum + numbers[i]; send(&part_sum, Pmaster);

Addition of a sequence of numbers Master s = n / m; bcast(numbers, s, Pslave_group); result = 0; for(i=0 ; i<m ; i++){ recv(&part_sum, Pany); sum = sum + part_sum; } Slave bcast(numbers, s, Pmaster); start = slave_number * s; end = start + s; sum = 0; for(i=start ; i<end ; i++) part_sum = part_sum + numbers[i]; send(&part_sum, Pmaster);

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<end ; x = x+d) area = area * (f(x)+f(x+d)) * d; reduce_add(&integral, &area, Pgroup); area = 0.0; for(x=start ; x<end ; x=x+d) area = area + f(x) + f(x+d); area = 0.5 * area * d; area = 0.5 * (f(start) + f(end)); for(x=start+d ; x<end ; x=x+d) area = area + f(x); area = area * d;

N-body problem

Three dimension space

N-body problem Sequential Code for(t=0 ; t<tmax ; t++) for(i=0 ; i<N ; i++) { F=FORCE_ROUTINE(i); v[i]new = v[i] + F * dt; x[i]new = x[i] + v[i]new * dt; } for(i=0 ; i<nmax ; i++){ x[i] = x[i]new; v[i] = v[i]new; }

N-body problem Center of mass distance cluster of bodies

N-body problem Barnes-Hut algorithm

N-body problem

for( t=0 ; t<tmax ; t++) { Build_OCTTREE(); Tot_Mass_center(); comp_Force(); Update(); }

N-body problem

Buckets Sort