SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
NOTASI UNTUK ALGORITMA PARALEL

• Untuk Shared-Memory Model
      Global
      Local

• Untuk Distributed Memory Machine
      Parameter      Æ
                   suatu konstanta yang sudah
      dikomunikasikan antar prosesor.

• Umum
      +, x,  Å
                  Æ
      if … else … endif ; while … endwhile ; for … endfor
      for all …  data paralelism :
                • SIMD : diasumsikan ada lockstep
                • MIMD : diasumsikan berjalan
                  asynchronous

• ⇐ menyatakan suatu prosesor store/retrieve nilai
  local dari prosesor lain.

• [x] a menyatakan nilai dari prosesor.
  tmp ⇐ [s] a




APP – Elementary Parallel Algorithm                    1/ 7 hal
SUMMATION (HYPERCUBE SIMD):

Parameter           n { Number of elements to add}
                    p { Number of processing elements}

Global              j
Local               local.set.size, local.value[1…n/p ], sum, tmp

Begin
    For all Pi, where () ≤ i ≤ p – 1 do
           If i < (n modulo p) then
                   Local.set.size     Å n/p
           Else
                   Local.set.size     Å n/p
           Endif
     Sum     Å  0
     Endfor
     For j   Å   1 to n/p do
           For all Pi, Where 0 ≤ i ≤ P-1 do
                   If local.set.size ≥ j then
                          Sum     Åsum + local.value[j]
                   Endif
           Endfor
    Endfor
    For j    Å  log P-1 downto 0 do
           For all Pi, Where 0 ≤ i ≤ P-1 do
                   If i < 2j Then
                          tmp ⇐ [ i+2j] sum
                          sum     Å
                                  sum + tmp
                   Endif
    Endfor
   Endfor
END

APP – Elementary Parallel Algorithm                         2/ 7 hal
APP – Elementary Parallel Algorithm   3/ 7 hal
Hasilnya ?


Bagaimana jika setiap elemen pemrosesan akan
mempunyai copy-an dari global sum ? Kita dapat
menggunakan fase broadcast di akhir algoritma. Setiap
elemen pemrosesan Θ mempunyai global sum, nilai-nilainya
dapat dikirimkan ke processor lainnya dalam log p tahapan
komunikasi dengan membalikan arah edge pada pohon
binomial.

Kompleksitas untuk menemukan jumlah (sum) dari n nilai, Θ
(n/p + log p) pada model hypercube yang berarray
prosesor.



SHUFFLE – EXCHANGE SIMD MODEL

Pada model ini, tidal ada dilatasi – 1 pada pohon binomial.
Efisiensi algoritma ini jika jumlah digabungkan secara
berpasangan. Angka logaritma dari tahapan penggabungan
dapat menemukan total akhir. Setelah log p shuffle
exchange, prosesor O memdapatkan total akhir prosesor.




APP – Elementary Parallel Algorithm                 4/ 7 hal
SUMMATION (SHUFFLE-EXCHANGE SIMD) :
Parameter           n { Number of elements to add }
                    P { Number of processing elements }
Global              j
Local               local.set.size, local.value[1…n/p ], sum,tmp
Begin
     For all Pi, where () ≤ i ≤ p – 1 do
          If i < (n modulo p) then
                  Local.set.size      Ån/p
          Else
                  Local.set.size      Ån/p

              Å
          Endif
      Sum       0
      Endfor
      For j   Å 1 to n/p do
          For all Pi, Where 0 ≤ i ≤ P-1 do
                  If local.set.size ≥ j then
                        Sum       Å
                                  sum + local.value[j]
                  Endif
     Endfor

            Å
    Endfor
    For j     0 to log p-1 do
          For all Pi, Where 0 ≤ i ≤ P-1 do
                  Shuffle (sum) ⇐ sum
                  Exchange (tmp) ⇐ sum
                  Sum      Åsum + tmp
     Endfor
  Endfor
END


Waktu Kompleksitas : Θ (n/p + log p)




APP – Elementary Parallel Algorithm                         5/ 7 hal
2-D Mesh SIMD Model
Untuk mendapatkan jumlah n nilai diantara p prosesor,
diorganisasikan dalam √p x √p mesh, minimal satu prosesor pada
mesh harus berisi total akhir.
Total jumlah dari tahap komunikasi untuk mendapatkan sub-total dari
prosesor minimal 2(√p-1).

Kompleksitas algoritma ini Θ(n/p + √p)




APP – Elementary Parallel Algorithm                         6/ 7 hal
(Pseudocode (anggap n = l2 )
SUMMATION (2-D MESH SIMD) :
Parameter       l { Mesh has size l x l }
Global          i
Local           tmp,sum
Begin
  {each processor finds sum of its local values – code not
shown}
    For i    Å
             l-1 downto 1 do
          For all Pj,i , Where 1 ≤ j ≤ l do
          {Processing elements in column i active}
                tmp ⇐ south (sum)
                sum        Å
                         sum + tmp
          Endfor
    Endfor
END




APP – Elementary Parallel Algorithm                   7/ 7 hal
Waktu Eksekusi Algoritma ini terbagi 2 :

• Waktu yang dibutuhkan untuk nilai awal pesan ( message
  – passing overhead)
• Waktu yang dibutuhkan untuk melaksanakan pemindahan
  data ( message latency)

Jika data yang di- broadcast sedikit, message – passing
overhead mendominasi message latency.

Algoritma yang baik adalah yang meminimalkan jumlah
komunikasi yang dilaksanakan oleh setiap prosesor. Jadi
minimal untuk komunikasi membutuhkan log p.




APP – Elementary Parallel Algorithm               8/ 7 hal
Pohon binomial cocok untuk model broadcast ini, karena
ada sebuah dilatasi-1 yang ditempelkan ke hypercube dari
pohon binomial ( Lihat Gb. 6-11 dan 6 – 12)

Jika data yang di-broadcast besar, waktu pemindahan data
mendominasi message-passing overhead . Pada pohon
binomial-nya merupakan keadaan terburuk, dalam setiap
waktu, tidak lebih dari p/2 dari p log p hubungan komunikasi
yang digunakan.

Jika M adalah waktu yang dibutuhkan untuk melewatkan
pesan dari satu prosesor ke lainnya, algoritma broadcast ini
membutuhkan waktu M log p.

Jhonson and Ho (1989) membuat algoritma broadcast yang
mengeksekusi waktu lebih cepat dari algoritma bimial log p.

Algoritmanya : setiap hypercube terdiri dari “log p edge-
disjoint spanning tree” dengan node akar yang sama .
Algoritma memisahkan pesan ke dalam log p bagian dan
broadcast setiap bagian ke node lain melalui pohon rentang
binomial. (lihat Gb. 6-13)

Sehingga algoritma yang baru membutuhkan waktu M log
p/log p = M.




APP – Elementary Parallel Algorithm                  9/ 7 hal
HYPERCUBE BROADCAST (id,source,value) :

Parameter           P              {Number of processor}
Value               id             {Processor’s id number}
                    source         {ID of source processor}
Reference           value          {value to be broadcast}
Local               i              {loop iteration}
                    partner        {partner processor}
                    position       {position in broadcast tree}

{This procedure is called from inside a for all statement}

Begin
                  Å
                  id ⊗ source
             Å
    position
    For i     0 to log p-1 do
          If position < 2i then
                               Å
                            id ⊗ 2i
                                        Å
                partner
                [partner] value     value
          Endif
     Endfor
END.




APP – Elementary Parallel Algorithm                               10/ 7 hal
APP – Elementary Parallel Algorithm   11/ 7 hal

Contenu connexe

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Alg daspar (kuliah ke 4 )

  • 1. NOTASI UNTUK ALGORITMA PARALEL • Untuk Shared-Memory Model Global Local • Untuk Distributed Memory Machine Parameter Æ suatu konstanta yang sudah dikomunikasikan antar prosesor. • Umum +, x, Å Æ if … else … endif ; while … endwhile ; for … endfor for all … data paralelism : • SIMD : diasumsikan ada lockstep • MIMD : diasumsikan berjalan asynchronous • ⇐ menyatakan suatu prosesor store/retrieve nilai local dari prosesor lain. • [x] a menyatakan nilai dari prosesor. tmp ⇐ [s] a APP – Elementary Parallel Algorithm 1/ 7 hal
  • 2. SUMMATION (HYPERCUBE SIMD): Parameter n { Number of elements to add} p { Number of processing elements} Global j Local local.set.size, local.value[1…n/p ], sum, tmp Begin For all Pi, where () ≤ i ≤ p – 1 do If i < (n modulo p) then Local.set.size Å n/p Else Local.set.size Å n/p Endif Sum Å 0 Endfor For j Å 1 to n/p do For all Pi, Where 0 ≤ i ≤ P-1 do If local.set.size ≥ j then Sum Åsum + local.value[j] Endif Endfor Endfor For j Å log P-1 downto 0 do For all Pi, Where 0 ≤ i ≤ P-1 do If i < 2j Then tmp ⇐ [ i+2j] sum sum Å sum + tmp Endif Endfor Endfor END APP – Elementary Parallel Algorithm 2/ 7 hal
  • 3. APP – Elementary Parallel Algorithm 3/ 7 hal
  • 4. Hasilnya ? Bagaimana jika setiap elemen pemrosesan akan mempunyai copy-an dari global sum ? Kita dapat menggunakan fase broadcast di akhir algoritma. Setiap elemen pemrosesan Θ mempunyai global sum, nilai-nilainya dapat dikirimkan ke processor lainnya dalam log p tahapan komunikasi dengan membalikan arah edge pada pohon binomial. Kompleksitas untuk menemukan jumlah (sum) dari n nilai, Θ (n/p + log p) pada model hypercube yang berarray prosesor. SHUFFLE – EXCHANGE SIMD MODEL Pada model ini, tidal ada dilatasi – 1 pada pohon binomial. Efisiensi algoritma ini jika jumlah digabungkan secara berpasangan. Angka logaritma dari tahapan penggabungan dapat menemukan total akhir. Setelah log p shuffle exchange, prosesor O memdapatkan total akhir prosesor. APP – Elementary Parallel Algorithm 4/ 7 hal
  • 5. SUMMATION (SHUFFLE-EXCHANGE SIMD) : Parameter n { Number of elements to add } P { Number of processing elements } Global j Local local.set.size, local.value[1…n/p ], sum,tmp Begin For all Pi, where () ≤ i ≤ p – 1 do If i < (n modulo p) then Local.set.size Ån/p Else Local.set.size Ån/p Å Endif Sum 0 Endfor For j Å 1 to n/p do For all Pi, Where 0 ≤ i ≤ P-1 do If local.set.size ≥ j then Sum Å sum + local.value[j] Endif Endfor Å Endfor For j 0 to log p-1 do For all Pi, Where 0 ≤ i ≤ P-1 do Shuffle (sum) ⇐ sum Exchange (tmp) ⇐ sum Sum Åsum + tmp Endfor Endfor END Waktu Kompleksitas : Θ (n/p + log p) APP – Elementary Parallel Algorithm 5/ 7 hal
  • 6. 2-D Mesh SIMD Model Untuk mendapatkan jumlah n nilai diantara p prosesor, diorganisasikan dalam √p x √p mesh, minimal satu prosesor pada mesh harus berisi total akhir. Total jumlah dari tahap komunikasi untuk mendapatkan sub-total dari prosesor minimal 2(√p-1). Kompleksitas algoritma ini Θ(n/p + √p) APP – Elementary Parallel Algorithm 6/ 7 hal
  • 7. (Pseudocode (anggap n = l2 ) SUMMATION (2-D MESH SIMD) : Parameter l { Mesh has size l x l } Global i Local tmp,sum Begin {each processor finds sum of its local values – code not shown} For i Å l-1 downto 1 do For all Pj,i , Where 1 ≤ j ≤ l do {Processing elements in column i active} tmp ⇐ south (sum) sum Å sum + tmp Endfor Endfor END APP – Elementary Parallel Algorithm 7/ 7 hal
  • 8. Waktu Eksekusi Algoritma ini terbagi 2 : • Waktu yang dibutuhkan untuk nilai awal pesan ( message – passing overhead) • Waktu yang dibutuhkan untuk melaksanakan pemindahan data ( message latency) Jika data yang di- broadcast sedikit, message – passing overhead mendominasi message latency. Algoritma yang baik adalah yang meminimalkan jumlah komunikasi yang dilaksanakan oleh setiap prosesor. Jadi minimal untuk komunikasi membutuhkan log p. APP – Elementary Parallel Algorithm 8/ 7 hal
  • 9. Pohon binomial cocok untuk model broadcast ini, karena ada sebuah dilatasi-1 yang ditempelkan ke hypercube dari pohon binomial ( Lihat Gb. 6-11 dan 6 – 12) Jika data yang di-broadcast besar, waktu pemindahan data mendominasi message-passing overhead . Pada pohon binomial-nya merupakan keadaan terburuk, dalam setiap waktu, tidak lebih dari p/2 dari p log p hubungan komunikasi yang digunakan. Jika M adalah waktu yang dibutuhkan untuk melewatkan pesan dari satu prosesor ke lainnya, algoritma broadcast ini membutuhkan waktu M log p. Jhonson and Ho (1989) membuat algoritma broadcast yang mengeksekusi waktu lebih cepat dari algoritma bimial log p. Algoritmanya : setiap hypercube terdiri dari “log p edge- disjoint spanning tree” dengan node akar yang sama . Algoritma memisahkan pesan ke dalam log p bagian dan broadcast setiap bagian ke node lain melalui pohon rentang binomial. (lihat Gb. 6-13) Sehingga algoritma yang baru membutuhkan waktu M log p/log p = M. APP – Elementary Parallel Algorithm 9/ 7 hal
  • 10. HYPERCUBE BROADCAST (id,source,value) : Parameter P {Number of processor} Value id {Processor’s id number} source {ID of source processor} Reference value {value to be broadcast} Local i {loop iteration} partner {partner processor} position {position in broadcast tree} {This procedure is called from inside a for all statement} Begin Å id ⊗ source Å position For i 0 to log p-1 do If position < 2i then Å id ⊗ 2i Å partner [partner] value value Endif Endfor END. APP – Elementary Parallel Algorithm 10/ 7 hal
  • 11. APP – Elementary Parallel Algorithm 11/ 7 hal