Computer Science/์ปดํ“จํ„ฐ๊ตฌ์กฐ๋ก 

CH 1. Computer Architecture

kite707 2024. 4. 22.

์ปดํ“จํ„ฐ ๊ตฌ์กฐ์˜ ํฐ 3๊ฐ€์ง€ ์š”์†Œ๋Š” CPU, Memory, I/O์ด๋‹ค.

ํ”„๋กœ๊ทธ๋žจ์€ ํฌ๊ฒŒ 3๊ฐ€์ง€๋กœ ๋‚˜๋ˆ„์–ด ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

  • Application Software
    • ๊ณ ๊ธ‰ ์–ธ์–ด๋กœ ์ž‘์„ฑ๋˜์–ด ์žˆ๋‹ค.
  • System Software
    • Compiler(์ปดํŒŒ์ผ๋Ÿฌ): HLL(High-level language)์ฝ”๋“œ๋ฅผ ๊ธฐ๊ณ„์–ด๋กœ ๋ฒˆ์—ญํ•œ๋‹ค.
    • Operating System(์šด์˜์ฒด์ œ): I/O๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ , ๋ฉ”๋ชจ๋ฆฌ์™€ ์ €์žฅ๊ณต๊ฐ„์„ ๊ด€๋ฆฌํ•œ๋‹ค. ์ผ๋“ค์„ ์Šค์ผ€์ค„๋งํ•˜๊ณ  ์ž์›์„ ๊ณต์œ ํ•œ๋‹ค.
  • Hardware
    • Processor, Memory, I/O controllers๊ฐ€ ํฌํ•จ๋œ๋‹ค.

์•ž์„œ ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ HLL์„ ๊ธฐ๊ณ„์–ด๋กœ ๋ฒˆ์—ญํ•œ๋‹ค๊ณ  ํ–ˆ๋Š”๋ฐ ํ”„๋กœ๊ทธ๋žจ ์ฝ”๋“œ๋Š” High-level language, Assembly language, Hardware representation 3๊ฐ€์ง€ ๋‹จ๊ณ„๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ๋‹ค.

์ปดํ“จํ„ฐ์˜ ์„ฑ๋Šฅ

์ด์ œ ์ปดํ“จํ„ฐ์˜ ์„ฑ๋Šฅ์— ์˜ํ–ฅ์„ ๋ฏธ์น˜๋Š” ์š”์†Œ๋“ค์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜์ž.

๋จผ์ € ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์žˆ๋‹ค. ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ operation step์ˆ˜๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค.

Programming language, compiler, architecture๋Š” operation๋‹น ์‹คํ–‰๋˜์–ด์•ผ ํ•˜๋Š” machine instructions์˜ ์ˆ˜๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค.

Processor, Memory system์€ ๋ช…๋ น์–ด๋“ค์ด ์–ผ๋งˆ๋‚˜ ๋นจ๋ฆฌ ์‹คํ–‰๋˜๋Š”์ง€๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค.

I/O system(OSํฌํ•จ)์€ I/O operation์ด ์–ผ๋งˆ๋‚˜ ๋นจ๋ฆฌ ์‹คํ–‰๋˜๋Š”์ง€๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค.

์ปดํ“จํ„ฐ ์„ฑ๋Šฅ์„ ์ธก์ •ํ•˜๋Š” ์ง€ํ‘œ๋Š” ํฌ๊ฒŒ Response time(์‘๋‹ต ์‹œ๊ฐ„)๊ณผ Throughput(์ฒ˜๋ฆฌ๋Ÿ‰)์œผ๋กœ ๋‚˜๋‰œ๋‹ค. Response time์€ ์ผ์„ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„, Throughput์€ ๋‹จ์œ„์‹œ๊ฐ„๋‹น ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ์–‘์„ ์˜๋ฏธํ•œ๋‹ค.

์„ฑ๋Šฅ ๋น„๊ต

์ปดํ“จํ„ฐ์˜ ์„ฑ๋Šฅ์€ ์•„๋ž˜ ์ˆ˜์‹์ฒ˜๋Ÿผ ํ‘œํ˜„ํ•œ๋‹ค.

์˜ˆ์‹œ๋ฅผ ๋“ค์–ด ์ดํ•ดํ•˜๋ฉด ํŽธํ•œ๋ฐ ๋งŒ์ผ ๊ฐ™์€ ์ผ์„ ํ•˜๋Š”๋ฐ A๋Š” 10์ดˆ๊ฐ€ ๊ฑธ๋ฆฌ๊ณ  B๋Š” 15์ดˆ๊ฐ€ ๊ฑธ๋ ธ๋‹ค๊ณ  ํ•˜์ž. ์ง๊ด€์ ์œผ๋กœ A๊ฐ€ ๋” ๋น ๋ฅด๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ์ง€๋งŒ ์ˆ˜์‹์œผ๋กœ ๊ณ„์‚ฐํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

์ฆ‰ A๋Š” B๋ณด๋‹ค 1.5๋ฐฐ ๋น ๋ฅด๋‹ค.

Execution Time

๊ทธ๋Ÿผ ์‹คํ–‰ ์‹œ๊ฐ„์€ ์–ด๋–ป๊ฒŒ ์ธก์ •ํ• ๊นŒ? ์ด๋ฅผ ์œ„ํ•ด Elapsed Time๊ณผ CPU Time์ด๋ผ๋Š” ๊ฒƒ์ด ์žˆ๋‹ค. Elapsed Time๋Š” ์ด ์‘๋‹ต์‹œ๊ฐ„์ด๋‹ค. ์ฆ‰ Processing, I/O, OS overhead, idle time๋“ฑ์„ ๋ชจ๋‘ ํฌํ•จํ•˜๋ฉฐ system performance๋ฅผ ๊ฒฐ์ •ํ•œ๋‹ค. CPU Time์€ ํ•ด๋‹น ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„, ์ฆ‰ Processing์— ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„๋งŒ์„ ์˜๋ฏธํ•œ๋‹ค.

CPU Clocking

์ด๋Ÿฐ ์‹œ๊ฐ„์„ ์ธก์ •ํ•˜๊ธฐ ์œ„ํ•ด Clock์„ ์‚ฌ์šฉํ•œ๋‹ค.

Clock Period(์ฃผ๊ธฐ)๋Š” 1์‚ฌ์ดํด๋‹น ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„์„ ์˜๋ฏธํ•œ๋‹ค.

Clock frequency(rate, ์ง„๋™์ˆ˜)๋Š” 1์ดˆ์— ๋ช‡๋ฒˆ์˜ cycle์„ ๋Œ ์ˆ˜ ์žˆ๋Š”์ง€๋ฅผ ์˜๋ฏธํ•œ๋‹ค.

CPU Time์€ ์•„๋ž˜ ์ˆ˜์‹์œผ๋กœ ๋‚˜ํƒ€๋‚ธ๋‹ค.

์ด ์—ญ์‹œ ๋‹น์—ฐํ•œ ์–˜๊ธฐ์ธ๋ฐ ๋งŒ์ผ ํŠน์ • ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ 10๋ฒˆ์˜ ์‚ฌ์ดํด์ด ๋Œ์•˜๋‹ค๊ณ  ์น˜์ž. ๊ทธ๋ฆฌ๊ณ  1์ดˆ์— 5๋ฒˆ์˜ ์‚ฌ์ดํด์ด ๋Œ ์ˆ˜ ์žˆ๋‹ค๋ฉด ํ•ด๋‹น ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๋Š”๋ฐ ๊ฑธ๋ฆฐ ์‹œ๊ฐ„์€ 2์ดˆ๋ผ๋Š” ๊ฒƒ์„ ์ง๊ด€์ ์œผ๋กœ ์•Œ ์ˆ˜ ์žˆ๋‹ค. Cpu Clock Cycle = 10, Clock Rate = 5์ธ ์ƒํ™ฉ์ด๋‹ค.

์œ„ ์ˆ˜์‹์— ๋”ฐ๋ผ ์„ฑ๋Šฅ์€ ์•„๋ž˜ ์กฐ๊ฑด๋“ค์— ์˜ํ•ด ํ–ฅ์ƒ๋œ๋‹ค๋Š” ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

  • Clock Cycle์˜ ์ˆ˜ ๊ฐ์†Œ(๋ถ„์ž)
  • Clock Rate ์ฆ๊ฐ€(๋ถ„๋ชจ)

๋‘ ๊ฐ€์ง€๋Š” ์„œ๋กœ ์ข…์†์ ์ด๊ธฐ ๋•Œ๋ฌธ์—, ํ•˜๋“œ์›จ์–ด ๋””์ž์ด๋„ˆ๋Š” ์ข…์ข… ํด๋Ÿญ ์†๋„์™€ ํด๋Ÿญ ์‚ฌ์ดํด ์ˆ˜ ์‚ฌ์ด์—์„œ ๊ฒฐ๋‹จ์„ ๋‚ด๋ฆฌ๊ฒŒ ๋œ๋‹ค.

โญ ์˜ˆ์ œ
Computer A: 2GHz clock, 10s CPU time
Computer B๋ฅผ ๋””์ž์ธ ํ•˜๋ ค๊ณ  ํ•  ๋•Œ CPU time์€ 6s์ด๊ณ , clock์„ ๋น ๋ฅด๊ฒŒ ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ clock cycle์ด 1.2๋ฐฐ ์ฆ๊ฐ€ํ•˜๊ฒŒ ๋œ๋‹ค. ์ด ๊ฒฝ์šฐ Computer B์˜ clock์€ ์–ผ๋งˆ๋‚˜ ๋นจ๋ผ์งˆ ์ˆ˜ ์žˆ๋Š”๊ฐ€?

Instruction Count and CPI

Clock Cycle์˜ ๊ฒฝ์šฐ Instruction Count x Cycles per Instruction(CPI)๋กœ ๊ตฌํ•œ๋‹ค.

์—ฌ๊ธฐ์„œ Instruction Count๋Š” program, ISA, compiler์— ์˜ํ•ด ๊ฒฐ์ •๋œ๋‹ค. ๋˜ Average Cycles per instruction์€ CPU ํ•˜๋“œ์›จ์–ด์— ์˜ํ•ด ๊ฒฐ์ •๋œ๋‹ค. ๋งŒ์ผ ๋‹ค๋ฅธ CPI๊ฐ€ ๋ช…๋ น์–ด๋งˆ๋‹ค ๋‹ค๋ฅด๋‹ค๋ฉด ํ‰๊ท  CPI๋Š” ๋ช…๋ น์–ด ๋ชจ์Œ(instruction mix)์— ์˜ํ–ฅ์„ ๋ฐ›์„ ๊ฒƒ์ด๋‹ค.

์ด์ œ CPI๋ฅผ ์˜ˆ์ œ๋ฅผ ํ†ตํ•ด ์ดํ•ดํ•ด๋ณด๋„๋ก ํ•˜์ž.

 

โญ ์˜ˆ์ œ
Computer A: Cycle Time = 250ps, CPI = 2.0
Computer B: Cycle Time = 500ps, CPI = 1.2
ISA๊ฐ€ ๊ฐ™๋‹ค๊ณ  ๊ฐ€์ •ํ–ˆ์„ ๋•Œ ์–ด๋–ค ์ปดํ“จํ„ฐ๊ฐ€ ์–ผ๋งˆ๋‚˜ ๋น ๋ฅธ๊ฐ€?

Average CPI

๋งŒ์ผ ๋ช…๋ น์–ด์˜ ์ข…๋ฅ˜๊ฐ€ ๋‹ค์–‘ํ•˜๋‹ค๋ฉด ๋ช…๋ น์–ด๋‹น CPI๋„ ๋‹ค๋ฅผ ๊ฒƒ์ด๋‹ค. ์ด๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์„ฑ๋Šฅ์„ ๋น„๊ตํ•˜๊ธฐ ์œ„ํ•ด Average CPI๋ผ๋Š” ๊ฐœ๋…์ด ์žˆ๋‹ค. ์ง๊ด€์ ์œผ๋กœ ๊ฐ ๋ช…๋ น์–ด๋‹น CPI๋ฅผ ์ ์šฉํ•ด ์ „์ฒด clock cycle์„ ๊ตฌํ•œ ๋’ค, ํ‰๊ท ์„ ๋‚ด์ฃผ๋ฉด ๋œ๋‹ค. ์ˆ˜์‹์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

์˜ˆ์ œ๋ฅผ ํ†ตํ•ด ์ดํ•ดํ•ด ๋ณด๋„๋ก ํ•˜์ž.

 

โญ ์˜ˆ์ œ
class A B C
CPI for class 1 2 3
IC in sequence 1 2 1 2
IC in sequence 2 4 1 1
๊ฐ Sequence์—์„œ์˜ Average CPI๋ฅผ ๊ตฌํ•ด๋ณด๋„๋ก ํ•˜์ž.

Performance Summary

์š”์•ฝํ•˜์ž๋ฉด ์„ฑ๋Šฅ์€ ์•„๋ž˜ ์š”์†Œ๋“ค๊ณผ ์—ฐ๊ด€์ด ์žˆ๋‹ค.

  • Algorithm: IC(Instruction Count)์— ์˜ํ–ฅ์„ ๋ฏธ์น˜๊ณ  CPI์— ์˜ํ–ฅ์„ ๋ฏธ์น  ์ˆ˜ ์žˆ๋‹ค.
  • Programming language: IC์™€ CPI์— ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค.
  • Compiler: IC์™€ CPI์— ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค.
  • ISA(Instruction Set Architecture: IC, CPI, Tc(Total Execution Time)์— ์˜ํ–ฅ์„ ๋ฏธ์นœ๋‹ค.

๋Œ“๊ธ€