Lec 12 · 고급 CPU microarchitecture: ILP, superscalar, register renaming
정밀 정리 · 검증 2026-09-24 18:48
1개요
1.1앞 13분: Lecture 11 마무리 — nested interrupt, interrupt priority, exception 용 pipeline flush.
1.2성능 = T_cyc × CPI × instruction count, 여기에 program 의 ILP 가 superscalar(N)·superpipelined(M) 성능을 결정.
1.3in-order pipeline 은 independent instruction 도 dependency stall 에 같이 묶인다 → out-of-order execution 필요.
1.4WAR·WAW false dependency 는 hardware register renaming(map table + free list)으로 제거, physical register 는 새 binding 을 만든 instruction commit 때 반환.
1.5마지막에 OoO execution(dynamic scheduling)과 in-order commit 개념만 소개, 세부는 다음 강의.
2섹션별 정리 상황·문제 → 원인 → 해결
2.13:18–8:13[L11 이어서] nested interrupt(중첩 인터럽트)
상황·문제handler 진입 시 HW 가 interrupt 를 자동 disable. 지금까지 본 short handler 는 re-enable 하지 않았다.
원인handler 가 길면 그동안 오는 interrupt 를 놓친다. 그냥 enable 하면 다음 interrupt 가 EPC(SEPC)·cause·status 를 덮어써 복귀 PC 를 잃는다.
해결EPC 와 쓸 register 를 stack 에 저장한 뒤 status 의 interrupt enable bit 를 켠다. 끝에서 다시 disable 하고 복원 후 복귀.
- handler 안에서 synchronous exception 을 만들지 않게 작성해야 한다
- 예제는 MIPS(EPC, mfc0). RISC-V 는 SEPC 를 저장하고 다른 instruction 사용
- 0x405 로 enable, 0x404 로 disable (slide 25)
2.28:13–10:06[L11 이어서] interrupt priority(인터럽트 우선순위)
상황·문제interrupt source 마다 중요도가 다르다. mouse click 하나는 놓쳐도 되지만 disk failure 는 안 된다.
원인handler 안에서 모든 interrupt 를 re-enable 하면 interrupt 가 끝없이 들어와 정상 실행으로 돌아오지 못할 수 있다 (강의 표현 deadlock).
해결status register mask 로 priority 별로 선택 disable. 처리 중에는 더 높은 priority 만 re-enable.
- 여러 interrupt 가 동시에 오면 가장 높은 priority 부터 처리
- higher priority interrupt 는 지연되면 안 된다
2.310:06–12:55[L11 이어서] exception 처리를 위한 pipeline flush
상황·문제interrupt·exception 시 handler 로 jump 하려면 이미 pipeline 에 들어온 younger instruction 을 없애야 한다.
원인기존 5-stage datapath 에는 stage 별 flush 제어와 handler 주소 선택 경로가 없다.
해결ID·EX stage 앞에 0 을 넣는 mux(IF.Flush, ID.Flush, EX.Flush)로 pipeline register 를 0 으로 채워 flush. IF 의 PC mux 에 handler 주소 입력 추가.
- instruction 마다 PC 를 pipeline 에 싣고 다닌다
- 읽기: textbook 과 Smith & Pleszkun precise interrupt 논문
2.3.r.1Smith & Pleszkun, Implementing Precise Interrupts in Pipelined Processors (1988, PDF) ↗ · L11 slide 28 에서 권장한 precise interrupt 논문 원문
2.412:55–13:22출석 확인
상황·문제chat 으로 출석 확인 후 본 주제(Advanced CPU microarchitecture)로 넘어감.
2.513:22–15:11Lec12 도입: 고급 pipeline 과 hazard 복습
상황·문제지금까지 만든 5-stage RISC-V 보다 성능을 높이려면 superscalar, superpipelining, out-of-order execution(비순차 실행) 같은 기법이 필요하다.
원인pipeline 을 공격적으로 만들수록 data·control·structural hazard 가 stall 을 만들어 성능을 깎는다.
해결세 hazard 를 복습: data 는 instruction 간 data dependency, control 은 PC dependency, structural 은 resource 부족.
- data hazard 안에 RAW, WAR, WAW 세 종류
- 이번 강의 목표: 이런 hazard 가 만드는 stall 을 피하는 방법
2.615:11–17:47performance factor 와 ILP 의 위치
상황·문제CPU 성능 척도는 wall-clock time 이고 T_cyc × CPI × instruction count 로 나뉜다.
원인T_cyc 는 가장 긴 stage 의 max combinational delay, CPI 는 microarchitecture, instruction count 는 ISA·compiler 가 정한다.
해결식에 드러나지 않는 ILP(instruction-level parallelism, 명령어 수준 병렬성)도 성능을 좌우한다. 같은 instruction 수라도 ILP 에 따라 성능이 달라진다.
- ILP = program 안에서 동시에 실행할 수 있는 instruction 의 양
2.6.r.1Iron law of processor performance (Wikipedia) ↗ · time = instruction count × CPI × clock period
2.717:47–24:54ILP 의 정의와 계산
상황·문제program A 는 back-to-back dependency 가 많고 program B 는 independent instruction 이 많다. B 가 stall 이 적어 더 빠르다.
원인ILP 는 processor 가 아니라 program 의 성질이다. true dependency 가 있는 instruction 만 순서대로 실행해야 한다.
해결평균 ILP = (program 의 instruction 수) / (PE 가 무한할 때 필요한 cycle 수). PE(processing element)는 1 cycle 에 1 instruction 실행.
- 100개 중 2개만 dependency 이면 ILP = 100/2 = 50
- Code 1(연쇄 dependency): ILP = 3/3 = 1, Code 2(모두 independent): ILP = 3/1 = 3
- TLP, DLP 와 비교되는 개념
2.824:54–29:33scalar vs superpipelined vs superscalar
상황·문제baseline 5-stage scalar pipeline 은 operation latency 1, peak IPC 1 이라 ILP ≥ 1 이면 최대 성능.
원인superpipelined 는 baseline cycle 을 M 개 minor cycle 로 쪼개 minor cycle 마다 1개 완료, superscalar 는 폭 N 개 pipeline 을 둔다. 둘 다 operation latency 는 1 baseline cycle 그대로.
해결peak IPC 가 M (또는 N) 배가 되지만 program 에 ILP ≥ M (N) 이 있어야 그 성능이 나온다. 부족하면 stall.
- superpipelined: clock frequency M 배
- superscalar 예시는 N = 3: fetch·decode 를 3개씩 동시에
2.929:33–34:052-way superscalar datapath 와 N·M 개 independent instruction
상황·문제2-way superscalar 는 stage 마다 자원 2배가 필요: I-cache fetch 대역폭, register file read·write port, ALU 2개.
원인D-cache 처럼 늘 두 배로 할 수 없는 자원이 있다. 같은 cycle 의 두 ALU 사이 forwarding 은 stage 가 ALU latency 의 2배보다 길어야 해 비현실적.
해결같은 cycle 에 issue 하는 두 instruction 은 서로 independent 해야 하고, dependent 면 두 번째를 stall 한 뒤 forwarding.
- 다른 instruction 이 data memory 를 안 쓰면 D-cache 1개로 충분
- superscalar·superpipelined 모두 매 cycle N 또는 M 개 independent instruction 을 찾아야 peak 성능
2.1034:05–40:00in-order pipeline 의 한계
상황·문제superpipelined 이면서 superscalar 인 CPU 는 매 cycle N×M 개 independent instruction 이 필요하고, full forwarding 으로도 dependency stall 이 잦다.
원인addf→mulf RAW 로 mulf 가 D 에서 stall(근본 문제). 뒤의 subf 는 independent 인데 D stage 를 mulf 가 차지(structural hazard)하고 program order 때문에 추월 못 해 같이 stall.
해결subf 를 먼저 실행해도 결과는 맞다. 이 stall 은 근본 문제가 아니므로 out-of-order execution 으로 해결.
- 예시: 6-stage 비슷한 pipeline, EX 3 cycle, 첫 결과는 5 cycle 끝에 나옴
- in-order 에서는 stall 된 instruction 뒤의 모든 instruction 도 멈춘다
2.10.r.1Out-of-order execution (Wikipedia) ↗ · dynamic scheduling, in-order retire, CDC 6600·360/91·Pentium Pro·R10000 역사
2.1140:00–45:50false dependency 와 register renaming 개념
상황·문제instruction 을 out-of-order 로 실행하려면 WAR(write-after-read)·WAW(write-after-write) dependency 가 문제다. 먼저 실행하면 잘못된 operand·최종값이 남는다.
원인WAR·WAW 는 data 가 아니라 register 이름이 겹쳐서 생기는 false dependency. RISC-V 는 architectural register 가 32개뿐이라 이름을 재사용하게 된다.
해결register 가 무한하면 WAR·WAW 를 완전히 제거 가능. CPU 안에 register 를 더 두고(예 60개) 이름을 바꿔 쓰는 것이 register renaming.
- RAW(true dependency)는 어떻게 할 수 없다 → forwarding 으로 영향만 줄임
- WAR·WAW 는 자원(register)을 늘리면 없앨 수 있다
2.1245:50–50:44register renaming 예제: ILP 1 → 2
상황·문제원래 4개 instruction 은 RAW(파랑)와 WAR·WAW(빨강) 때문에 infinite PE 로도 4 cycle, ILP = 4/4 = 1.
원인3·4번째 instruction 의 r1·r3 가 앞 instruction 과 이름만 겹친다.
해결r8, r9 로 이름을 바꾸면 독립 쌍 두 개가 생겨 ILP = 4/2 = 2. 순서를 바꾸면 superpipelining, 여러 pipeline 이면 superscalar 로 빨라진다.
- 남는 RAW dependency 가 성능 한계를 정한다
- 강의자: 필요하면 특정 부분만 한국어로 다시 설명하겠다
2.1350:44–58:24hardware register renaming: rename table 과 map table 예제
상황·문제compiler 가 이미 만든 program 을 software 도움 없이 hardware 가 rename 해야 한다.
원인rename table 이 architectural register → physical register binding 을 유지. compiler 는 physical register 를 모르고, 개수·구성은 microarchitecture 마다 다르다.
해결rd 를 쓰는 instruction 이 issue 될 때 free physical register px 를 할당해 binding 기록. source 는 table 을 보고 변환.
- 예: r1~r3 → p1~p3, free p4~p7
- add r1,r2,r3 → add p4,p2,p3 / sub → p5 / mul → p6 / div r1,4,r1 → div p7,4,p4
- 같은 instruction 의 r1 도 source(p4)와 destination(p7)은 다른 physical register
2.1458:24–1:08:50Q&A: architectural register 를 늘리지 않는 이유, free list overhead, physical register 수
상황·문제질문: architectural register 를 그냥 늘리면? free list 는 낭비 아닌가? physical register 는 몇 개 필요? rename 으로 cycle 이 길어지나?
원인architectural register 수는 ISA 가 정한다. 늘리면 instruction 길이가 늘고 RISC-V 가 아닌 다른 architecture 가 된다.
해결ISA 호환을 지키며 physical register 를 늘리고 동적으로 mapping. 필요한 수는 pipeline 에 동시에 있는 instruction 수와 관계, diminishing return·용도(server vs mobile)로 결정. rename 은 decode stage 에 넣거나 table 이 크면 별도 stage.
- free list 는 overhead 지만 성능 향상에는 diminishing return 이 따른다
- free list 없이 하는 방식도 있다 (뒤 slide 의 P6 방식)
- 한국어로 답변
2.151:08:50–1:15:00physical register 는 언제 free list 로 돌려주나
상황·문제r1 의 binding 이 p4 에서 p7 로 바뀐 뒤 p4 를 언제 free 해도 되는가?
원인새 binding 이 생겼다고 바로 지우면, 아직 실행 안 된 이전 instruction 이 p4 대신 p7 을 보게 되어 결과가 달라질 수 있다 (OoO 에서).
해결r1 에 새 binding 을 만든 instruction 이 commit 될 때(pipeline 에서 가장 오래된 instruction 으로 실행 완료) 이전 binding(r1→p4)을 제거.
- slide 22 의 'see slide 37' 과 같은 내용
- OoO execution 을 배우면 더 이해될 것이라며 마무리
- 답한 학생 3명에게 1점씩
2.161:15:00–1:15:52중간고사 일정 공지
상황·문제중간고사가 다음 시간까지 범위이며 일정(화요일)을 다시 공지하겠다고 안내.
2.171:15:52–1:20:05out-of-order execution 개념
상황·문제renaming 으로 WAR·WAW 는 사라지지만 RAW 에서는 reader 가 writer 결과를 기다려야 한다(근본적).
원인independent instruction 은 기다릴 이유가 없는데 in-order 는 program 순서로 막는다.
해결hardware 가 동적으로 independent instruction 을 먼저 issue 하는 OoO execution(=dynamic instruction scheduling). 단 외부에 드러나지 않게 architectural state 갱신(commit)은 in-order.
- static scheduling 은 compiler, dynamic 은 hardware 가 다시 스케줄
- 예제 6개 instruction 은 rename 후 infinite PE 에서 3 cycle
- dependence distance > issue distance 이면 RAW 도 성능 영향 없음
2.17.r.1Out-of-order execution (Wikipedia) ↗ · dynamic scheduling, in-order retire, CDC 6600·360/91·Pentium Pro·R10000 역사
3핵심 개념
3.1nested interrupt(중첩 인터럽트)
handler 안에서 EPC 등 저장 후 interrupt 를 re-enable. 더 높은 priority 만 허용.
3.2ILP(instruction-level parallelism, 명령어 수준 병렬성)
program 의 성질. instruction 수 / 무한 PE 로 필요한 cycle 수.
3.3superpipelining(슈퍼파이프라이닝)
baseline cycle 을 M minor cycle 로 쪼개 minor cycle 마다 1개 완료. ILP ≥ M 필요.
3.4superscalar(슈퍼스칼라)
폭 N 의 병렬 pipeline, peak IPC N. 매 cycle N 개 independent instruction 필요.
3.5false dependency(거짓 의존성)
WAR·WAW. data 가 아니라 register 이름 재사용에서 생긴다.
3.6register renaming(레지스터 이름 바꾸기)
architectural register 를 매번 새 physical register 에 mapping 해 false dependency 제거.
3.7rename table / map table
architectural → physical binding 표. write 마다 새 binding, read 는 표 조회.
3.8free list(프리 리스트)
할당 가능한 physical register 목록. 이전 binding 은 새 binding 을 만든 instruction 의 commit 때 반환.
3.9out-of-order execution(비순차 실행)
independent instruction 을 먼저 issue 하는 dynamic scheduling. commit 은 in-order.
3.9.r.1Out-of-order execution (Wikipedia) ↗ · dynamic scheduling, in-order retire, CDC 6600·360/91·Pentium Pro·R10000 역사
3.10in-order commit(순서 유지 커밋)
architectural state 갱신을 program order 로 해 OoO 를 외부에 숨긴다.
4스스로 확인
4.1handler 안에서 interrupt 를 re-enable 하기 전에 무엇을 해야 하나?
답
EPC(SEPC) 와 사용할 register 를 stack 에 저장. 그리고 higher priority interrupt 만 enable.
4.2100개 instruction 중 2개만 서로 dependent 이면 ILP 는?
답
infinite PE 로 2 cycle 이므로 100/2 = 50.
4.3superpipelined(M) + superscalar(N) CPU 가 peak 성능을 내려면?
답
매 cycle N×M 개 independent instruction 이 있어야 한다.
4.4in-order pipeline 예제에서 subf 가 stall 되는 이유 두 가지는?
답
mulf 가 D stage 를 차지(structural hazard)하고, program order 때문에 mulf 를 추월할 수 없다.
4.5WAR·WAW 를 false dependency 라 부르는 이유는?
답
data 를 주고받지 않고 register 이름만 겹친다. register 를 늘리면(renaming) 제거된다.
4.6div r1,4,r1 은 slide 22 예제에서 어떻게 rename 되나?
답
source r1 은 당시 map 의 p4, destination r1 은 새 free register p7 → div p7,4,p4.
4.7RISC-V architectural register 를 48개로 늘리지 않는 이유는?
답
instruction encoding 이 바뀌어 더 이상 RISC-V 가 아니다. 대신 physical register 를 늘려 동적 mapping.
5참고 자료
5.4Out-of-order execution (Wikipedia) ↗ · dynamic scheduling, in-order retire, CDC 6600·360/91·Pentium Pro·R10000 역사
5.5Smith & Sohi, The Microarchitecture of Superscalar Processors (1995, PDF) ↗ · slide 27·35·50 의 논문 비평 대상, renaming·ROB·issue window 설명
5.6Olukotun et al., The Case for a Single-Chip Multiprocessor (ASPLOS'96, PDF) ↗ · slide 45·46 의 6-way SS vs 4×2-way MP 같은 면적 비교 원 논문






























