RISC, CISC and pipelining
แนะนำใหม่
14:50
RISC, Pipelines & Logic
นักออกแบบชิปสองคนเผชิญปัญหาเดียวกัน: ทำให้โปรแกรมทำงานเร็ว คนหนึ่งบอกว่า — สร้างคำสั่งทรงพลัง เพื่อให้แต่ละคำสั่งทำงานได้มาก คนอื่นบอกว่า — รักษา…
บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| processors/ˈprəʊsesəz/ | The component that executes instructions and performs the operations of a computer or similar system. |
| instructions/ɪnˈstrʌkʃnz/ | Commands that tell a computer what actions to perform. |
| memory/ˈmeməri/ | Circuits that store data, such as registers, RAM and ROM. |
| CISC/sɪsk/ | ชุดคำสั่งซับซ้อน (CISC) |
| RISC/rɪsk/ | 精简指令集 |
| pipelining/ˈpaɪplaɪnɪŋ/ | 流水线 |
| Flynn's taxonomy/flɪnz tækˈsɒnəmi/ | 弗林分类 |
| memory accesses | Operations that read data from or write data to memory. |
| decoding | The process of working out what an instruction tells the processor to do. |
| hardware/ˈhɑːdweə/ | The physical parts of a computer system that can be touched. |
| decode | To work out what an instruction tells the processor to do. |
| load/ləʊd/ | To copy data from memory into a processor register. |
| store/stɔː/ | To move data from a register into a memory location. |
| register/ˈredʒɪstə/ | รีจิสเตอร์ |
| instruction length | The number of bits used to represent a single instruction. |
| cycles per instruction | The number of processor clock cycles needed to complete an instruction. |
| micro-operations | Simple internal operations into which a processor can break down instructions. |
| fetch | To get an instruction from memory for the processor to use. |
| execute/ˈeksɪkjuːt/ | To carry out the operation that an instruction tells the processor to do. |
| ALU/ˌeɪ el ˈjuː/ | หน่วยคำนวณทางคณิตศาสตร์และตรรกะ |
| write back | To write the result of an instruction into a register. |
| throughput/ˈθruːpʊt/ | The amount of useful work or data completed per unit of time, rather than the time for one individual operation. |
| fetch unit | The part of a processor that gets instructions for it to process. |
| hazard/ˈhæzəd/ | 冒险 |
| data hazard | A delay when an instruction needs a result that is not yet available. |
| control hazard | A possible delay when the processor does not yet know which instruction comes next. |
| branch/bræntʃ/ | A path of instructions chosen according to a condition or value. |
| instruction streams | Sequences of instructions that processors read and carry out. |
| data streams | Sequences of data items that processors receive and process. |
| SISD | One instruction stream, one data stream, a traditional single core . |
| single core | A processor with one core that executes a stream of instructions. |
| SIMD/ˈsɪmdiː/ | 单指令多数据 |
| GPU | A processor designed to perform many similar operations on different data items at once. |
| CPU/ˌsiː piː ˈjuː/ | The part of a computer that carries out program instructions. |
| vector unit | A part of a processor that applies one instruction to several data items. |
| MISD | Several operations on the same data. |
| MIMD/ˈmɪmdiː/ | 多指令多数据 |
| multi-core | Describes a processor with two or more cores that can process instructions independently. |
| cluster/ˈklʌstə/ | A group of connected computers that work together on tasks. |
| massively parallel/ˈmæsɪvli ˈpærəlel/ | 大规模并行 |
| messages | Pieces of information sent between processors to exchange data. |
| supercomputers/ˌsuːpəkəmˈpjuːtəz/ | 超级计算机 |
| graphics card/ˈɡræfɪks kɑːd/ | Hardware that processes graphics and produces display output, commonly containing a graphics processing unit and memory. |
| pixels/ˈpɪkslz/ | An individual picture element in a digital image or display. |
| compiler/kəmˈpaɪlə/ | Software that translates a program from a source language into another form, commonly machine or intermediate code. |
| distributed memory/ˈdɪstrɪbjuːtɪd ˈmeməri/ | An architecture in which processing units have separate local memories and exchange data through communication. |
| message passing | The exchange of data between processors by sending and receiving messages. |
โทรศัพท์ในกระเป๋าของคุณไม่ได้ใช้ Intel
- For thirty years the fastest processors were the most complicated ones: add instructions, and each one does more work. Intel built an empire on it.
- จากนั้นบริษัทขนาดเล็กแห่งหนึ่งนำโปรเซสเซอร์ที่ เรียบง่าย อย่างตั้งใจไปใส่ในโทรศัพท์ คำสั่งน้อยลง มีความยาวเท่ากันแทบจะไม่มีการเข้าถึงเมมโมรี่เลย มันไม่สามารถทำได้ดีต่อคำสั่งเท่า CISC แต่กลับชนะได้ในที่สุด
- มันชนะเพราะคำสั่งที่เรียบง่ายและสม่ำเสมอสามารถ **ซ้อนทับ (overlapped)**กันได้ และการซ้อนทับนี้มีค่ามากกว่าความซับซ้อน
- This lesson is CISC and RISC, pipelining, the four architectures of Flynn's taxonomy, and where a processor's heat and speed limits lead.
CISC and RISC
- CISC (Complex Instruction Set Computer) มี คำสั่งจำนวนมาก มักจะซับซ้อน: คำสั่งหนึ่งอาจดำเนินการเข้าถึงเมมโมรี่และการคำนวณหลายครั้ง คำสั่งมีความ ยาวไม่แน่นอน ทำให้การถอดรหัสซับซ้อน ทำได้มากต่อคำสั่งด้วยฮาร์ดแวร์ ตัวอย่าง: Intel x86
- RISC (Reduced Instruction Set Computer) มีชุดคำสั่งที่ เล็กและเรียบง่าย Each instruction ทำหน้าที่พื้นฐานเพียงอย่างเดียว, มีความยาว คงที่ และถอดรหัสได้รวดเร็ว มีเพียง load และ store เท่านั้นที่เข้าถึงหน่วยความจำ; ส่วนอื่นๆ เป็น register ไปยัง register ตัวอย่าง: ARM.
- โปรแกรม RISC มีขนาด ยาวกว่า แต่แต่ละคำสั่งทำงานเร็วและคาดเดาได้ ซึ่งเป็นสิ่งที่ pipeline ต้องการเป๊ะๆ

มากต่อหนึ่งคำสั่ง หรือเร็วและคาดเดาได้มากกว่าต่อหนึ่งคำสั่ง
A RISC processor is characterised by:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
RISC keeps instructions few, simple and fixed-length (usually 1 cycle); CISC has many complex variable-length ones.
ความแตกต่างที่ข้อสอบต้องการ
| คุณสมบัติ | CISC | RISC |
|---|---|---|
| ชุดคำสั่ง | มาก, ซับซ้อน | น้อย, เรียบง่าย |
| ความยาวคำสั่ง | เปลี่ยนแปลงได้ | คงที่ |
| การเข้าถึงหน่วยความจำ | คำสั่งหลายตัวอาจเข้าถึงหน่วยความจำ | มีเพียง load และ store เท่านั้น |
| รีจิสเตอร์ | น้อย | มาก |
| รอบต่อนำคำสั่ง | เปลี่ยนแปลงได้ | โดยทั่วไปหนึ่งรอบ |
| การทำ Pipeline | ยาก | เป็นธรรมชาติ |
- ชิป Intel รุ่นใหม่จะแปลงคำสั่ง CISC ของตัวเองเป็น micro-operations แบบ RISC ที่ง่ายขึ้นภายใน ซึ่งเป็นการพิสูจน์ชัดเจนที่สุดว่าแบบออกแบบใดชนะการถกเถียงนี้
Match each term to its description.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
RISC = simple + fixed-length + load/store; CISC = complex + variable-length; pipelining overlaps stages for speed.
In a RISC processor, the only instructions that access memory are load and ____.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Everything else is register to register. That restriction is what makes instructions fixed-length, uniform in timing and easy to pipeline.
การทำ Pipeline
- Pipeline ประมวลผลคำสั่งใน ขั้นตอนที่ซ้อนทับกัน เหมือนสายการผลิต: ดึงข้อมูล, ถอดรหัส, ประมวลผลใน ALU, เข้าถึงหน่วยความจำ, เขียนกลับ
- แต่ละขั้นตอนทำงานกับ คำสั่งที่แตกต่างกัน ในเวลาเดียวกัน ดังนั้นเมื่อ pipeline เต็มแล้ว จะมีคำสั่ง เสร็จสมบูรณ์หนึ่งตัวต่อหนึ่งรอบ
- มันไม่ทำให้คำสั่งใดคำสั่งหนึ่งเร็วขึ้น แต่เพิ่ม throughput: มีคำสั่งเสร็จสมบูรณ์มากขึ้นต่อวินาที
- RISC's fixed-length, simple instructions make every stage take the same time, which is why RISC pipelines cleanly and CISC does not.

*คำสั่งหกตัวกำลังดำเนินการ, เสร็จหนึ่งตัวต่อรอบ
How pipelining fills up
Step through the clock cycles. Once the pipeline is full, a new instruction finishes every cycle — even though each one still takes several stages — because the stages of different instructions overlap.
When a pipeline is full, it completes about:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Overlapping the stages means a new instruction finishes each cycle once the pipeline is full.
Pipelining speeds up a processor by:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Stages of different instructions run at the same time.
ตัวอย่างวิธีทำ: ทำไม pipeline ถึงเร็วกว่า
- Pipeline ห้าขั้น ทำงานด้วยหนึ่งรอบต่อหนึ่งขั้น อธิบายทำไมมันจึงเร็วกว่าการรันคำสั่งทีละตัวตามลำดับ
- โดยไม่มี pipeline คำสั่งหนึ่งจะครอบครองโปรเซสเซอร์ตลอดทั้งห้าขั้นตอน ดังนั้นจึงเสร็จสิ้นทุก 5 รอบนาฬิกา
- เมื่อมี pipeline หน่วยดึงข้อมูลจะเริ่มคำสั่งถัดไปในขณะที่คำสั่งปัจจุบันยังคงอยู่ในขั้นตอนถอดรหัส ทำให้มีห้าคำสั่งกำลังดำเนินการพร้อมกัน และเมื่อเต็มแล้ว จะเสร็จ ทุกๆ รอบ
- ไม่มีคำสั่งใดถูกประมวลผลเร็วขึ้น; แต่ throughput เพิ่มขึ้นประมาณห้าเท่า ต้องระบุให้ชัดเจน: นี่คือจุดที่คนส่วนใหญ่พลาดคะแนนมากที่สุด

What does pipelining actually improve?
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Stages overlap, so five instructions are in progress at once and one completes per cycle. No individual instruction is executed any faster.
Hazards (อุปสรรค/สิ่งกีดขวาง)
- Hazard ทำให้ pipeline หยุดชะงัก Data hazard เกิดขึ้นเมื่อคำสั่งต้องการผลลัพธ์ที่คำสั่งก่อนหน้ายังไม่ได้สร้าง จึงต้องรอ
- Control hazard เกิดขึ้นที่การ branching: จนกว่าการ branching จะถูกตัดสินใจ โปรเซสเซอร์จะไม่รู้ว่าควรดึงคำสั่งถัดไปตัวไหน
- ทั้งสองอย่างนี้เสียรอบการทำงาน จึงเป็นเหตุที่โปรเซสเซอร์ใช้การทำนายการ branching และการส่งต่อผลลัพธ์ระหว่างขั้นตอน

A data hazard stalls the pipeline when an instruction needs a result that is not ready yet; a control hazard comes from a branch changing which instruction runs next.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Hazards force the pipeline to stall (or flush), which is why they reduce the ideal one-per-cycle throughput.
Match each pipeline hazard to what causes it.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Both stall the pipeline and waste cycles, which is why processors forward results between stages and predict branches.
Flynn's taxonomy
- Flynn's taxonomy จัดประเภทคอมพิวเตอร์โดยจำนวน instruction streams และ data streams ที่มี
- SISD: instruction stream หนึ่งตัว, data stream หนึ่งตัว, คือแกนเดียวแบบดั้งเดิม
- SIMD: one instruction operates on many data items at once. This is a GPU or a CPU's vector unit, and it suits images, video and scientific arrays.
- MISD: several operations on the same data; rare and mostly theoretical. MIMD: many processors run different instructions on different data, which is a multi-core CPU or a cluster, and it is the most general.

*คำสั่งหนึ่งตัว, ข้อมูลจำนวนมาก
Which describe SIMD? Select ทั้งหมด that apply.
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Different programs on different data is MIMD, the multi-core case. SIMD is one instruction stream over many data streams.
คอมพิวเตอร์แบบขนานมหาศาล
- ระบบ massively parallel ใช้ โปรเซสเซอร์นับพัน เชื่อมต่อกันด้วยเครือข่ายความเร็วสูง แต่ละตัวมี หน่วยความจำของตัวเอง ส่งข้อมูลผ่าน messages แทนการแชร์หน่วยความจำ
- มันเป็น MIMD และต้องใช้ซอฟต์แวร์ที่เขียนเฉพาะ เพราะโปรแกรมเมอร์ต้องแบ่งปัญหาและจัดการการสื่อสาร
- นี่คือสิ่งที่ supercomputers ขนาดใหญ่ที่สุดคือ: การจำลองสภาพภูมิอากาศ, การฝึก machine-learning และดาราศาสตร์ ล้วนทำงานแบบนี้

A massively parallel computer's processors share one block of memory.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Each processor has its own memory, and they exchange data by messages over a fast network. That distributed memory is what the term means.
ตัวอย่างวิธีทำ: กำหนดประเภทเครื่อง
- การ์ดกราฟิกปรับความสว่างให้พิกเซลสองล้านพิกเซล SIMD: คำสั่งหนึ่งตัว, ข้อมูล-many items, ซึ่งตรงกับที่ cores เล็กนับพันของ GPU ถูกสร้างขึ้นเพื่อ
- แล็ปท็อปสี่คอร์รันเบราว์เซอร์ คอมไพเลอร์ และเครื่องเล่นเพลงพร้อมกัน MIMD: คำสั่งต่างกันบนข้อมูลต่างกัน ไหลเข้าทีละสตรีมต่อคอร์
- ศูนย์พยากรณ์อากาศแบ่งบรรยากาศเป็น grid บนโปรเซสเซอร์หมื่นตัว, แต่ละตัวมีหน่วยความจำของตัวเอง, ส่งค่าขอบเขตเป็น messages Massively parallel, ซึ่งเป็นรูปแบบหนึ่งของ MIMD
- ระบุชื่อหมวดหมู่ แล้วอธิบายด้วยจำนวน instruction และ data streams

คะแนนที่หลุดหายไป
- Pipeline เพิ่ม throughput; ไม่ลดความยาวของคำสั่งใดคำสั่งหนึ่ง ต้องพูดให้ชัด
- ใน RISC มีเพียง load และ store เท่านั้นที่เข้าถึงเมมโมรี่ ข้อเท็จจริงเดียวนี้อธิบายความยาวคงที่ โทนรีจิสเตอร์มากมาย และการทำ pipeline ที่สะอาดตา
- SIMD คือ one instruction on many data; MIMD คือ many instructions on many data นับ streams ก่อนตอบคำถาม
- Massively parallel หมายถึง thousands of processors with distributed memory และ message passing, ไม่ใช่แค่ "computer ที่เร็ว"
คุณเข้าใจแล้ว
- CISC: คำสั่งซับซ้อนหลายตัว ความยาวแปรผัน, มากต่อหนึ่ง指令 · RISC: คำสั่งเรียบง่ายน้อย ความยาวคงที่, load และ store เท่านั้น, Many registers, One cycle each
- pipeline (สายการผลิตรถยนต์) ครอบคลุมขั้นตอน fetch, decode, execute, memory และ write-back ทำให้มีคำสั่งหนึ่งเสร็จสิ้นต่อ cycle เมื่อระบบเต็มประสิทธิภาพ: เพิ่ม throughput ไม่ใช่ความเร็วของคำสั่งแต่ละตัว; data hazards และ control hazards ทำให้เกิดความล่าช้า
- Flynn: SISD, SIMD (เช่น GPU), MISD, MIMD (multi-core)
- massively parallel: ใช้โปรเซสเซอร์นับพันเครื่อง, มี distributed memory, สื่อสารผ่าน message passing, ใช้ MIMD, นำโดยซูเปอร์คอมพิวเตอร์
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้