Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. 2004.

Presentasi serupa


Presentasi berjudul: "Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. 2004."— Transcript presentasi:

1 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.1 Komputasi Pipeline Chapter 5

2 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.2 Komputasi Pipeline Problem dibagi menjadi serangkaian task yang harus diselesaikan berurutan (dasar pemrograman sekuensial). Setiap task dieksekusi oleh satu proses atau prosesor yang terpisah.

3 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.3 Contoh Tambahkan semua elemen array a ke akumulasi sum: for (i = 0; i < n; i++) sum = sum + a[i]; Loop ini dapat “diuraikan” menjadi sum = sum + a[0]; sum = sum + a[1]; sum = sum + a[2]; sum = sum + a[3]; sum = sum + a[4];.

4 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.4 Pipeline untuk loop yang tidak terurai

5 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.5 Contoh Lain Filter frekuensi – Tujuannya adalah untuk mengambil frekuensi tertentu (f 0, f 1, f 2,f 3, dst.) dari sinyal yang terdijitasi, f(t). Sinyal memasuki pipeline dari kiri:

6 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.6 Dimana pipelining dapat digunakan dengan hasil yang baik Misalkan problem dapat dibagi menjadi serangkaian task sekuensial, pendekatan pipeline dapat menaikkan kecepatan eksekusi pada ketiga tipe komputasi berikut: 1. Jika ada lebih dari satu instance problem yang akan dieksekusi. 2. Jika ada sederet data item yang harus dioleh, masing- masing membutuhkan multiple operations 3. Jika informasi untuk memulai proses berikutnya dapat dikirimkan sebelum proses menyelesaikan semua operasi internalnya

7 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.7 “Type 1” Pipeline Space-Time Diagram

8 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.8 Alternative space-time diagram

9 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. 5.9 “Type 2” Pipeline Space-Time Diagram

10 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. “Type 3” Pipeline Space-Time Diagram Pengolahan pipeline di mana informasi dikirimkan ke tahap berikutnya sebelum status sebelumnya selesai. 5.10

11 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Jika jumlah tahap lebih besar dari jumlah prosesor pada pipeline, sejumlah tahap dapat diberikan ke setiap prosesor: 5.11

12 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Platform Komputasi untuk Aplikasi Pipelined Sistem multiprosesor dengan a line configuration Sebenarnya pipeline bukan struktur terbaik untuk cluster – bagaimanapun, cluster dengan switched direct connections, sebagaimana dimiliki oleh sebagian besar cluster, dapat mendukung simultaneous message passing

13 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Contoh Solusi Pipeline (Contoh setiap jenis komputasi) 5.13

14 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Contoh Program Pipeline Penjumlahan Bilangan Komputasi pipeline tipe

15 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Basic code untuk proses Pi : recv(&accumulation, Pi-1); accumulation = accumulation + number; send(&accumulation, Pi+1); Kecuali untuk proses pertama, P0, yang berupa send(&number, P1); Dan proses terakhir, Pn-1, yang berupa recv(&number, Pn-2); accumulation = accumulation + number; 5.15

16 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Program SPMD if (process > 0) { recv(&accumulation, Pi-1); accumulation = accumulation + number; } if (process < n-1) send(&accumulation, P i+1); Hasil akhir terdapat di proses terakhir. Selain penjumlahan, operasi aritmetika lain dapat dikerjakan. 5.16

17 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Penjumlahan bilangan yang di-pipeline Proses master process dan konfigurasi ring 5.17

18 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Sorting (mengurutkan) Bilangan Versi paralel insertion sort. 5.18

19 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved Pipeline untuk sorting dengan menggunakan insertion sort komputasi pipeline tipe 2

20 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Algoritma dasar untuk proses Pi adalah recv(&number, Pi-1); if (number > x) { send(&x, Pi+1); x = number; } else send(&number, Pi+1); Dengan n bilangan, proses nomer ke-i akan menerima = n - i. Jumlah yang dikirim = n - i - 1 Dengan demikian, dapat digunakan loop sederhana. 5.20

21 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Insertion sort dengan hasil dikembalikan ke proses master dengan menggunakan bidirectional line configuration 5.21

22 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Insertion sort with results returned 5.22

23 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Mencari Bilangan Prima Sieve of Eratosthenes Deret integer dimulai dari 2. Bilangan pertama, 2, adalah bilangan prima, dan disimpan. Semua kelipatan bilangan ini dihapus karena tidak mungkin merupakan bilangan prima juga. Proses diulang dengan bilangan yang tersisa. Algoritma ini membuang non-prima, dan menyimpan yang prima. 5.23

24 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Sieve of Eratosthenes Komputasi pipeline tipe 2

25 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Code untuk proses, Pi, dapat didasarkan atas recv(&x, Pi-1); /* ulangi untuk bilangan berikutnya */ recv(&number, Pi-1); if ((number % x) != 0) send(&number, P i+1); Setiap proses tidak akan menerima bilangan dengan banyak yang sama dan tidak diketahui sebelumnya. Gunakan message “terminator”, yang dikirimkan di akhir urutan: recv(&x, Pi-1); for (i = 0; i < n; i++) { recv(&number, Pi-1); If (number == terminator) break; (number % x) != 0) send(&number, P i+1); } 5.24

26 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Menyelesaikan Sistem Persamaan Linier Bentuk segitiga atas Di mana a dan b adalah konstanta, dan x adalah variabel yang dicari. 5.25

27 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Back Substitution Pertama, nilai x 0 dapat ditemukan dari persamaan terakhir; yaitu, Nilai x 0 disubstitusi ke persamaan berikutnya untuk mendapatkan x 1 ; yaitu, Nilai untuk x 1 dan x 0 disubstisi ke persamaan berikutnya untuk mendapat x 2 : dan seterusnya sampai semua variabel ditemukan. 5.26

28 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Solusi Pipeline Tahap pipeline pertama menghitung x 0 dan mengirim x 0 ke tahap kedua, yang menghitung x 1 dari x 0 dan mengirim x 0 dan x 1 ke tahap berikutnya, yang menghitung x 2 dari x 0 dan x 1, dan seterusnya. Komputasi pipeline tipe

29 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Proses ke-i (0 < i < n) menerima nilai x 0, x 1, x 2, …, x i-1 dan menghitung x i dari persamaan: 5.28

30 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Sequential Code Jika konstanta a i,j dan b k disimpan dalam array a[ ][ ] dan b[ ], berturut-turut, dan nilai yang akan dicari pada array, x[ ], sequential code untuk ini adalah x[0] = b[0]/a[0][0]; /* dihitung terpisah */ for (i = 1; i < n; i++) { /*untuk variabel yang tersisa*/ sum = 0; For (j = 0; j < i; j++ sum = sum + a[i][j]*x[j]; x[i] = (b[i] - sum)/a[i][i]; } 5.29

31 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved. Parallel Code Pseudocode proses P i (1 < i < n) for (j = 0; j < i; j++) { recv(&x[j], Pi-1); send(&x[j], Pi+1); } sum = 0; for (j = 0; j < i; j++) sum = sum + a[i][j]*x[j]; x[i] = (b[i] - sum)/a[i][i]; send(&x[i], Pi+1); Sekarang diperlukan komputasi tambahan setelah menerima dan mengirim nilai. 5.30

32 Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M Pearson Education Inc. All rights reserved Pemrosesan Pipeline dengan menggunakan back substitution


Download ppt "Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M. 2004."

Presentasi serupa


Iklan oleh Google