Taichi
Ubuntu 20.04
$ ubuntu-drivers devices
$ sudo ubuntu-drivers autoinstall # 安装 CUDA
$ sudo apt install libtinfo-dev
基本概念
- backend
func 可以调用 func
func 不能调用 kernel
kernel 可以调用 func
kernel 不能调 kernel
ti.func 强行 inline
最外层的 for loop 并行
struct-for loops: pixels 例子, 稀疏的元素
for loops 前后循环依赖怎么办?
原子操作不能被中断,并行时候有用
Taichi-scope: 编译并运行 Python-scope:Python 解释器运行
ti.init(arch=ti.gpu) ti.field ti.Vector ti.Matrix
ti.init(degug=True, arch=ti.cpu), 只能用 CPU
megakernel: 计算多,访存少
Lagrangian View: 小船 探测器 what are my position and velocity? Eulerian View: 木桩
弹簧质点系统: Mass-Spring Systems
ti.imwrite(img, filename)
ti video -f 24
ti gif -i imput.mp4
SPH implemented with C++ and CUDA
Smoothed Particle Hydrodynamics
屈服:yield
SOA: 排序后效率很高,随机访问 low cacheline utilization AOS: 不排序效率还可以
空间稀疏性:局部还可以是稠密的
一般的稀疏性:
快速失败的原则,这样才能有效找到更好的办法
Error-prone 容易出错 hard to analyze 难以分析
处理的复杂性是有限的
为什么还会把问题搞复杂?
搞出复杂的方法比简单的方法更容易一些
- 用复杂来证明自己很聪明
- 证明自己做了很多工作
- 去隐藏错误:没人理解我做的事,没人能证明我错了,所以我就是对的
- 科学的表述在于其可证伪
- 与前面的方法区分开来(发表论文)
- 懒
- Audience being too nice to tolerate *
Learning-for-Simulation
Simulation-for-Learning
有智慧的人可以把智慧传递给别人
加速了知识的传播
MGPCG