pipeline hazard

MySprtlty·2023년 10월 8일
0

Computer Architecture

목록 보기
4/6

용어 정리 및 전제 조건
파이프라인은 IF-ID-EXE-MEM-WB라고 가정
ADD $2, $3, $4에서 $2, $3, $4모두 operand다.
$2target register(or destination register)라고 한다.
$3, $4source register라고 한다.
sequential execution's semantic을 따르기만 한다면, 어떤 테크닉을 사용하든 상관없다.

🏷️pipeline hazard

  • cache miss가 발생하면, stall이 발생할 수밖에 없다.

📌structural hazard (구조적 해저드)

  • 자원이 부족해서 발생하는 hazard다.
  • 발생 조건
    • 동일한 cycle에
    • 서로 다른 instruction이
    • 동일한 resource를 요구할 때 발생한다.
  • 🔍ex) 동일한 cycle에 한 instrucion은 WB stage에서 Register file에 쓰고 한 instruction은 ID stage에서 Regester file에서 읽는 경우

💡해결책

  • register file을 multi port로 만든다.
  • time-multiplexed
    • stage를 더 잘게 쪼개는 것이다.
    • ID와 RR(Register Read) stage로 나눈다. (IF-ID-RR-EXE-MEM-WB)
  • memory의 경우 instruction cache와 data cache로 나눈다.

📌data hazard

  • 그냥 naive하게 실행을 하면, seqeuntial execution과 결과가 달라질 수 있다.
  • load의 target register와 바로 뒷 명령의 source register가 같은 경우, 필연적으로 stall이 발생할 수 밖에 없다.

💡해결책

  • pipeline freeze(stall)
    • 일명 뒷다리 잡기
  • Internal Forwarding
    • 실제 write시점보다 빠른 시점에 ALU input으로 준다. (Bypass)
  • compiler scheduling
    • 컴파일러가 현명하게 instruction을 배치한다.

📌control hazard

  • PC값을 non-sequential하게 바꾸는 instruction(jump or branch) 때문에 발생한다.
  • 그 instruction을 실행을 마쳐야 파이프라인에 어떤 instruction을 투입할지 알 수 있다.
  • 🖇️cf. 어떻게 보면 program counter에 대한 RAW dependency다.

💡해결책

  • branch 명령을 2 cycle안에 끝내기
    • 일명 초전박살
  • branch prediction
    • taken, not-taken을 예측한다.
  • delayed branch
    • 무조건 pc+4 instruction을 실행하기 때문에 일명 영혼 팔아먹기라고 한다.
    • 원래 branch instruction의 semantic을 바꾼 것이기 때문이다.
    • 5년 정도 쓰이다가 거의 안쓰이는 기술이다.

파이프 라인 단계를 IF-ID-RR-EXE-MEM-WB로

profile
2Co 4:7

0개의 댓글