计算机概论 1
最近在YoutuBe上学习台湾大学的一场公开课,于天立主讲,感觉挺有意思的,故撰写该笔记进行和大家探讨。
文章目录
Data Manipulation (数据操控)
Function of ALU(Arithmetic and Logic unit)
运用逻辑右移输出二进制位
#include <iostream>
using namespace std;
void printBin(int num)
{
int mask = 1 << 7; //10000000
for (int i = 0; i < 8; ++i){
cout << (((num & mask) == 0)? 0:1);
mask >> 1;
}
cout << endl;
}
printBin (64); //01000000
printBin (7); //00000111
xor Instruction is used reverted:常见的与,或,非,往往运算数都是f,用来逻辑运算被运算数:异或也一样, 0x314(001100010100b) ^ 0xfff = 0xceb(110011101011b)
input and output(I/O)
DMA: direct memory access.
MMIO: Memory-mapped I/O. 简谈:读写内存的方式操作I/O。
bps: bit per second.
Program Execution (程序执行)
- Instruction register(IR), program counter(PC)
- Machine cycle: clock
Fetch -> Decode -> Execute
Pipelining (流水线)
每个电路负责的任务不同,取指电路,译码电路,执行电路等。
Jump 条件跳转指令会浪费fetch的操作,所以分支预测很重要。
Parallel/distributed(分发) Computing
- Parallel 并行处理
a = b + c
d = e + f //32位加法或16,8位加法
( a , d ) = ( b , e ) + ( c , f ) 假设64位处理器为了确保资源与效率,32bit加法使用64bit向量加法,处理器提供相应指令集. - Distributed,相当于区块链技术,分隔算力。
Linking several computers via network.
Separate processors, separate memory. - Issues 保证计算资料分配合理与安全有效
Data dependency(数据依赖)
Load Balancing (负载均衡)
Synchronization(同步)
Reliability (可靠性)
How to parallelize?(针对多核处理器)
科普小知识点:斐波那契数列:F(N) = F(N-1) + F(N-2)
Speedup & Scaling
P: proportion that can be paralleized //可被并行化的任务比例
G
a
i
n
=
1
P
M
+
(
1
−
P
)
Gain = \dfrac{1}{\dfrac{P}{M}+(1-P)}
Gain=MP+(1−P)1
通过上述公示M为处理器核数,P为可被平行化的任务,当M->∞时,理论上最大可以提升5倍。
(争夺资源时一定要保证最大效率,往往可能有些反而会降低原有的效率)。
下一节:Data Storage,希望大家共同努力学习ing 星星之火,可以燎原。