跳转至

Computer abstractions and Technology

约 532 个字 预计阅读时间 4 分钟

Eight Great Ideas

  1. Design for Moore's Law(设计紧跟摩尔定律)
    • Moore's Law: Integrated circuit resources double every 18-24 months.
    • Design for where it will be when finishes rather than design for where it starts.
  2. Use abstraction ti Simpify Design(采用抽象简化设计)
    • 层次化、模块化的设计
  3. Make the Common Case Fast (加速大概率事件)
  4. Performance via Parallelism(通过并行提高性能)
  5. Performance via Pipelining (通过流水线提高性能)
    • 换句话说就是,每个流程同时进行,只不过每一个流程工作的对象是时间上相邻的若干产品;
    • 相比于等一个产品完全生产完再开始下一个产品的生产,会快很多;
    • 希望每一个流程的时间是相对均匀的;
  6. Performance via Prediction (通过预测提高性能)
    • 例如先当作 if() 条件成立,执行完内部内容,如果后来发现确实成立,那么直接 apply,否则就再重新正常做;
    • 这么做就好在(又或者说只有这种情况适合预测),预测成功了就加速了,预测失败了纠正的成本也不高;
  7. Hierarchy of Memories (存储器层次)
    • Disk / Tape -> Main Memory(DRAM) -> L2-Cache(SRAM) -> L1-Cache(On-Chip) -> Registers
  8. Dependency via Redundancy(通过冗余提高可靠性)
    • 类似于卡车的多个轮胎,一个模块 down 了以后不会剧烈影响整个系统;

Performance Analysis

CPU Time

\[ \text{CPU Time} = \text{CPU Clock Cycles} \times \text{Clock Cycle Time} = \frac{\text{CPU Clock Cycles}}{\text{Clock Rate}} \]

CPI

CPI: Cycle Per Instruction

\[ \text{CPI} = \frac{\text{CPU Clock Cycles}}{\text{Instruction}} \]
\[ \text{CPU Time} = \text{CPI} \times \text{Instruction Count} \times \text{Clock Cycle Time} \]

MIPS

MIPS: Million Instructions Per Second

\[ \text{MIPS} = \frac{\text{Instruction Count}}{\text{CPU Time} \times 10^6} \]

Warning

这个指标不太能反映出CPU的性能,因为
1. 不同的CPU用的不同的ISA(指令集架构)
2. 不同的指令复杂度

Amdahl's rule

阿姆达尔定律/边际收益递减规律:改进计算机的一个方面,并期望整体性能按比例提高这样的优化思路是有问题的,总是有一部分内容只允许使用串行不能使用并行优化。

\[ T_{\text{improved}} = \frac{T_{\text{affected}}}{\text{improvement factor}} + T_{\text{unafffected}} \]