Skip to the content.

Computer Organization and Design: the Hardware/Software Interface (6th Edition, RISC-V Edition)

By David A. Patterson and John L. Hennessy


What You Can Learn in This Book

By the time you complete this book, we believe you will be able to answer the following questions:

Without understanding the answers to these questions, improving the performance of your program on a modern computer or evaluating what features might make one computer better than another for a particular application will be a complex process of trial and error(不断试错的复杂过程), rather than a scientific procedure(科学的过程) driven by insight and analysis.

Seven Great Ideas in Computer Architecture

The BIG Pictures


This table summarizes how the hardware and software affect performance:

Hardware or software component How this component affects performance Where is this topic covered?
Algorithm Determines both the number of source-level statements and the number of I/O operations executed Other books!
Programming language, compiler, and architecture Determines the number of computer instructions for each source-level statement Chapters 2 and 3
Processor and memory system Determines how fast instructions can be executed Chapters 4, 5, and 6
I/O system (hardware and operating system) Determines how fast I/O operations may be executed Chapters 4, 5, and 6

Defining Performance

\[Performance_X = \frac{1}{Execution \ time_X}\]







x + (-x) = 10000000 = 2^n

2^n - (-x)






C code:
int fact (int n)
  if (n < 1) return (1);
  else return (n * fact(n − 1));

RISC-V code:
  addi sp, sp, -8
  sw x1, 4(sp)
  sw x10, 0(sp)
  addi x5, x10, -1
	bge x5, x0, L1

	addi x10, x0, 1 
	addi sp, sp, 8 
	// 返回
	jalr x0, 0(x1)
	// n - 1
	addi x10, x10, -1
	jal x1, fact

	// x6 = fact(n - 1)
	addi x6, x10, 0
	lw x10, 0(sp) 
	lw x1, 4(sp) 
	addi sp, sp, 8
	// n * fact(n - 1)
	mul x10, x10, x6
	// 返回
	jalr x0, 0(x1)