GPU Puzzles
31–40 of 44 posts
Re: GPU Puzzles
#32Re: GPU Puzzles
#33Re: GPU Puzzles
#34Re: GPU Puzzles
#35When working on GPU code there’s really two parts to it, I feel. One is “how do I even write code for the GPU” which this tutorial seems to cover but there’s a second part which is “how do I write good code for the GPU” which seems like it would need another resource or expansion to this one.
1. instead of buildings, IP cores doing processing steps;
2. instead of belts, wires — which take up far less than one tile, so many can run together along one tile and many can connect to a single IP core; where each wire can move its contents at arbitrary speed (including "stopped") — but where this will have a power-use cost proportional to the wire's speed;
3. an overall goal of optimizing for rocket launches per second per power-usage watt. (Which should overall require minimizing the amount of stuff moving around across the whole base, avoiding pipeline stalls; doing as much parallel batching as possible; etc.)
(Yes, I know Shenzhen I/O exists. It's great for what it does — modelling signals and signal transformations — but it doesn't model individual packets of data as moving along wires with propagation delay, and with the potential for e.g. parallel-line interference given a bad encoding scheme, quantum tunnelling, overclocking or undervolting components, etc. I think a Factorio-variant would actually be much more flexible to implement these aspects.)
Re: GPU Puzzles
#36I loved the tensor puzzles you made. I spent the morning revisiting and liking all the videos on youtube you've made. Hope for many more in the future!
Re: GPU Puzzles
#37So I'm used to working with lists and maps, which doesn't really track well with tackling problems on thousands of cores. Is the usual strategy to worry less about repeating calculations and just use brute force to tackle the problem? Is there a good resource to read about how to tackle problems in an extremely parallel way?
Re: GPU Puzzles
#38Can I hire you to make Flash Attention a reality for V100?
Re: GPU Puzzles
#39So I'm used to working with lists and maps, which doesn't really track well with tackling problems on thousands of cores. Is the usual strategy to worry less about repeating calculations and just use brute force to tackle the problem? Is there a good resource to read about how to tackle problems in an extremely parallel way?
It is true that you don’t have to worry as much about repeating calculations. I think you’re referring to “rematerialization”, meaning after doing some non-trivial calculation once and using the result, throwing it away and redoing the same calculation again later on the same thread. It’s true this can sometimes be advantageous, mostly because memory use is so expensive. One load or store into VRAM can be as expensive as 10 or sometimes even 100 math instructions, so if your store & load takes 40 cycles, and recomputing something takes 25 cycles of math using registers, then recomputing can be faster.
I second the sibling recommendation to learn numpy, it’s a different way of thinking than single-threaded functional programming with lists & maps. Try writing some kind of image filter in Python both ways, and get a feel for the performance difference. If you’re familiar with Python, this is a one or two hour exercise. Last time I tried it, my numpy version was ~2 orders of magnitude faster than the lists & maps version.
One of the most fun ways to learn SIMD programming, in my humble opinion, is to study the shaders on ShaderToy. ShaderToy makes it super simple to write GPU code and see the result. Some of the tricks people use are very clever, but after studying them for a while and trying a few yourself, you’ll start to see themes emerge about how to organize parallel image computations.
Re: GPU Puzzles
#40I recently ported this to Metal for Apple Silicon computers. If you're interested in learning GPU programming on an M series Mac, I think this is a very accessible option. Thanks to Sasha for making this! https://github.com/abeleinin/Metal-Puzzles