Parallel and distributed computing · Komputasi paralel dan terdistribusi
Doing work in order
- Most simple programs are sequential: they do one step, then the next, then the next.
- The computer finishes step 1 before it starts step 2.
- This is easy to understand, but it can be slow for big jobs.
Melakukan pekerjaan secara berurutan
- Sebagian besar program sederhana bersifat sekuen: mereka melakukan satu langkah, lalu langkah berikutnya, lalu langkah setelahnya.
- Komputer menyelesaikan langkah 1 sebelum memulai langkah 2.
- Ini mudah dipahami, tetapi bisa lambat untuk pekerjaan besar.
Sequential (one worker):
task A -> task B -> task C -> task D
|-------|--------|--------|--------|
total time = A + B + C + D
Parallel computing
- Parallel computing splits work so several parts run at the same time.
- A modern computer has several processors (also called cores) that can each do work.
- If four workers each take one task, four tasks can finish in about the time of one.
Komputasi paralel
- Komputasi paralel membagi pekerjaan agar beberapa bagian dapat berjalan secara bersamaan.
- Komputer modern memiliki beberapa prosesor (juga disebut inti) yang masing-masing dapat melakukan pekerjaan.
- Jika empat pekerja masing-masing mengambil satu tugas, empat tugas dapat selesai dalam waktu sekitar satu.
Parallel (four workers at once):
worker 1: task A
worker 2: task B
worker 3: task C
worker 4: task D
|--------|
total time ≈ the longest single task
Speedup
- Speedup asks: how many times faster is the parallel version?
- speedup = (sequential time) / (parallel time).
- Example: a job takes 8 seconds in order, but 2 seconds split up. Speedup = 8 / 2 = 4 times.
Peningkatan Kecepatan
- Peningkatan kecepatan bertanya: berapa kali lebih cepat versi paralel?
- peningkatan kecepatan = (waktu berurutan) / (waktu paralel).
- Contoh: sebuah pekerjaan memakan waktu 8 detik secara berurutan, tetapi 2 detik jika dibagi. Peningkatan kecepatan = 8 / 2 = 4 kali.
Not always N times faster
- More processors does not always mean N times faster.
- Some parts of a job cannot be split — they must happen in order.
- Also, splitting work and joining results back together takes some extra time.
Tidak Selalu N Kali Lebih Cepat
- Memiliki lebih banyak prosesor tidak selalu berarti N kali lebih cepat.
- Beberapa bagian dari pekerjaan tidak dapat dibagi—mereka harus terjadi secara berurutan.
- Selain itu, membagi pekerjaan dan menggabungkan kembali hasilnya memerlukan sedikit waktu tambahan.
Job = setup (must be in order) + main work (can split)
setup main work (split over 4)
|-----| |--------------------------------|
|--------| <- this part gets 4x
The setup part stays the same length.
Distributed computing
- Distributed computing uses many separate computers that cooperate over a network.
- They may sit in different rooms, cities, or countries.
- Examples: the web (many servers), big data jobs split over thousands of machines, and large science projects.
Komputasi Terdistribusi
- Komputasi terdistribusi menggunakan banyak komputer terpisah yang bekerja sama melalui jaringan.
- Mereka mungkin berada di ruangan berbeda, kota berbeda, atau negara berbeda.
- Contoh: web (banyak server), pekerjaan data besar yang dibagi di atas ribuan mesin, dan proyek sains berskala besar.
Distributed (computers cooperate over a network):
[computer 1] [computer 2] [computer 3]
\ | /
\ | /
shared network / job
Each computer does part of the work.
Trade-offs
- Good: parallel and distributed systems can be much faster, and can handle huge jobs.
- Harder: the code is more complex; parts must be coordinated; results must be combined.
- Limits: speedup is capped by the parts that cannot be split, and by network delays between computers.
Trade-off
- Kelebihan: sistem paralel dan terdistribusi bisa jauh lebih cepat, dan mampu menangani pekerjaan besar.
- Kekurangan: kode menjadi lebih kompleks; bagian-bagian harus dikoordinasikan; hasil harus digabungkan.
- Batasan: peningkatan kecepatan dibatasi oleh bagian yang tidak dapat dibagi, serta penundaan jaringan antar komputer.
Key words
- Sequential: steps run one after another, in order.
- Parallel: parts run at the same time on several processors.
- Speedup: sequential time divided by parallel time.
- Distributed: many separate computers cooperate over a network.
Kata-kata kunci
- Berurutan: langkah-langkah berjalan satu demi satu, secara berurutan.
- Paralel: bagian-bagian berjalan bersamaan pada beberapa prosesor.
- Percepatan: waktu sekuensial dibagi dengan waktu paralel.
- Terdistribusi: banyak komputer terpisah bekerja sama melalui jaringan.
Common mistakes
- Parallel speed-up only helps work that can be split into independent parts.
- Each extra processor adds less and less speed.
Kesalahan umum
- Percepatan paralel hanya membantu pekerjaan yang dapat dibagi menjadi bagian-bagian independen.
- Setiap prosesor tambahan menambah kecepatan semakin sedikit.
Now you try
- Put the speedup formulas to work as small functions.
- Model a job that is part fixed setup and part splittable work. Press Check answer.
Sekarang Anda coba
- Terapkan rumus percepatan sebagai fungsi kecil.
- Modelkan tugas yang sebagian merupakan setup tetap dan sebagian adalah pekerjaan yang dapat dibagi. Tekan Cek jawaban.
A job has a setup part that must run in order, and a splittable part that workers can share at the same time. Write parallel_time(setup, splittable, workers) that returns the total time: the setup, plus the splittable part divided among the workers. Example: parallel_time(2, 8, 4) → 4.0 (2 + 8/4). · Sebuah pekerjaan memiliki bagian setup yang harus berjalan secara berurutan, dan bagian splittable yang workers dapat dibagi secara bersamaan. Tulis parallel_time(setup, splittable, workers) yang mengembalikan waktu total: setup, ditambah bagian yang dapat dibagi di antara para pekerja. Contoh: parallel_time(2, 8, 4) → 4.0 (2 + 8/4).
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.
Write speedup(sequential, parallel) that returns how many times faster the parallel version is: the sequential time divided by the parallel time. Example: speedup(8, 2) → 4.0. · Tulis speedup(sequential, parallel) yang mengembalikan berapa kali lebih cepat versi paralel: waktu sekuensial dibagi dengan waktu paralel. Contoh: speedup(8, 2) → 4.0.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.
Even with unlimited workers, the setup part still cannot be split. Write max_speedup(setup, splittable) for the best possible speedup: the whole job time divided by the setup time (endless workers shrink the splittable part to almost nothing, leaving only the setup). Example: max_speedup(2, 6) → 4.0 ((2+6)/2). · Bahkan dengan pekerja tak terbatas, bagian setup tetap tidak dapat dibagi. Tulis max_speedup(setup, splittable) untuk pemanfaatan kecepatan terbaik: waktu seluruh pekerjaan dibagi dengan waktu setup (pekerja tak terbatas mengecilkan bagian yang dapat dibagi menjadi hampir nol, menyisakan hanya setup). Contoh: max_speedup(2, 6) → 4.0 ((2+6)/2).
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.