11601 Week 7 - 位运算及多线程

作者 QIFAN 日期 2016-10-13
11601 Week 7 - 位运算及多线程

CMU 11601 Coding BootCamp


知识点

1. 位运算

2. Parallism and Multi-threading

High level parallel system architechtures
Single Instruction Single Data (SISD)
Single Instruction Multiple Data (SIMD)
Multiple Instruction Multiple Data (MISD)
Multiple Instruction Multiple Data (MIMD)

heavy way: multiple instructions
light way: single instruction

serial/stochastic
Fine Grain
Coarse Grain
Embarassingly Parallism

parallism = ~Dependency

dependency种类

  • naming dependency: 计算时使用一个之后会改变的值
  • output dependency: 计算顺序对结果有影响
  • control dependency: 上一步instruction决定当前运算是否要执行
  • data dependency: 当前计算需要上一步计算的结果

better multithreading:
Synchornization: wait/notify
BlockingQueue

InClass

  1. what class can an inner class extended?
  • any class
  1. 考察XOR
    返回a,b之间的两两XOR最小的
    int maximum_XOR(int a, int b) {
    int min = Integer.MIN_VALUE;
    for(int i=a; i<=b; i++) {
    for(int j=a; j<=b; j++) {
    min = Math.max(min, i^j);
    }
    }
    return min;
    }

因midterm本周无shuffle和homework