6. Multiprocessor
6์ฅ Multiprocessor ๊ฐ์
๋จ์ผ ํ๋ก์ธ์์ clock frequency ํ๊ณ์ ๋ถ๋ชํ๋ฉด์ ์ฌ๋ฌ ํ๋ก์ธ์๋ฅผ ๋ณ๋ ฌ๋ก ์ฌ์ฉํ๋ Multiprocessor ์ํคํ ์ฒ๊ฐ ์ปดํจํฐ ๊ตฌ์กฐ์ ์ฃผ๋ฅ๊ฐ ๋์๋ค. ์ด ์ฅ์์๋ Shared Memory / Message Passing, Cache Coherence, ๋๊ธฐํ, Cluster ๋ฐ ์ํธ์ฐ๊ฒฐ ํ ํด๋ก์ง๋ฅผ ๋ค๋ฃฌ๋ค.
Shared Memory Multiprocessor
[P1]โโ[Cache]โโโ
[P2]โโ[Cache]โโโผโโ[Interconnection Network]โโ[Memory]
[P3]โโ[Cache]โโโ
- UMA (Uniform Memory Access): ๋ชจ๋ ํ๋ก์ธ์๊ฐ ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ ์๊ฐ์ด ๊ฐ์
- NUMA (Non-Uniform Memory Access): ํ๋ก์ธ์์ ๊ฐ๊น์ด ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ์ ๋น ๋ฅด๊ณ , ๋จผ ๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ์ ๋๋ฆผ
- Memory access time๋ ๋ค๋ฆ
Example: Sum Reduction
100๊ฐ์ ํ๋ก์ธ์๊ฐ 100,000๊ฐ ์ซ์๋ฅผ ํฉ์ฐํ๋ ์ฝ๋:
sum[Pn] = 0;
for (i = 10000*Pn; i < 10000*(Pn+1); i = i + 1)
sum[Pn] = sum[Pn] + A[i];
/* now add the sub-sums */
half = 100;
repeat
synch();
if (half%2 != 0 && Pn == 0)
sum[0] = sum[0] + sum[half-1];
/* Conditional sum needed when half is odd */
half = half/2; /* dividing line on who sums */
if (Pn < half)
sum[Pn] = sum[Pn] + sum[Pn+half];
until (half == 1);
Synchronization์ด ํ์ํ ์ด์ : ์ฌ๋ฌ processor๊ฐ ๊ฐ์ ๋ณ์๋ฅผ ๋์์ ์ฝ๊ณ ์ธ ๋ race condition ๋ฐ์.
Synchronization in Shared Memory
์: Producer-Consumer ๋ฌธ์
Shared data
int counter = 0;
int buffer[BUFFER_SIZE];
int in <mark class="highlight"><strong><u> 0; int out </u></strong></mark> 0;
/* Producer */
while (counter == BUFFER_SIZE) ; // do nothing
buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE;
counter++;
/* Consumer */
while (counter == 0) ; // do nothing
next_consumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;
counter--;
counter++์ counter--๊ฐ atomicํ์ง ์์ผ๋ฉด race condition ๋ฐ์.
์: counter++ register1 </u></strong></mark> counter; register1 <mark class="highlight"><strong><u> register1 + 1; counter </u></strong></mark> register1;
๋ processor๊ฐ ์ธํฐ๋ฆฌ๋น๋๋ฉด ๊ฐ์ด ์์ค๋ ์ ์์ โ Critical Section ๋ฌธ์ .

The Critical-Section Problem
repeat
Entry Section
critical section โ ํ ๋ฒ์ ํ processor๋ง ์ง์
Exit Section
remainder section
until false;
Correctness Criteria for a Solution
- Mutual Exclusion: ํ critical section์ ํ processor๋ง ์ง์
- Progress: critical section์ ๋ค์ด๊ฐ๋ ค๋ processor๊ฐ ์์ผ๋ฉด ๊ฒฐ๊ตญ ๋ค์ด๊ฐ ์ ์์
- Bounded Waiting: Critical Section์ ์ง์ ํ๋ ค๋ processor๋ ์ ํ ์๊ฐ ๋ด์ ์ง์ ํด์ผ ํจ (starvation ๋ฐฉ์ง)

Mutual Exclusion with Test-and-Set
repeat
while Test-and-Set(lock) do no-op; // Entry Section
critical section
lock := false; // Exit Section
remainder section
until false;
- Lock ๊ฐ์ด 1์ด๋ฉด no-op ์ํ (loop, busy-wait)
- SW ๋ช ๋ น์ด๋ก lock์ 0์ผ๋ก ๋ฐ๊ฟ
P0์ P1์ด ๋์์ lock bit๋ฅผ ์ฝ์ผ๋ฉด ๋ฌธ์ ๋ฐ์
๋์์ lock bit๊ฐ 0์ผ๋ก ์ฝํ๋ฏ๋ก ๋ฌธ์ . Test-and-Set์ atomic ์ฐ์ฐ์ผ๋ก ์ด๋ฅผ ๋ฐฉ์ง (์ฌ์ฉํ๋ ค๊ณ ํ๋ฉด ๋ฐ๋ก lock bit๋ฅผ 1๋ก ๋ฐ๊ฟ, ์ฝ์๋ง์).
โ Mutual Section๊ณผ Progress๋ ๋ง์กฑํ์ง๋ง Bounded Waiting์ ๋ง์กฑํ์ง ์์ (ํ๋ฅ ์ด ๋ฎ๊ธฐ์ ๊ตฌํ์ ์ํ ์๋ ์์).
Naive Synchronization vs Optimized Synchronization
Naive (Test-and-Set in a loop)
Try to lock variable using swap:
read lock variable and then set
variable to locked value (1)
Succeed? (= 0?)
Yes โ Begin update, Finish update, Unlock (set lock variable to 0)
No โ loop
๊ธฐ๋ฅ์ ์ธ ๋ฌธ์ ๋ ์์ง๋ง, ์ฑ๋ฅ์ ์ธ ๋ฌธ์ ๋ฐ์:
- P0 ์ฌ์ฉ โ lock bit: 1
- P1 Access ๋ถ๊ฐ โ lock bit: 1 (๋๋จธ์ง Cache์ lock bit invalidate)
- P2 Access ๋ถ๊ฐ โ lock bit: 1 (๋๋จธ์ง Cache์ lock bit invalidate)
โ ๊ณ์ํด์ Memory Access ๋ฌธ์ ๋ฐ์ (Interconnect ์ง์ฐ, ์ ๋ ฅ ์๋ชจ).
Optimized Synchronization (Load-first)
- Memory ์ฌ์ฉ X โ ์ ๋ ฅ์ ์ข์
- Test-and-Set ์ ์ lock ๊ฐ์ load
lock: 1โ ๊ณ์ Loadlock: 0โ Test-and-Set
๋ง์ฝ Loadํ ๋ 0์ด์๋๋ฐ Test-and-Setํ ๋ 1์ด๋ฉด ๋๊ตฐ๊ฐ๊ฐ ๋จผ์ ๋นผ์์๊ฐ ๊ฒ.
- P0 ์ฌ์ฉ โ lock bit: 1
- P1, P2 Access โ Load (Cache์ lock bit: 1) โ Cache์์ ๊ณ์ Hit (๋ฉ๋ชจ๋ฆฌ ์ ๊ทผ X)
- P0 ์ฌ์ฉ ์ข ๋ฃ โ Lock bit: 0๋๊ณ invalidate protocol์ ์ํด ๋ค๋ฅธ Processor Cache์ lock bit: 0
- P1, P2 Access โ Load (Cache์ lock bit: 0) โ Test-and-Setํด์ P1๊ณผ P2 ์ค ํ๋๊ฐ ๋์์ฑ

Message Passing
- ๊ฐ๊ฐ์ Processor๊ฐ ๊ฐ๊ฐ์ Physical Address ๊ณต๊ฐ์ ๊ฐ์ง
- HW๋ Processor ์ฌ์ด์ Message๋ฅผ ์ฃผ๊ณ ๋ฐ์
[Processor]โ[Cache]โ[Memory] ... [Processor]โ[Cache]โ[Memory]
โโโโโโโโโ Interconnection Network โโโโโโโโโ
Loosely Coupled Clusters
- ๋ ๋ฆฝ์ ์ธ ์ปดํจํฐ๋ค์ ์๋ Network ํ์ โ I/O System ์ด์ฉ (Ethernet/Switch/Internet)
- ๊ฐ์ ๋ค๋ฅธ Memory์ CPU
- ๋ ๋ฆฝ์ ์ธ task๋ฅผ ๊ฐ์ง๋ application์ ์ ํฉ (Web server, databases, simulations โฆ)
- ๋์ Availability, Scalable, Affordable
โ Shared Memory๋ ์ฐ๊ฒฐ์ํฌ ์ ์๋ Processor์ ์ ํ๊ณ๊ฐ ์์ง๋ง, Message Passing์ ๋ ๋ง์ Processor ์ด์ฉ ๊ฐ๋ฅ.
[๋ฌธ์ ์ ]: ๊ด๋ฆฌ ๋น์ฉ์ด ๋น์ธ๊ณ , Interconnect์ ์ฑ๋ฅ์ด ๋ฎ์ผ๋ฉด ์ ์ฒด ์ฑ๋ฅ์ด ๋จ์ด์ง โ SMP (Symmetric Multiprocessor) ์ด์ฉ โ ๊ณ ์ฑ๋ฅ, ๊ณ ๋์ญ ๊ตฌํ.
Sum Reduction in Message Passing
- โ ๋๊ตฐ๊ฐ๊ฐ ๋ํด์ผ ํ๋ ์๋ฅผ 1000๊ฐ์ฉ ๋๋์ด ์ฃผ์ด์ผ ํจ (Shared Memory ๋ฐฉ์์ ๋๋์ด ์ค ํ์ ์์)
- โก ๊ฐ๊ฐ์ Processor๊ฐ 1000๊ฐ์ ์๋ฅผ ๋ํจ
- โข 100๊ฐ์ ํ๋ก์ธ์๊ฐ ๋ํ ๊ฒฐ๊ณผ๋ฅผ ํฉ์ณ์ค (์ ๋ฐ์ ์ฃผ๊ณ ์ ๋ฐ์ ๋ฐ์ ๋ํจ) โ ๋ฐ๋ณต
- ๋๊ธฐํ ๊ณผ์ ์ด ํ์ X โ Message๋ฅผ ์ฃผ๊ฑฐ๋ ๋ฐ๋ ๊ณผ์ ์ด Synchronization ์ ๊ณต (์ฃผ๊ฑฐ๋ ๋ฐ๋ Processor๊ฐ ์ค๋น๊ฐ ๋์ง ์๋๋ค๋ฉด ์๋ต X โ ์์ฐ์ค๋ฝ๊ฒ ๋๊ธฐํ)
limit <mark class="highlight"><strong><u> 100; half </u></strong></mark> 100; /* 100 processors */
repeat
half = (half+1)/2; /* send vs. receive dividing line */
if (Pn >= half && Pn < limit)
send(Pn - half, sum);
if (Pn < (limit/2))
sum = sum + receive();
limit = half; /* upper limit of senders */
until (half == 1); /* exit with final sum */
Network Topology
NUMA Topology ์
[Switch]โ[Switch]โ[Switch]โ[Switch]
โ โ โ โ
[Switch]โ[Switch]โ[Switch]โ[Switch]
โ โ โ โ
...
2-D grid or mesh, 3-D n-cube (hypercube) ๋ฑ.
- Processing Elements (PEs) ์ฌ๋ฌ ๊ฐ, Switch๋ก ์ฐ๊ฒฐ
- ๊ฐ์ฅ ๋ฉ๋ฆฌ ์๋ ๋ ธ๋๊น์ง ๊ฐ ์ ์๋ ์ = $n$ (n-cube)

Crossbar & Multi-Stage Interconnection Network
Crossbar
๋์์ ์ฌ๋ฌ ์ ์ฐ๊ฒฐ ๊ฐ๋ฅ. ์: P0์ P3 ์ฐ๊ฒฐ ๊ฐ๋ฅ.
Omega Network (Multi-stage interconnection network)
- 2ร2 Switch ์ฌ์ฉ: If P๊ฐ 16๊ฐ๋ผ๋ฉด $\log_2(16) = 4$ โ 4 stage ํ์
- 4ร4 Switch ์ฌ์ฉ: If P๊ฐ 16๊ฐ๋ผ๋ฉด $\log_4(16) = 2$ โ 2 stage
Switch (ํ ์๋ง ์ฐ๊ฒฐ)
Crossbar (์ฌ๋ฌ ์๋ ์ฐ๊ฒฐ ๊ฐ๋ฅ)
The Evolution-Revolution Spectrum of Computer Architecture
Evolutionary โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Revolutionary
Pipelining โ Cache โ Timeshared โ Virtual โ RISC โ CC-UMA โ CC-NUMA โ Not-CC-NUMA โ Message-passing โ Massive SIMD โ Parallel processing
- ๊ฐ์ฅ ํฐ ๋ฐ์ : Pipelining, Cache
- CC (Cache Coherency): Cache coherency๋ฅผ ๋ง์ถฐ์ค
- SIMD: Single Instruction Multiple Data โ Instruction์ ๊ฐ์ง๋ง Data๊ฐ ๋ค๋ฆ (๊ฐ์ฅ ์์ธก์ ๋ง์ด ์ฌ์ฉ)
RISC vs CISC
- RISC (Reduced Instruction Set Computer): ์ํ ์๊ฐ ๋์ผ, ํ์ฌ ๋๋ถ๋ถ ์ฌ์ฉ. ์ฅ์ : ํจ์จ์ ์ธ Pipelining.
- CISC (Complex Instruction Set Computer): Instruction์ ๊ธธ์ด๊ฐ ๋ค๋ฆ (์ํํ๋ ์๊ฐ์ด ๋ค๋ฆ). ์์ ์๋ Memory๊ฐ ๋น์ธ์ Instruction์ ๊ณต๊ฐ์ ์ค์ด๊ธฐ ์ํด์.
โ Intel Processor์ ๊ฒฝ์ฐ HW๋ RISC, SW๋ CISC ํ์ โ ๋ณํํ์ฌ ์ฌ์ฉ โ Application์ ํธํ์ฑ์ ์ํด. ๋๋ถ๋ถ์ RISC ํ์ .

์ ๋ฆฌ
| ๊ฐ๋ | ์ค๋ช |
|---|---|
| Shared Memory MP | ๋ชจ๋ processor๊ฐ ๊ฐ์ memory space ๊ณต์ (UMA/NUMA) |
| Message Passing MP | ๊ฐ์์ memory, message๋ก ํต์ (cluster, HPC) |
| Cache Coherence | Multi-level cache ๊ฐ ๊ฐ ์ผ์น ์ ์ง |
| Synchronization | Test-and-Set / Load-first๋ก atomic ์ฐ์ฐ ๊ตฌํ |
| Network Topology | Crossbar, Omega, 2D-mesh, n-cube |
| SIMD | ํ ๋ช ๋ น์ด๋ก ์ฌ๋ฌ ๋ฐ์ดํฐ ๋์ ์ฒ๋ฆฌ (GPU์ ๊ธฐ๋ฐ) |
Multiprocessor๋ ์ดํ Multi-core CPU + GPU + Cluster๋ก ์ด์ด์ง๋ ๋ชจ๋ ๋ณ๋ ฌ ์ปดํจํ ์ ์ด๋ก ์ ๊ธฐ๋ฐ์ด ๋๋ค.
Comments (0)
No comments yet. Be the first to comment!
Please to write a comment.