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

link: https://www.elsevier.com/books/computer-organization-and-design-risc-v-edition/patterson/978-0-12-820331-6

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

Performance

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}\]

image-20210717153929167

image-20210718005023603

image-20210718005420681

image-20210718005952569

image-20210718155437463

image-20210718155842969

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

2^n - (-x)

术语

读不懂的英文句子

读错的英文单词

queue,procedure,parameter,

test:

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

RISC-V code:
fact:
  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)
L1: 
	// 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)