feat: improve

This commit is contained in:
Renge 2024-04-24 23:03:27 -04:00
parent 50d5a5fa42
commit 312cd28f32

View File

@ -107,7 +107,7 @@ level: 2
transition: slide-up transition: slide-up
--- ---
# A simple blur algorithm # A Simple Blur Algorithm
````md magic-move ````md magic-move
```cpp {all|3|4|all} twoslash ```cpp {all|3|4|all} twoslash
@ -186,11 +186,11 @@ alloc out[2046][3072]
for each ty in 0..2048/32: for each ty in 0..2048/32:
for each tx in 0..3072/32: for each tx in 0..3072/32:
alloc blurx[-1..33][32] alloc blurx[-1..33][32]
for y in -1..33: for each y in -1..33:
for x in 0..32: for each x in 0..32:
blurx[y][x] = in[ty*32+y][tx*32+x-1] + in[ty*32+y][tx*32+x] + in[ty*32+y][tx*32+x+1] blurx[y][x] = in[ty*32+y][tx*32+x-1] + in[ty*32+y][tx*32+x] + in[ty*32+y][tx*32+x+1]
for y in 0..32: for each y in 0..32:
for x in 0..32: for each x in 0..32:
out[ty*32+y][tx*32+x] = blurx[y-1][x] + blurx[y ][x] + blurx[y+1][x] out[ty*32+y][tx*32+x] = blurx[y-1][x] + blurx[y ][x] + blurx[y+1][x]
``` ```
@ -199,11 +199,11 @@ for each ty in 0..2048/32:
alloc out[2046][3072] alloc out[2046][3072]
for each ty in 0..2048/8: for each ty in 0..2048/8:
alloc blurx[-1..1][3072] alloc blurx[-1..1][3072]
for y in -2..8: for each y in -2..8:
for x in 0..3072: for each x in 0..3072:
blurx[(y+1)%3][x] = in[ty*8+y+1][tx*32+x-1] + in[ty*8+y+1][tx*32+x] + in[ty*8+y+1][tx*32+x+1] blurx[(y+1)%3][x] = in[ty*8+y+1][tx*32+x-1] + in[ty*8+y+1][tx*32+x] + in[ty*8+y+1][tx*32+x+1]
if y < 0: continue if each y < 0: continue
for x in 0..3072: for each x in 0..3072:
out[ty*8+y][x] = blurx[(y-1)%3][x] + blurx[ y % 3][x] + blurx[(y+1)%3][x] out[ty*8+y][x] = blurx[(y-1)%3][x] + blurx[ y % 3][x] + blurx[(y+1)%3][x]
``` ```
@ -237,10 +237,13 @@ hideInToc: true
| Local Laplacian | 21 | 189* | 9× | 52 | 262* | 5× | | Local Laplacian | 21 | 189* | 9× | 52 | 262* | 5× |
--- ---
transition: slide-left
---
# References # References
- [Halide: a language and compiler for optimizing parallelism, locality, and recomputation in image processing pipelines](https://dl.acm.org/doi/10.1145/2491956.2462176) - [Halide: a language and compiler for optimizing parallelism, locality, and recomputation in image processing pipelines](https://dl.acm.org/doi/10.1145/2491956.2462176)
- [CPU die shot](https://www.computerhope.com/issues/pictures/cpu-cache-die.png) - [CPU die shot](https://www.computerhope.com/issues/pictures/cpu-cache-die.png)
- [Memory Hierarchy](https://www.cs.swarthmore.edu/~kwebb/cs31/f18/memhierarchy/figures/MemoryHierarchy.png) - [Memory Hierarchy](https://www.cs.swarthmore.edu/~kwebb/cs31/f18/memhierarchy/figures/MemoryHierarchy.png)
- [Moore's Law](https://image3.slideserve.com/6552767/moore-s-law-l.jpg) - [Moore's Law](https://image3.slideserve.com/6552767/moore-s-law-l.jpg)
---
# Questions?