Lec 7 · Speculative execution: ROB, in-order commit, register renaming
정밀 정리 · 검증 2026-09-24 01:45
1개요
1.1Lec6 정정(분기 미해소 시 'dispatch' 금지) 후 speculation 의 동기와 imprecise interrupt 문제.
1.2ROB 로 in-order commit 을 강제해 precise exception·오예측 복구, speculative Tomasulo 4단계와 7-명령어 예제.
1.3memory hazard 처리, OoO design space(RS 위치·분산/중앙) 토론.
1.4renaming 두 방식: Data-in-ROB vs unified physical register file, physical register 해제 시점. p24 이후(관리 예제·superscalar renaming)는 다음 강의로.
2섹션별 정리 상황·문제 → 원인 → 해결
2.10:00–3:07행정 안내
상황·문제project proposal 채점·코멘트 메일 발송(재제출 불필요, progress presentation 에서 반영). paper critique #1 KLMS 게시, 마감 다음 주 화요일 11:59 p.m.(슬라이드: Oct. 19).
2.23:07–4:44Lec6 정정: 분기 해소 전에는 dispatch 하지 않는다
상황·문제Lec6 'Dynamic Loop Unrolling Example' 의 'FP instructions do not start execution until all prior branches are resolved' 를 정정하겠다고 약속했던 부분.
원인reservation station 에 들어간 뒤에는 entry 사이에 program order 정보가 없어 '실행 시작'만 막아서는 순서를 보장할 수 없음.
해결'start execution' 을 지우고 'should not be dispatched' 로 판서 정정. 분기 결과가 불확실하면 이후 명령어를 RS 로 dispatch 하지 않음.
- 정정 대상 슬라이드는 이번 덱에 없는 Lec6 슬라이드(영상 속 3쪽)
- RS 안에서는 program order 를 모름 → 입구(dispatch)에서 막아야 함
2.2.r.1Tomasulo's algorithm — Wikipedia ↗ · RS·CDB 기반 동적 스케줄링, imprecise exception 한계와 speculation 확장 언급
2.34:44–8:15Speculation 의 동기와 정의
상황·문제Tomasulo 는 RS 로 register renaming·OoO 실행을 주지만 branch prediction 너머로 실행을 이어갈 수 없음.
원인결과가 확정되지 않은 branch 뒤 명령어가 architectural state 를 바꾸면, 예측이 틀렸을 때 올바른 상태로 복구할 방법이 없음.
해결speculation: branch prediction 이 항상 맞고 exception 이 없다고 가정하고 fetch·issue·execute + 틀리면 복구하는 mechanism. dynamic scheduling + speculation ≈ data flow execution model.
- control dependence 를 hardware speculation 으로 극복 (p2)
- von Neumann 구조이면서 dataflow 실행의 이점을 얻음
2.48:15–11:56Speculation 은 틀릴 수 있다: imprecise interrupt
상황·문제99.99% 맞는 branch predictor 라도 가끔 틀림. IBM 360/91 은 branch 는 speculate 하지 않았지만 앞선 명령어에 exception 이 없다고 speculate.
원인RS 안에서 일부 명령어가 부분 실행되어 '여기까지 commit, 이후는 영향 없음'인 PC 하나를 특정할 수 없음 → imprecise interrupt.
해결debugging 이 어렵고 page fault 처럼 해당 명령어에서 재시작해야 하는 trap 은 사실상 구현 불가. 따라서 틀린 speculation 지점에서 recover·restart 하는 mechanism 필요.
- Computer stopped at this PC; its likely close to this address (p2)
- page fault: 디스크→메모리 로드 후 fault 명령어부터 재시작해야 함
2.4.r.2Smith & Pleszkun, Implementing Precise Interrupts in Pipelined Processors (IEEE TC 1988) ↗ · precise interrupt 정의와 reorder buffer 를 제안한 원 논문 (Sec. IV)
2.511:56–17:24In-order commit 과 Reorder Buffer
상황·문제Tomasulo 에서는 먼저 끝난 명령어가 register file 을 먼저 갱신(out-of-order commit)해 이전 상태로 되돌릴 수 없음.
원인architectural state 갱신 순서가 program order 와 다름.
해결in-order fetch/decode/dispatch → RS 에서 OoO issue → OoO completion(결과는 ROB) → ROB head 부터 in-order commit. exception·오예측은 commit 에서 감지해 newer 명령어를 kill 하고 handler PC(또는 correct PC)에서 fetch.
- commit = 명령어가 더 이상 speculative 가 아닐 때 (p3)
- 이 강의에서 dispatch ≠ issue
2.5.r.1Re-order buffer — Wikipedia ↗ · ROB 로 OoO·speculative 실행 후 in-order commit, precise exception·branch mispredict rollback
2.5.r.2Smith & Pleszkun, Implementing Precise Interrupts in Pipelined Processors (IEEE TC 1988) ↗ · precise interrupt 정의와 reorder buffer 를 제안한 원 논문 (Sec. IV)
2.5.r.3Out-of-order execution — Wikipedia ↗ · precise exception, reorder buffer, graduation/retire, dispatch-issue decoupling
2.617:24–22:02ROB 동작과 entry 필드
상황·문제Tomasulo 구조에 ROB 를 추가할 때 결과 보관·operand 공급·tag 를 어떻게 바꾸는가.
원인결과가 commit 전까지 ROB 에 머물므로 newer 명령어의 operand 공급원이 되어야 함.
해결CDB tag 를 RS 번호 대신 ROB 번호로. RS 는 ROB 에 최신 값이 있으면 ROB 에서, 없으면 register file 에서 operand 를 받음. ROB 가 store buffer 를 대체. entry = instruction type·destination·value·ready.
- commit: ROB head 값 → register (store 는 memory) (p4)
- branch 는 destination 없음, store 는 memory address (p5)
2.6.r.1Re-order buffer — Wikipedia ↗ · ROB 로 OoO·speculative 실행 후 in-order commit, precise exception·branch mispredict rollback
2.6.r.2MIT 6.823 Handout #9 — Out-of-Order Execution with ROB ↗ · data 를 ROB 에 두는 설계, rename table 의 present bit·tag, dispatch/commit 규칙
2.722:02–26:06Speculative Tomasulo 의 4단계
상황·문제Tomasulo 3단계에 commit 단계를 추가.
원인ROB entry 가 없으면 결과를 둘 곳이 없음.
해결1 Dispatch: RS 와 ROB slot 이 모두 비어야, destination 의 ROB 번호 전달. 2 Issue&Execute: 두 operand 준비 시 실행(RAW 확인). 3 Write result: CDB 로 RS·ROB 에 기록. 4 Commit(graduation): head 가 완료되면 갱신, 오예측이면 ROB flush.
- ROB 번호가 CDB tag
- commit 을 graduation 이라고도 부름 (p6)
2.7.r.1Tomasulo's algorithm — Wikipedia ↗ · RS·CDB 기반 동적 스케줄링, imprecise exception 한계와 speculation 확장 언급
2.826:06–34:04ROB 예제: LD·ADDD·DIVD·BNE 와 speculative 명령어
상황·문제LD F0 → ADDD F10 → DIVD F2 → BNE F2 → (예측 경로) LD F4 → ADDD F0 → ST F4 를 ROB1~7 에 넣어 추적.
원인BNE 는 DIVD 의 F2 를 기다려(RAW) 미해결, 그 뒤 명령어는 branch prediction 에 따른 speculative.
해결RS 는 값 대신 producer ROB 번호(ROB1, ROB2, ROB5)를 기록. LD F4 완료 시 M[10] 이 ROB5 와 ST·ADDD 로 전달되나 oldest 가 아니면 commit 불가. 오예측이면 BNE 가 commit 될 때 뒤 entry 를 flush 만 하면 됨.
- F6 은 producer 가 없어 register file 에서 읽음 (p12)
- 완료(Y)여도 head 가 아니면 commit 대기 (p14)
2.8.r.1Re-order buffer — Wikipedia ↗ · ROB 로 OoO·speculative 실행 후 in-order commit, precise exception·branch mispredict rollback
2.934:04–36:28Q&A: ROB·RS 가 가득 차면
상황·문제ROB 또는 RS 가 가득 차면 어떻게 되는가 (채팅 질문).
원인dispatch 에는 RS entry 와 ROB entry 가 모두 필요.
해결FP op queue 에서 dispatch 를 stall, commit 으로 entry 가 비면 재개. 요즘 고성능 프로세서 ROB 는 100개 이상, 때로 200개 이상.
- 충분한 크기의 RS·ROB 로 stall 방지
2.9.r.1Out-of-order execution — Wikipedia ↗ · precise exception, reorder buffer, graduation/retire, dispatch-issue decoupling
2.1036:28–42:25Memory 를 통한 hazard
상황·문제register 가 아닌 memory 주소를 통한 hazard 는 어떻게 지키는가.
원인store 와 load 가 같은 주소를 접근할 수 있음 (예: ST F4,0(R3) 와 LD F4,0(R3)).
해결WAW·WAR: store 는 ROB head 에서만 memory 갱신 → 앞선 load/store 가 남아 있을 수 없음. RAW: load 주소를 program order 로 계산하고 ROB 의 앞선 store 와 주소가 같으면 memory 접근 금지, 값은 ROB/CDB 에서 받음.
- Q: 같은 unit 에 여러 명령어가 동시에 ready → 강사: oldest 우선이 자연스럽지만 결과는 ROB 에서 in-order commit 되므로 순서 무관
2.10.r.1Memory disambiguation — Wikipedia ↗ · memory 를 통한 RAW/WAR/WAW, store-to-load forwarding, 앞선 store 주소 확인
2.10.r.2Data dependency — Wikipedia ↗ · RAW(true)·WAR(anti)·WAW(output) 정의, name dependence 는 renaming 으로 제거
2.1142:25–56:53OoO design space: RS 위치와 구성
상황·문제RS 를 ROB 일부로 둘지 별도 issue window 로 둘지, FU 별 분산인지 중앙 집중인지.
원인두 축 모두 ILP 발견 능력과 배선·면적 비용이 맞바뀜.
해결분산/별도 RS: FU 와 가깝고 짧은 배선. ROB=RS: 한 구조에서 tag 비교, 더 큰 window 로 ILP↑ 이지만 완료된 명령어에도 operand field 가 남아 면적 낭비. 중앙 RS: 연산 종류 편중에도 활용도↑. 분산된 ROB+RS 조합은 가능하나 oldest 판별 비용.
- ROB 는 RS 보다 커야 함 (완료 후 commit 대기 명령어 포함)
- utilization vs design cost trade-off
2.11.r.1Out-of-order execution — Wikipedia ↗ · precise exception, reorder buffer, graduation/retire, dispatch-issue decoupling
2.1256:53–1:07:24Data-in-ROB 설계 (HP PA8000, Pentium Pro 등)
상황·문제renaming 방식 1: source·result data 를 ROB 에 두고 별도 architectural register file 유지.
원인ROB 가 circular buffer 로 program order 를 유지, tag = ROB index(free pointer).
해결dispatch: ARF 값을 Src 에 복사하고 p set, 아니면 producer tag 복사·p clear. CDB write 시 tag 검색해 복사. commit: exception 이면 trap, 아니면 ARF 갱신. trap 시 free=oldest 로 flush. rename table <p,tag,value>, commit 시 <1,_,Result>.
- dispatch 때 ROB 에 더 새 값이 있으면 ARF 값을 bypass (p20·p21)
- 강사가 처음 source 가 RS 에 있다고 했다가 ROB data field 로 정정
2.12.r.1MIT 6.823 Handout #9 — Out-of-Order Execution with ROB ↗ · data 를 ROB 에 두는 설계, rename table 의 present bit·tag, dispatch/commit 규칙
2.12.r.2P6 (microarchitecture) — Wikipedia ↗ · Pentium Pro 의 speculative·OoO 실행, retire unit, register renaming
2.12.r.3Register renaming — Wikipedia ↗ · ROB 방식 vs tag-indexed(physical) register file, 이전 tag 를 free queue 로 돌려주는 시점
2.131:07:24–1:10:30Unified physical register file (MIPS R10K, Alpha 21264 등)
상황·문제renaming 방식 2: ROB 에 data 없이 모든 값을 하나의 physical register file 에.
원인decode 때 architectural register 를 physical register 로 rename 만 하고 값은 읽지 않음.
해결FU 는 unified register file 에서 읽고 씀. commit 은 data 이동 없이 architectural→physical mapping 만 갱신. PRF 는 committed 와 speculative 값을 모두 보유.
- physical register 가 ROB entry 와 분리됨 (p23)
- Data-in-ROB 의 ROB 칸은 사실상 physical register 였던 것
2.13.r.1MIT 6.5900 Quiz 1 handout — Physical Register File Design ↗ · rename table·physical register file·free list·ROB(tag 만 보관) 구성
2.13.r.2Register renaming — Wikipedia ↗ · ROB 방식 vs tag-indexed(physical) register file, 이전 tag 를 free queue 로 돌려주는 시점
2.141:10:30–1:15:25Rename 예제와 physical register 해제 시점
상황·문제destination 마다 free physical register 를 새로 배정하고 source 는 mapping 을 따라 rename (x1→P1 이므로 addi 의 source 도 P1).
원인physical register 수가 유한해 재활용해야 하는데, 언제 P5 를 해제해도 안전한가.
해결RAW 는 mapping 으로 보존, WAR·WAW 는 새 register 배정으로 제거. P5(x6) 는 x6 를 다시 쓰는 다음 명령어가 commit 될 때 해제: 그 앞의 P5 사용자도 모두 commit 됨.
- Px·Py·Pz·Pw 는 코드만으로 알 수 없는 이전 mapping (p23)
- 학생 답에 빠진 핵심어 = commit
2.14.r.1Register renaming — Wikipedia ↗ · ROB 방식 vs tag-indexed(physical) register file, 이전 tag 를 free queue 로 돌려주는 시점
2.14.r.2Data dependency — Wikipedia ↗ · RAW(true)·WAR(anti)·WAW(output) 정의, name dependence 는 renaming 으로 제거
2.151:15:25–1:16:30Physical register 관리 예제 예고, 다음 수업 안내
상황·문제p24 rename table·physical regs·free list·ROB(LPRd) 예제는 시간이 없어 다음 강의로. 다음 월요일 휴일이라 수요일 수업, 보강 예정.
3핵심 개념
3.1speculation(추측 실행)
branch prediction 이 맞고 exception 이 없다고 가정하고 fetch·issue·execute. 틀리면 복구 필요.
3.2imprecise interrupt(부정확한 인터럽트)
interrupt 시점에 '이전은 모두 commit, 이후는 영향 없음'인 PC 를 특정할 수 없는 상태. 360/91.
3.2.r.1Smith & Pleszkun, Implementing Precise Interrupts in Pipelined Processors (IEEE TC 1988) ↗ · precise interrupt 정의와 reorder buffer 를 제안한 원 논문 (Sec. IV)
3.3reorder buffer(ROB, 재정렬 버퍼)
dispatch 순서(FIFO)로 명령어·결과를 보관하고 head 부터 in-order commit. CDB tag 로 ROB 번호 사용.
3.3.r.1Re-order buffer — Wikipedia ↗ · ROB 로 OoO·speculative 실행 후 in-order commit, precise exception·branch mispredict rollback
3.4commit / graduation(커밋)
ROB head 가 완료되면 register·memory 갱신. 오예측·exception 이면 newer entry flush.
3.4.r.1Out-of-order execution — Wikipedia ↗ · precise exception, reorder buffer, graduation/retire, dispatch-issue decoupling
3.5memory hazard(메모리 해저드)
store 는 head 에서만 memory 갱신(WAW·WAR 제거), load 는 앞선 store 주소와 비교(RAW).
3.5.r.1Memory disambiguation — Wikipedia ↗ · memory 를 통한 RAW/WAR/WAW, store-to-load forwarding, 앞선 store 주소 확인
3.6Data-in-ROB design
source·result 를 ROB 에, committed 값은 architectural register file 에. rename table <p,tag,value>.
3.6.r.1MIT 6.823 Handout #9 — Out-of-Order Execution with ROB ↗ · data 를 ROB 에 두는 설계, rename table 의 present bit·tag, dispatch/commit 규칙
3.7unified physical register file(통합 물리 레지스터 파일)
committed·speculative 값을 한 파일에. commit 은 mapping 만 갱신, data 이동 없음.
3.7.r.1MIT 6.5900 Quiz 1 handout — Physical Register File Design ↗ · rename table·physical register file·free list·ROB(tag 만 보관) 구성
3.8physical register 해제 시점
같은 architectural register 를 쓰는 다음 명령어가 commit 될 때 이전 physical register 를 free list 로.
3.8.r.1Register renaming — Wikipedia ↗ · ROB 방식 vs tag-indexed(physical) register file, 이전 tag 를 free queue 로 돌려주는 시점
3.8.r.2Yeager, The MIPS R10000 Superscalar Microprocessor (IEEE Micro 1996) ↗ · active list·free list·map table, exception 시 cycle 당 4개씩 역순 unmapping
4스스로 확인
4.1Tomasulo 에서 분기 해소 전 명령어를 '실행 금지'가 아니라 'dispatch 금지'로 정정한 이유는?
답
RS 에 들어간 entry 사이에는 program order 정보가 없어 실행 시점만으로는 순서를 막을 수 없기 때문.
4.2ROB 가 precise exception 을 가능하게 하는 원리는?
답
결과를 ROB 에 두고 head 부터 in-order commit → commit 된 것과 영향 없는 것 사이에 명확한 경계, 오예측·exception 시 newer entry flush.
4.3예제에서 LD F4 가 완료(Y)됐는데 commit 못 하는 이유는?
답
ROB head(oldest)가 아니기 때문. 앞선 LD F0·ADDD·DIVD·BNE 가 먼저 commit 돼야 함.
4.4memory 를 통한 WAR·WAW 가 자동으로 제거되는 이유는?
답
store 는 ROB head 에서만 memory 를 갱신하므로 그 시점에 앞선 load/store 가 남아 있지 않음.
4.5ROB 를 RS 로 겸용할 때 장단점은?
답
더 큰 window 로 ready 명령어 발견↑(ILP↑), 대신 완료 명령어에도 operand field 가 남아 면적 낭비·긴 배선.
4.6unified PRF 에서 P5(x6) 를 free 해도 되는 시점은?
답
x6 를 다시 쓰는 다음 명령어가 commit 될 때. 그 앞의 P5 사용자도 모두 commit 된 상태.
5참고 자료
5.1Computer Architecture: A Quantitative Approach, 6th ed. — Elsevier ↗ · 교재. 덱 권장 읽기 Chapter 3.6 (hardware-based speculation)
5.2Smith & Pleszkun, Implementing Precise Interrupts in Pipelined Processors (IEEE TC 1988) ↗ · precise interrupt 정의와 reorder buffer 를 제안한 원 논문 (Sec. IV)
5.3Yeager, The MIPS R10000 Superscalar Microprocessor (IEEE Micro 1996) ↗ · active list·free list·map table, exception 시 cycle 당 4개씩 역순 unmapping
5.4Re-order buffer — Wikipedia ↗ · ROB 로 OoO·speculative 실행 후 in-order commit, precise exception·branch mispredict rollback
5.5Register renaming — Wikipedia ↗ · ROB 방식 vs tag-indexed(physical) register file, 이전 tag 를 free queue 로 돌려주는 시점
5.6MIT OCW 6.823 Computer System Architecture (Fall 2005) — Lecture notes ↗ · 덱 원출처 계열 강의: L12 OoO·renaming, L13 speculative execution, L14 advanced superscalar

















