并行程序设计导论课程笔记


前言

B站硬核课程加州大学伯克利分校 CS 194 并行程序设计导论 Introduction to Parallel Programming

https://www.bilibili.com/video/BV1QQ4y1o7rn?p=3&spm_id_from=pageDriver&vd_source=e0b3cb923dbb83260e674c055a5ec68f


Lecture3:Cache Oblivious Matmul

blocked matrix multiply

右矩阵数据复用,减少整个列读的次数
这样B只需要重复读N次,而不是j次
3-0

Recursive Matrix Multiplication

以2维mm递归把for循环展开,直接把memory读到cache里
3-1
3-2

3-3

  • func嵌套不能太深到1*1,需要先切右矩阵确定最小计算单元

推荐读物:
https://cvw.cac.cornell.edu/vector/

Lecture6:shared memory(openMP)

6-1

Lecture7:roofline performance model

论文连接:
https://people.eecs.berkeley.edu/~kubitron/cs252/handouts/papers/RooflineVyNoYellow.pdf

7-1
7-2

7-3
machine balance = 4
所以先评估当前程序是在machine balance的左边还是右边

最左边上移:

  • reduce attentable bandwise:
    lack prefetch,
    ignore NUMA(non-uniform memory access some memory closer to some cores)

  • different badwidth for multiple level

Peak DP上移:

  • 增加computation intensity
  • bandwidth-reducing:
    cache re-use(tiling)
    compression techiques

Lecture8:Synchronization

避免shared memory的资源竞争。如果多线程同时往同一个shared memory里写,每个线程会独立把memory加载到L1 cache里,写锁导致无法并行
8-1
8-2
8-3

8-4

Lecture9:Load Balancing

9-1

  • self scheduling: https://dl.acm.org/doi/pdf/10.1145/55364.55422
  • Guided self-scheduling: A practical scheduling scheme for parallel supercomputers

一个processor一个task queue的情况下,需要有调度,某个processor执行快了,需要从别的task queue里去拿一部分task来保证balance:
9-2
从random processor里拿task:
如果n == p的情况不优,只有task足够大才用这种方法,
找计算时间最长的task比较通用

9-3

Lecture10:Linearizablity

https://dl.acm.org/doi/pdf/10.5555/2385452

concurrent queue

10-1
10-2

总结

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值