04 · Computer Architecture
04 · สถาปัตยกรรมคอมพิวเตอร์
This chapter is the floor where physics becomes logic — the lowest floor this book visits, and the one every floor above it stands on.
บทนี้คือชั้นที่ฟิสิกส์กลายเป็นตรรกะ — ชั้นล่างสุดที่หนังสือเล่มนี้ลงไปถึง และเป็นชั้นที่ทุกชั้นเหนือขึ้นไปยืนอยู่บน
How do you get arithmetic out of electricity?
ดึงเลขคณิตออกมาจากไฟฟ้าได้อย่างไร
A single Nvidia Blackwell B200 processor holds 208 billion transistors. A transistor does exactly one thing: it conducts, or it does not. It cannot add. It has no notion of a number, or of quantity. Yet somewhere between that switch and the arithmetic running underneath this sentence, meaning appears — and it appears in no component. This chapter is about where it actually is.
โปรเซสเซอร์ Nvidia Blackwell B200 ตัวเดียวมีทรานซิสเตอร์ (transistor) 208 billion ตัว ทรานซิสเตอร์ทำได้อย่างเดียว คือนำไฟฟ้า หรือไม่นำ มันบวกเลขไม่เป็น ไม่มีความคิดเรื่องตัวเลขหรือปริมาณอยู่ในตัวเลยสักนิด แต่ระหว่างสวิตช์ตัวนั้นกับเลขคณิตที่ทำงานอยู่ใต้ประโยคนี้ ความหมายกลับโผล่ขึ้นมา และมันไม่ได้อยู่ในชิ้นส่วนไหนเลยสักชิ้น บทนี้ว่าด้วยว่ามันอยู่ตรงไหนกันแน่
The answer is composition, and it is older than the computer. In the master's thesis he submitted to MIT in 1937, Claude Shannon showed that the two-valued algebra George Boole had built to formalize logic described, exactly, the behavior of circuits made of switches (MIT's copy). Two switches in series are AND; in parallel, OR. That correspondence is the hinge of the entire tower: a circuit can be designed as an argument rather than tinkered into working. After it, the climb is short and mechanical. Five gates — two XOR, two AND, one OR — make a full adder, a circuit that adds two bits plus a carry. Chain sixty-four of them and the machine adds sixty-four-bit integers. Nothing was introduced along the way except arrangement. Arithmetic is not in the electricity. It is in the shape.
คำตอบคือการประกอบกัน (composition) และมันเก่าแก่กว่าคอมพิวเตอร์ ในวิทยานิพนธ์ปริญญาโทที่ Claude Shannon ยื่นให้ MIT ในปี 1937 เขาแสดงว่าพีชคณิตสองค่าที่ George Boole สร้างขึ้นเพื่อทำให้ตรรกะเป็นรูปนัย อธิบายพฤติกรรมของวงจรที่สร้างจากสวิตช์ได้ตรงเป๊ะ (ต้นฉบับของ MIT) สวิตช์สองตัวต่ออนุกรมคือ AND ต่อขนานคือ OR ความสอดคล้องนี้คือบานพับของหอคอย (tower) ทั้งหลัง วงจรถูก ออกแบบ ขึ้นในฐานะข้อโต้แย้งหนึ่งได้ แทนที่จะลองผิดลองถูกจนใช้งานได้ หลังจากนั้นทางขึ้นก็สั้นและเป็นกลไกล้วนๆ เกตตรรกะ (logic gate) ห้าตัว — XOR สองตัว AND สองตัว OR หนึ่งตัว — ประกอบกันเป็นวงจรบวกแบบเต็ม (full adder) หนึ่งตัว บวกบิตสองตัวกับตัวทดอีกหนึ่งตัว ต่อกันเข้าไป 64 ตัว เครื่องก็บวกจำนวนเต็ม 64 บิตได้ ระหว่างทางไม่มีอะไรถูกเติมเข้ามานอกจากการจัดเรียง เลขคณิตไม่ได้อยู่ในไฟฟ้า มันอยู่ในรูปทรง
The second idea arrived in a document nobody finished. In June 1945, Herman Goldstine circulated twenty-four copies of a 101-page draft by John von Neumann, the First Draft of a Report on the EDVAC (scan). Its central move — the stored program — was to keep a machine's instructions in the same memory as its data. This sounds like a filing decision. It is the reason the upper tower exists: if a program is just numbers in memory, then a program can read, write, and generate other programs — which is what every tool in chapter 06 does. It carried von Neumann's name alone, and caused sixty years of argument: J. Presper Eckert and John Mauchly held that the idea came out of group meetings at the Moore School, and the report's wide circulation later counted as prior art that helped invalidate the ENIAC patent in 1973. The lesson survives the quarrel: the machine's most consequential feature was a decision about what to not keep separate.
ไอเดียที่สองมาจากเอกสารที่ไม่มีใครเขียนจบ เดือนมิถุนายน 1945 Herman Goldstine แจกจ่ายสำเนา 24 ชุดของร่าง 101 หน้าที่ John von Neumann เขียน ชื่อ First Draft of a Report on the EDVAC (สแกนต้นฉบับ) แกนกลางของมันคือโปรแกรมที่เก็บในหน่วยความจำ (stored program) — เก็บคำสั่งเครื่องไว้ในหน่วยความจำก้อนเดียวกับข้อมูล ฟังดูเหมือนแค่การตัดสินใจเรื่องจัดเก็บเอกสาร แต่มันคือเหตุผลที่หอคอยชั้นบนทั้งหมดมีอยู่ได้ ถ้าโปรแกรมเป็นแค่ตัวเลขในหน่วยความจำ โปรแกรมก็อ่าน เขียน และสร้างโปรแกรมอื่นได้ ซึ่งคือสิ่งที่เครื่องมือทุกชิ้นในบทที่ 06 ทำ เอกสารนี้ลงชื่อ von Neumann อยู่คนเดียว และก่อการโต้เถียงยาว 60 ปี J. Presper Eckert และ John Mauchly ยืนยันว่าไอเดียนี้ออกมาจากการประชุมกลุ่มที่ Moore School และการแจกจ่ายเอกสารในวงกว้างต่อมาก็ถูกนับเป็นหลักฐานสิ่งที่มีมาก่อน (prior art) ที่ช่วยให้สิทธิบัตร ENIAC เป็นโมฆะในปี 1973 บทเรียนรอดจากการทะเลาะกันมาได้ คุณสมบัติที่สำคัญที่สุดของเครื่องคือการตัดสินใจว่าจะ ไม่ แยกอะไรออกจากกัน
The third idea is the one that gives this floor its name. On 7 April 1964 IBM announced System/360, a family of machines of differing size, speed, and price built to run the same programs. Gene Amdahl, Gerrit Blaauw, and Frederick Brooks defined architecture as "the attributes of a system as seen by the programmer, i.e., the conceptual structure and functional behavior, as distinct from the organization of the data flow and controls, the logical design, and the physical implementation" (Amdahl, Blaauw & Brooks, 1964). That distinction is the floor's surface. An instruction set is a contract: the hardware promises what each instruction means, and promises nothing about how it will keep the promise. Behind an unchanged contract, engineers have replaced nearly everything — pipelining instructions so several are in flight at once, executing them out of order, guessing at branches and rolling back wrong guesses. The programmer's side of the contract never mentions any of it. This is why software outlives the hardware it was written for.
ไอเดียที่สามคือไอเดียที่ให้ชื่อกับชั้นนี้ วันที่ 7 เมษายน 1964 IBM ประกาศเปิดตัว System/360 ตระกูลเครื่องที่ขนาด ความเร็ว และราคาต่างกัน แต่สร้างมาให้รันโปรแกรมชุดเดียวกันได้ Gene Amdahl, Gerrit Blaauw และ Frederick Brooks นิยาม architecture ว่าคือ "คุณลักษณะของระบบตามที่โปรแกรมเมอร์มองเห็น กล่าวคือโครงสร้างเชิงแนวคิดและพฤติกรรมเชิงหน้าที่ ต่างจากการจัดการ data flow และการควบคุม การออกแบบเชิงตรรกะ และการนำไปปฏิบัติจริงทางกายภาพ" (Amdahl, Blaauw & Brooks, 1964) ความต่างนั้นคือผิว (surface) ของชั้นนี้ ชุดคำสั่ง (instruction set) หนึ่งชุดคือ สัญญา ฮาร์ดแวร์สัญญาว่าคำสั่งเครื่องแต่ละตัวหมายถึงอะไร และไม่สัญญาสักคำว่าจะรักษาสัญญานั้นด้วยวิธีไหน หลังสัญญาที่ไม่เคยเปลี่ยนฉบับนั้น วิศวกรเปลี่ยนแทบทุกอย่าง — ทำ pipelining ให้คำสั่งเครื่องหลายตัวอยู่ระหว่างดำเนินการพร้อมกัน สั่งทำงานนอกลำดับ เดาทางแยกของโปรแกรมและย้อนกลับเมื่อเดาผิด ฝั่งโปรแกรมเมอร์ของสัญญาไม่เอ่ยถึงเรื่องพวกนี้เลยสักคำ นี่คือเหตุผลที่ซอฟต์แวร์อยู่ได้นานกว่าฮาร์ดแวร์ที่มันถูกเขียนขึ้นมาให้
But the contract has fine print, and the fine print is where this floor leaks. In 1995 William Wulf and Sally McKee published a two-page note called "Hitting the Memory Wall: Implications of the Obvious". Their arithmetic used numbers everyone already had: memory was getting about 7 percent faster a year, processors about 80. Compounded, that gap projected an average memory access costing roughly 99 processor cycles by 2010 — a machine spending most of its life waiting. What has held the wall back is not a theorem but an empirical regularity: locality. Programs touch the same data again soon, and data near what they just touched. So architects built a hierarchy of small fast memories in front of large slow ones and bet on that habit — the most exploited empirical regularity in computing, and it usually wins. When it loses, two loops identical in logic — same operations, same results — can differ enormously in time, for reasons the instruction set does not mention and the source code does not show. Knowing that such a gap is a memory problem, three floors down, rather than an algorithm problem, is a large fraction of what practical expertise in computing means.
สัญญามีตัวหนังสือตัวเล็ก และตัวหนังสือตัวเล็กนั้นคือจุดที่ชั้นนี้รั่ว ในปี 1995 William Wulf และ Sally McKee ตีพิมพ์บันทึกสั้นสองหน้าชื่อ "Hitting the Memory Wall: Implications of the Obvious" เลขคณิตของพวกเขาใช้ตัวเลขที่ทุกคนมีอยู่แล้ว หน่วยความจำเร็วขึ้นราวปีละ 7 เปอร์เซ็นต์ โปรเซสเซอร์เร็วขึ้นราว 80 เปอร์เซ็นต์ พอทบต้นกันไป ช่องว่างนี้ทำนายว่าภายในปี 2010 การเข้าถึงหน่วยความจำโดยเฉลี่ยจะกิน cycle ของโปรเซสเซอร์ไปราว 99 cycle — เครื่องที่ใช้ชีวิตส่วนใหญ่ไปกับการรอ สิ่งที่กันกำแพงนี้ไว้ไม่ใช่ทฤษฎีบท แต่คือความสม่ำเสมอเชิงประจักษ์อย่างหนึ่ง คือ locality โปรแกรมมักแตะข้อมูลเดิมซ้ำในเวลาไม่นาน และแตะข้อมูลที่อยู่ใกล้กับสิ่งที่เพิ่งแตะไป สถาปนิกจึงวางลำดับชั้นหน่วยความจำ (memory hierarchy) ที่มีหน่วยความจำเล็กเร็วอยู่หน้าหน่วยความจำใหญ่ช้า และพนันกับนิสัยนั้น — ความสม่ำเสมอเชิงประจักษ์ที่ถูกใช้ประโยชน์มากที่สุดในวงการคอมพิวเตอร์ และมันมักจะชนะ เมื่อมันแพ้ ลูปสองลูปที่ตรรกะเหมือนกันเป๊ะ — ปฏิบัติการเดียวกัน ผลลัพธ์เดียวกัน — อาจกินเวลาต่างกันมหาศาล ด้วยเหตุผลที่ instruction set ไม่พูดถึง และซอร์สโค้ดไม่แสดงให้เห็น การรู้ว่าช่องว่างแบบนั้นเป็นปัญหาเรื่อง หน่วยความจำ ที่อยู่ลึกลงไปสามชั้น ไม่ใช่ปัญหาเรื่องอัลกอริทึม คือความเชี่ยวชาญเชิงปฏิบัติส่วนใหญ่ในวงการคอมพิวเตอร์
The last idea is that this floor stopped being free. Gordon Moore's 1965 magazine article observed that the component count on a chip was doubling every year, a rate he revised to every two years in 1975; the famous "eighteen months" appears in neither. What made shrinking transistors feel free was a second rule from Robert Dennard and colleagues in 1974: scale dimensions and voltage together and power density stays constant, so more transistors cost no more heat (Dennard et al., 1974). Around 2005 that stopped working — voltages could not keep falling without leakage — and the whole tower felt it, because for four decades every floor above had been getting faster while doing nothing. Architects responded by spending transistors differently: first on more cores, then on chips that do less but do it better. Google's first Tensor Processing Unit, described at ISCA in 2017, dropped nearly everything a general processor offers and reported, on its intended workload, 25 to 29 times the operations per watt of the contemporary Nvidia K80 GPU and 41 to 83 times a contemporary Intel CPU — the spread depending on how power is accounted (Jouppi et al., 2017). John Hennessy and David Patterson, who received the 2017 Turing Award for the quantitative approach that made such comparisons possible, called the result a new golden age for computer architecture. Note what changed: speed used to arrive from below as a gift; now it is negotiated.
ไอเดียสุดท้ายคือชั้นนี้เลิกฟรีแล้ว บทความในนิตยสารปี 1965 ของ Gordon Moore สังเกตว่าจำนวนชิ้นส่วนบนชิปเพิ่มเป็นสองเท่าทุกปี อัตราที่เขาแก้เป็นทุกสองปีในปี 1975 ส่วนคำโด่งดังอย่าง "สิบแปดเดือน (eighteen months)" ไม่ปรากฏในทั้งสองฉบับ สิ่งที่ทำให้การย่อทรานซิสเตอร์ รู้สึก เหมือนฟรี คือกฎอีกข้อจาก Robert Dennard และเพื่อนร่วมงานในปี 1974 — ย่อขนาดและแรงดันไฟไปพร้อมกัน ความหนาแน่นของกำลังไฟจะคงที่ ทรานซิสเตอร์ที่เพิ่มขึ้นจึงไม่กินความร้อนเพิ่ม (Dennard et al., 1974) ราวปี 2005 กฎนี้หยุดใช้ได้ — แรงดันไฟลดต่อไปไม่ได้อีกโดยไม่เกิดการรั่วไหลของกระแส — และหอคอยทั้งหลังรู้สึกถึงมัน เพราะตลอดสี่ทศวรรษ ทุกชั้นเหนือขึ้นไปเร็วขึ้นเรื่อยๆ โดยไม่ต้องทำอะไรเลย สถาปนิกตอบด้วยการใช้ทรานซิสเตอร์ไปในทางอื่น ข้อแรกคือเพิ่มจำนวนคอร์ (core) จากนั้นไปที่ชิปที่ทำงานได้น้อยลงแต่ทำได้ดีขึ้น Tensor Processing Unit ตัวแรกของ Google ที่บรรยายไว้ในงาน ISCA ปี 2017 ตัดแทบทุกอย่างที่โปรเซสเซอร์ทั่วไปมีทิ้งไป และรายงานว่า บนงานที่ตั้งใจให้มันทำ มันให้จำนวนปฏิบัติการต่อวัตต์มากกว่า Nvidia K80 GPU ร่วมสมัย 25 ถึง 29 เท่า และมากกว่า Intel CPU ร่วมสมัย 41 ถึง 83 เท่า — ช่วงที่ต่างกันขึ้นอยู่กับวิธีนับกำลังไฟ (Jouppi et al., 2017) John Hennessy และ David Patterson ผู้รับรางวัล Turing Award ปี 2017 จากแนวทางเชิงปริมาณที่ทำให้การเปรียบเทียบแบบนี้เป็นไปได้ เรียกผลลัพธ์นี้ว่ายุคทองใหม่ของสถาปัตยกรรมคอมพิวเตอร์ สังเกตสิ่งที่เปลี่ยนไป — ความเร็วเคยมาจากชั้นล่างในฐานะของขวัญ ตอนนี้มันต้องต่อรองเอา
The people are unusually entangled with the ideas. Amdahl architected System/360 and then left IBM in 1970 to found a company building machines plug-compatible with the very contract he had drafted — the architecture outlived its author's employment, which is the strongest proof it was a real interface. Dennard invented the one-transistor memory cell in 1966 (patent granted June 1968) and then wrote the scaling rule that let processors outrun it: one man is responsible both for the memory that is too slow and for the reason it matters.
ผู้คนพัวพันกับไอเดียเหล่านี้อย่างผิดปกติ Amdahl เป็นสถาปนิกของ System/360 และลาออกจาก IBM ในปี 1970 ไปตั้งบริษัทสร้างเครื่องที่เข้ากันได้โดยตรง (plug-compatible) กับสัญญาฉบับที่ตัวเองร่างไว้ — architecture อยู่ได้นานกว่าการเป็นพนักงานของผู้เขียนมันเอง และนั่นคือบทพิสูจน์ที่หนักแน่นที่สุดว่ามันคืออินเทอร์เฟซที่มีอยู่จริง Dennard คิดค้นเซลล์หน่วยความจำแบบทรานซิสเตอร์เดียวในปี 1966 (สิทธิบัตรได้รับอนุมัติมิถุนายน 1968) และเขียนกฎการย่อขนาดที่ทำให้โปรเซสเซอร์วิ่งแซงหน้ามันไป คนคนเดียวรับผิดชอบทั้งหน่วยความจำที่ช้าเกินไป และเหตุผลที่มันสำคัญ
Connections
เชื่อมโยง
Below this chapter, in this book, there is nothing — 01 through 03 are about what can be computed and what information is, questions that hold for any machine or none. Above it, 05 takes this single machine and makes it behave like many, using the protection and timer hardware this floor provides; 06 turns the instruction-set contract into something a person can write in. Chapter 02's cost model quietly assumes memory that answers in constant time, which this floor does not supply; read the two against each other and the disagreement is instructive. Chapter 12 is where specialization now points, and chapter 14 asks what the energy wall does to all of it.
ใต้บทนี้ในหนังสือเล่มนี้ไม่มีอะไรอีกแล้ว — บทที่ 01 ถึง 03 ว่าด้วยสิ่งที่คำนวณได้และสารสนเทศคืออะไร คำถามที่เป็นจริงไม่ว่าจะเป็นเครื่องไหนหรือไม่มีเครื่องเลย เหนือขึ้นไป บทที่ 05 เอาเครื่องเดียวนี้มาทำให้มันทำตัวเหมือนมีหลายเครื่อง โดยใช้ฮาร์ดแวร์ป้องกันและตัวจับเวลาที่ชั้นนี้ยื่นให้ บทที่ 06 เปลี่ยนสัญญา instruction set ให้เป็นสิ่งที่คนเขียนได้ โมเดลต้นทุนของบทที่ 02 แอบสมมติว่าหน่วยความจำตอบด้วยเวลาคงที่ ซึ่งชั้นนี้ไม่ได้ให้ อ่านสองบทเทียบกัน ความขัดแย้งนั้นสอนอะไรได้ บทที่ 12 คือจุดที่การเฉพาะทางกำลังมุ่งไปตอนนี้ และบทที่ 14 ถามว่ากำแพงพลังงาน (energy wall) จะทำอะไรกับทั้งหมดนี้
Open questions
คำถามที่ยังเปิดอยู่
Is a fixed instruction set still worth its cost, when the workloads that matter change faster than chips can be designed? If memory is the bottleneck, should computation move into memory instead of data moving to the processor? Speculative execution bought decades of speed and then turned out to leak secrets across the security boundary chapter 11 depends on; can a machine be fast and honest about what it is doing? And after specialization, what is left for a general-purpose computer to be?
instruction set ที่ตายตัวยังคุ้มต้นทุนของมันอยู่ไหม ในเมื่องานที่สำคัญเปลี่ยนเร็วกว่าที่ชิปจะออกแบบทัน ถ้าหน่วยความจำคือคอขวด การคำนวณควรย้ายเข้าไปอยู่ในหน่วยความจำ แทนที่จะให้ข้อมูลย้ายไปหาโปรเซสเซอร์หรือเปล่า speculative execution ซื้อความเร็วมาได้หลายสิบปี และกลายเป็นว่ามันรั่วความลับข้ามพรมแดนความปลอดภัยที่บทที่ 11 พึ่งพาอยู่ — เครื่องจะเร็วและซื่อสัตย์เรื่องที่มันกำลังทำอยู่ไปพร้อมกันได้ไหม และหลังการเฉพาะทาง อะไรจะเหลือให้คอมพิวเตอร์ อเนกประสงค์ เป็นได้อีก
Go deeper
อ่านต่อ
- John L. Hennessy & David A. Patterson, Computer Architecture: A Quantitative Approach, 7th ed. (with Christos Kozyrakis), Morgan Kaufmann, 2025 — the book that made architecture an experimental science. Publisher.
- Gene Amdahl, Gerrit Blaauw & Frederick Brooks, "Architecture of the IBM System/360," IBM Journal of Research and Development 8, no. 2 (1964): 87–101 — the paper that defined the word.
- William A. Wulf & Sally A. McKee, "Hitting the Memory Wall: Implications of the Obvious," ACM SIGARCH Computer Architecture News 23, no. 1 (1995): 20–24 — two pages, thirty years of consequences.
- John L. Hennessy & David A. Patterson, Computer Architecture: A Quantitative Approach, 7th ed. (with Christos Kozyrakis), Morgan Kaufmann, 2025 — หนังสือที่ทำให้ architecture กลายเป็นวิทยาศาสตร์เชิงทดลอง สำนักพิมพ์
- Gene Amdahl, Gerrit Blaauw & Frederick Brooks, "Architecture of the IBM System/360," IBM Journal of Research and Development 8, no. 2 (1964): 87–101 — เปเปอร์ที่นิยามคำนี้ขึ้นมา
- William A. Wulf & Sally A. McKee, "Hitting the Memory Wall: Implications of the Obvious," ACM SIGARCH Computer Architecture News 23, no. 1 (1995): 20–24 — สองหน้า สามสิบปีแห่งผลที่ตามมา